diff --git a/Kyoo/ClientApp/src/app/browse/browse.component.html b/Kyoo/ClientApp/src/app/browse/browse.component.html index 4b75ca34..9463805f 100644 --- a/Kyoo/ClientApp/src/app/browse/browse.component.html +++ b/Kyoo/ClientApp/src/app/browse/browse.component.html @@ -21,7 +21,7 @@
{{show.title}}
{{show.startYear}} - {{show.endYear}}
diff --git a/Kyoo/ClientApp/src/app/browse/browse.component.ts b/Kyoo/ClientApp/src/app/browse/browse.component.ts index 3399b521..dc88b664 100644 --- a/Kyoo/ClientApp/src/app/browse/browse.component.ts +++ b/Kyoo/ClientApp/src/app/browse/browse.component.ts @@ -28,6 +28,14 @@ export class BrowseComponent implements OnInit return this.sanitizer.bypassSecurityTrustStyle("url(/poster/" + slug + ")"); } + getLink(show: Show) + { + if (show.isCollection) + return "/collection/" + show.slug; + else + return "/show/" + show.slug; + } + sort(type: string, order: boolean) { this.sortType = type; diff --git a/Kyoo/ClientApp/src/models/show.ts b/Kyoo/ClientApp/src/models/show.ts index be30cdb5..65748657 100644 --- a/Kyoo/ClientApp/src/models/show.ts +++ b/Kyoo/ClientApp/src/models/show.ts @@ -16,10 +16,10 @@ export interface Show people: People[]; seasons: Season[]; trailerUrl: string; + isCollection: boolean; startYear: number; endYear : number; externalIDs: string; - } diff --git a/Kyoo/InternalAPI/Crawler/Crawler.cs b/Kyoo/InternalAPI/Crawler/Crawler.cs index 673aadf9..d6b035f3 100644 --- a/Kyoo/InternalAPI/Crawler/Crawler.cs +++ b/Kyoo/InternalAPI/Crawler/Crawler.cs @@ -1,4 +1,5 @@ -using Kyoo.Models; +using Kyoo.InternalAPI.Utility; +using Kyoo.Models; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Hosting; using System.Collections.Generic; @@ -15,17 +16,17 @@ namespace Kyoo.InternalAPI { private readonly CancellationTokenSource cancellation; - private readonly IConfiguration config; private readonly ILibraryManager libraryManager; private readonly IMetadataProvider metadataProvider; private readonly ITranscoder transcoder; + private readonly IConfiguration config; - public Crawler(IConfiguration configuration, ILibraryManager libraryManager, IMetadataProvider metadataProvider, ITranscoder transcoder) + public Crawler(ILibraryManager libraryManager, IMetadataProvider metadataProvider, ITranscoder transcoder, IConfiguration configuration) { - config = configuration; this.libraryManager = libraryManager; this.metadataProvider = metadataProvider; this.transcoder = transcoder; + config = configuration; cancellation = new CancellationTokenSource(); } @@ -129,12 +130,13 @@ namespace Kyoo.InternalAPI Match match = regex.Match(path); string showPath = Path.GetDirectoryName(path); + string collectionName = match.Groups["Collection"]?.Value; string showName = match.Groups["ShowTitle"].Value; bool seasonSuccess = long.TryParse(match.Groups["Season"].Value, out long seasonNumber); bool episodeSucess = long.TryParse(match.Groups["Episode"].Value, out long episodeNumber); long absoluteNumber = -1; - if(!seasonSuccess || !episodeSucess) + if (!seasonSuccess || !episodeSucess) { //Considering that the episode is using absolute path. seasonNumber = -1; @@ -160,6 +162,16 @@ namespace Kyoo.InternalAPI showProviderIDs = show.ExternalIDs; showID = libraryManager.RegisterShow(show); + if (collectionName != null) + { + if (!libraryManager.IsCollectionRegistered(Slugifier.ToSlug(collectionName), out long collectionID)) + { + Collection collection = await metadataProvider.GetCollectionFromName(collectionName); + collectionID = libraryManager.RegisterCollection(collection); + } + libraryManager.AddShowToCollection(showID, collectionID); + } + List