-
Notifications
You must be signed in to change notification settings - Fork 74
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: change generated playlists (again)
Added better support for multi-episode files in playlists by changing the structure from 1-N to N-N, but we restrict playlist items to a 1-N or N-1 pattern even if the playlist theoretically allows N-N items. Tweaked the playlist hydration to be more flexible, and moved the hydration logic from the API layer to the service layer. Series and episodes now use AniDB IDs, while files use either local IDs or lookup by ED2K hash, optionally with a file size provided. The query options have all been moved into the playlist near their respective item, instead of being applied globally, so we can apply the series options on a per series basis and preferred release group ID per series and/or episode. Because of the new flexibility then we can now provide episodes and files together to to watch one or more files for one or more episodes, instead of leaving the file/episode choice up to the auto-detect logic. See the example below for a made up example of how this would work **Example** Given a dehydrated playlist as follows; ```txt api/v3/Playlist/Generate?playlist=e2345+f234234,e2346,e953423+20A3246CC1BD7C513598FD49F250348B,3456,s69+onlyUnwatched+includeSpecials,e23423+e953423+20A3246CC1BD7C513598FD49F250348B-135345345345,s12+r123+includeRewatching ``` It would hydrate to the following: - `e2345+f234234`: Add episode `2345` with local file `234234`. - `e2346`: Add episode `2346` without a file specified, letting the system auto-detect the file to use. - `e953423+20A3246CC1BD7C513598FD49F250348B`: Add episode `953423` with the local file specified by the ED2K hash `20A3246CC1BD7C513598FD49F250348B`. - `3456`: Add local file `3456` without an episode specified, letting the system auto-detect the episode to use. - `s69+onlyUnwatched+includeSpecials`: Add unwatched episodes and specials from series `69`. - `e23423+e953423+20A3246CC1BD7C513598FD49F250348B-135345345345`: Add the local file specified by the ED2K hash `20A3246CC1BD7C513598FD49F250348B` and file size `135345345345` for episode `23423` and `953423`. - `s12+r123+includeRewatching`: Prefer release group `123` for series `12` and start the playlist from the first episode that's being re-watched if any, or otherwise fallback to the normal behavior.
- Loading branch information
Showing
3 changed files
with
332 additions
and
145 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
|
||
namespace Shoko.Server.API.v3.Models.Shoko; | ||
|
||
/// <summary> | ||
/// Playlist item. | ||
/// </summary> | ||
public class PlaylistItem | ||
{ | ||
/// <summary> | ||
/// The main episode for the playlist item. | ||
/// </summary> | ||
public Episode Episode { get; } | ||
|
||
/// <summary> | ||
/// Any additional episodes for the playlist item, if any. | ||
/// </summary> | ||
public IReadOnlyList<Episode> AdditionalEpisodes { get; } | ||
|
||
/// <summary> | ||
/// All file parts for the playlist item. | ||
/// </summary> | ||
public IReadOnlyList<File> Parts { get; } | ||
|
||
/// <summary> | ||
/// Initializes a new <see cref="PlaylistItem"/>. | ||
/// </summary> | ||
/// <param name="episodes">Episodes.</param> | ||
/// <param name="files">Files.</param> | ||
public PlaylistItem(IReadOnlyList<Episode> episodes, IReadOnlyList<File> files) | ||
{ | ||
Episode = episodes[0]; | ||
AdditionalEpisodes = episodes.Skip(1).ToList(); | ||
Parts = files; | ||
} | ||
} | ||
|
Oops, something went wrong.