mirror of
https://github.com/zoriya/Kyoo.git
synced 2025-06-03 05:34:23 -04:00
Adding default values when no data providers can Work. Cleaning up everything
This commit is contained in:
parent
3e9da31ac5
commit
8b8e89d123
@ -17,7 +17,7 @@ namespace Kyoo.Controllers
|
|||||||
Task<IEnumerable<People>> GetPeople(Show show);
|
Task<IEnumerable<People>> GetPeople(Show show);
|
||||||
|
|
||||||
//For the seasons
|
//For the seasons
|
||||||
Task<Season> GetSeason(string showName, long seasonNumber);
|
Task<Season> GetSeason(Show show, long seasonNumber);
|
||||||
|
|
||||||
//For the episodes
|
//For the episodes
|
||||||
Task<Episode> GetEpisode(Show show, long seasonNumber, long episodeNumber, long absoluteNumber);
|
Task<Episode> GetEpisode(Show show, long seasonNumber, long episodeNumber, long absoluteNumber);
|
||||||
|
@ -8,7 +8,7 @@ namespace Kyoo.Controllers
|
|||||||
{
|
{
|
||||||
Task<Collection> GetCollectionFromName(string name, Library library);
|
Task<Collection> GetCollectionFromName(string name, Library library);
|
||||||
Task<Show> GetShowFromName(string showName, Library library);
|
Task<Show> GetShowFromName(string showName, Library library);
|
||||||
Task<Season> GetSeason(string showName, long seasonNumber, Library library);
|
Task<Season> GetSeason(Show show, long seasonNumber, Library library);
|
||||||
Task<Episode> GetEpisode(Show show, long seasonNumber, long episodeNumber, long absoluteNumber, Library library);
|
Task<Episode> GetEpisode(Show show, long seasonNumber, long episodeNumber, long absoluteNumber, Library library);
|
||||||
Task<IEnumerable<People>> GetPeople(Show show, Library library);
|
Task<IEnumerable<People>> GetPeople(Show show, Library library);
|
||||||
}
|
}
|
||||||
|
@ -8,7 +8,7 @@ namespace Kyoo.Models
|
|||||||
public class Collection : IMergable<Collection>
|
public class Collection : IMergable<Collection>
|
||||||
|
|
||||||
{
|
{
|
||||||
[JsonIgnore] public long id = -1;
|
[JsonIgnore] public long ID = -1;
|
||||||
public string Slug;
|
public string Slug;
|
||||||
public string Name;
|
public string Name;
|
||||||
public string Poster;
|
public string Poster;
|
||||||
@ -16,13 +16,11 @@ namespace Kyoo.Models
|
|||||||
[JsonIgnore] public string ImgPrimary;
|
[JsonIgnore] public string ImgPrimary;
|
||||||
public IEnumerable<Show> Shows;
|
public IEnumerable<Show> Shows;
|
||||||
|
|
||||||
public Collection()
|
public Collection() { }
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public Collection(long id, string slug, string name, string overview, string imgPrimary)
|
public Collection(long id, string slug, string name, string overview, string imgPrimary)
|
||||||
{
|
{
|
||||||
this.id = id;
|
ID = id;
|
||||||
Slug = slug;
|
Slug = slug;
|
||||||
Name = name;
|
Name = name;
|
||||||
Overview = overview;
|
Overview = overview;
|
||||||
@ -47,14 +45,14 @@ namespace Kyoo.Models
|
|||||||
|
|
||||||
public Collection SetShows(ILibraryManager libraryManager)
|
public Collection SetShows(ILibraryManager libraryManager)
|
||||||
{
|
{
|
||||||
Shows = libraryManager.GetShowsInCollection(id);
|
Shows = libraryManager.GetShowsInCollection(ID);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Collection Merge(Collection collection)
|
public Collection Merge(Collection collection)
|
||||||
{
|
{
|
||||||
if (id == -1)
|
if (ID == -1)
|
||||||
id = collection.id;
|
ID = collection.ID;
|
||||||
if (Slug == null)
|
if (Slug == null)
|
||||||
Slug = collection.Slug;
|
Slug = collection.Slug;
|
||||||
if (Name == null)
|
if (Name == null)
|
||||||
|
@ -5,13 +5,13 @@ namespace Kyoo.Models
|
|||||||
{
|
{
|
||||||
public class Episode : IMergable<Episode>
|
public class Episode : IMergable<Episode>
|
||||||
{
|
{
|
||||||
[JsonIgnore] public long id;
|
[JsonIgnore] public long ID;
|
||||||
[JsonIgnore] public long ShowID;
|
[JsonIgnore] public long ShowID;
|
||||||
[JsonIgnore] public long SeasonID;
|
[JsonIgnore] public long SeasonID;
|
||||||
|
|
||||||
public long seasonNumber;
|
public long SeasonNumber;
|
||||||
public long episodeNumber;
|
public long EpisodeNumber;
|
||||||
public long absoluteNumber;
|
public long AbsoluteNumber;
|
||||||
[JsonIgnore] public string Path;
|
[JsonIgnore] public string Path;
|
||||||
public string Title;
|
public string Title;
|
||||||
public string Overview;
|
public string Overview;
|
||||||
@ -27,16 +27,24 @@ namespace Kyoo.Models
|
|||||||
public string Thumb; //Used in the API response only
|
public string Thumb; //Used in the API response only
|
||||||
|
|
||||||
|
|
||||||
public Episode() { }
|
public Episode()
|
||||||
|
{
|
||||||
|
ID = -1;
|
||||||
|
ShowID = -1;
|
||||||
|
SeasonID = -1;
|
||||||
|
SeasonNumber = -1;
|
||||||
|
EpisodeNumber = -1;
|
||||||
|
AbsoluteNumber = -1;
|
||||||
|
}
|
||||||
|
|
||||||
public Episode(long seasonNumber, long episodeNumber, long absoluteNumber, string title, string overview, DateTime? releaseDate, long runtime, string imgPrimary, string externalIDs)
|
public Episode(long seasonNumber, long episodeNumber, long absoluteNumber, string title, string overview, DateTime? releaseDate, long runtime, string imgPrimary, string externalIDs)
|
||||||
{
|
{
|
||||||
id = -1;
|
ID = -1;
|
||||||
ShowID = -1;
|
ShowID = -1;
|
||||||
SeasonID = -1;
|
SeasonID = -1;
|
||||||
this.seasonNumber = seasonNumber;
|
SeasonNumber = seasonNumber;
|
||||||
this.episodeNumber = episodeNumber;
|
EpisodeNumber = episodeNumber;
|
||||||
this.absoluteNumber = absoluteNumber;
|
AbsoluteNumber = absoluteNumber;
|
||||||
Title = title;
|
Title = title;
|
||||||
Overview = overview;
|
Overview = overview;
|
||||||
ReleaseDate = releaseDate;
|
ReleaseDate = releaseDate;
|
||||||
@ -47,12 +55,12 @@ namespace Kyoo.Models
|
|||||||
|
|
||||||
public Episode(long id, long showID, long seasonID, long seasonNumber, long episodeNumber, long absoluteNumber, string path, string title, string overview, DateTime? releaseDate, long runtime, string imgPrimary, string externalIDs)
|
public Episode(long id, long showID, long seasonID, long seasonNumber, long episodeNumber, long absoluteNumber, string path, string title, string overview, DateTime? releaseDate, long runtime, string imgPrimary, string externalIDs)
|
||||||
{
|
{
|
||||||
this.id = id;
|
ID = id;
|
||||||
ShowID = showID;
|
ShowID = showID;
|
||||||
SeasonID = seasonID;
|
SeasonID = seasonID;
|
||||||
this.seasonNumber = seasonNumber;
|
SeasonNumber = seasonNumber;
|
||||||
this.episodeNumber = episodeNumber;
|
EpisodeNumber = episodeNumber;
|
||||||
this.absoluteNumber = absoluteNumber;
|
AbsoluteNumber = absoluteNumber;
|
||||||
Path = path;
|
Path = path;
|
||||||
Title = title;
|
Title = title;
|
||||||
Overview = overview;
|
Overview = overview;
|
||||||
@ -82,7 +90,7 @@ namespace Kyoo.Models
|
|||||||
|
|
||||||
public Episode SetThumb(string showSlug)
|
public Episode SetThumb(string showSlug)
|
||||||
{
|
{
|
||||||
Link = GetSlug(showSlug, seasonNumber, episodeNumber);
|
Link = GetSlug(showSlug, SeasonNumber, EpisodeNumber);
|
||||||
Thumb = "thumb/" + Link;
|
Thumb = "thumb/" + Link;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
@ -100,18 +108,18 @@ namespace Kyoo.Models
|
|||||||
|
|
||||||
public Episode Merge(Episode other)
|
public Episode Merge(Episode other)
|
||||||
{
|
{
|
||||||
if (id == -1)
|
if (ID == -1)
|
||||||
id = other.id;
|
ID = other.ID;
|
||||||
if (ShowID == -1)
|
if (ShowID == -1)
|
||||||
ShowID = other.ShowID;
|
ShowID = other.ShowID;
|
||||||
if (SeasonID == -1)
|
if (SeasonID == -1)
|
||||||
SeasonID = other.SeasonID;
|
SeasonID = other.SeasonID;
|
||||||
if (seasonNumber == -1)
|
if (SeasonNumber == -1)
|
||||||
seasonNumber = other.seasonNumber;
|
SeasonNumber = other.SeasonNumber;
|
||||||
if (episodeNumber == -1)
|
if (EpisodeNumber == -1)
|
||||||
episodeNumber = other.episodeNumber;
|
EpisodeNumber = other.EpisodeNumber;
|
||||||
if (absoluteNumber == -1)
|
if (AbsoluteNumber == -1)
|
||||||
absoluteNumber = other.absoluteNumber;
|
AbsoluteNumber = other.AbsoluteNumber;
|
||||||
if (Path == null)
|
if (Path == null)
|
||||||
Path = other.Path;
|
Path = other.Path;
|
||||||
if (Title == null)
|
if (Title == null)
|
||||||
|
@ -4,7 +4,7 @@ namespace Kyoo.Models
|
|||||||
{
|
{
|
||||||
public class Genre
|
public class Genre
|
||||||
{
|
{
|
||||||
[JsonIgnore] public readonly long id;
|
[JsonIgnore] public readonly long ID;
|
||||||
public string Slug;
|
public string Slug;
|
||||||
public string Name;
|
public string Name;
|
||||||
|
|
||||||
@ -16,7 +16,7 @@ namespace Kyoo.Models
|
|||||||
|
|
||||||
public Genre(long id, string slug, string name)
|
public Genre(long id, string slug, string name)
|
||||||
{
|
{
|
||||||
this.id = id;
|
this.ID = id;
|
||||||
Slug = slug;
|
Slug = slug;
|
||||||
Name = name;
|
Name = name;
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,7 @@ namespace Kyoo.Models
|
|||||||
{
|
{
|
||||||
public class Library
|
public class Library
|
||||||
{
|
{
|
||||||
[JsonIgnore] public readonly long id;
|
[JsonIgnore] public readonly long ID;
|
||||||
public string Slug;
|
public string Slug;
|
||||||
public string Name;
|
public string Name;
|
||||||
public string[] Paths;
|
public string[] Paths;
|
||||||
@ -12,7 +12,7 @@ namespace Kyoo.Models
|
|||||||
|
|
||||||
public Library(long id, string slug, string name, string[] paths, string[] providers)
|
public Library(long id, string slug, string name, string[] paths, string[] providers)
|
||||||
{
|
{
|
||||||
this.id = id;
|
ID = id;
|
||||||
Slug = slug;
|
Slug = slug;
|
||||||
Name = name;
|
Name = name;
|
||||||
Paths = paths;
|
Paths = paths;
|
||||||
|
@ -4,33 +4,35 @@ namespace Kyoo.Models
|
|||||||
{
|
{
|
||||||
public class People : IMergable<People>
|
public class People : IMergable<People>
|
||||||
{
|
{
|
||||||
[JsonIgnore] public long id;
|
[JsonIgnore] public long ID = -1;
|
||||||
public string slug;
|
public string Slug;
|
||||||
public string Name;
|
public string Name;
|
||||||
public string Role; //Dynamic data not stored as it in the database
|
public string Role; //Dynamic data not stored as it in the database
|
||||||
public string Type; //Dynamic data not stored as it in the database ---- Null for now
|
public string Type; //Dynamic data not stored as it in the database ---- Null for now
|
||||||
[JsonIgnore] public string imgPrimary;
|
[JsonIgnore] public string ImgPrimary;
|
||||||
|
|
||||||
public string externalIDs;
|
public string ExternalIDs;
|
||||||
|
|
||||||
|
public People() {}
|
||||||
|
|
||||||
public People(long id, string slug, string name, string imgPrimary, string externalIDs)
|
public People(long id, string slug, string name, string imgPrimary, string externalIDs)
|
||||||
{
|
{
|
||||||
this.id = id;
|
ID = id;
|
||||||
this.slug = slug;
|
Slug = slug;
|
||||||
Name = name;
|
Name = name;
|
||||||
this.imgPrimary = imgPrimary;
|
ImgPrimary = imgPrimary;
|
||||||
this.externalIDs = externalIDs;
|
ExternalIDs = externalIDs;
|
||||||
}
|
}
|
||||||
|
|
||||||
public People(long id, string slug, string name, string role, string type, string imgPrimary, string externalIDs)
|
public People(long id, string slug, string name, string role, string type, string imgPrimary, string externalIDs)
|
||||||
{
|
{
|
||||||
this.id = id;
|
ID = id;
|
||||||
this.slug = slug;
|
Slug = slug;
|
||||||
Name = name;
|
Name = name;
|
||||||
Role = role;
|
Role = role;
|
||||||
Type = type;
|
Type = type;
|
||||||
this.imgPrimary = imgPrimary;
|
ImgPrimary = imgPrimary;
|
||||||
this.externalIDs = externalIDs;
|
ExternalIDs = externalIDs;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static People FromReader(System.Data.SQLite.SQLiteDataReader reader)
|
public static People FromReader(System.Data.SQLite.SQLiteDataReader reader)
|
||||||
@ -55,19 +57,19 @@ namespace Kyoo.Models
|
|||||||
|
|
||||||
public People Merge(People other)
|
public People Merge(People other)
|
||||||
{
|
{
|
||||||
if (id == -1)
|
if (ID == -1)
|
||||||
id = other.id;
|
ID = other.ID;
|
||||||
if (slug == null)
|
if (Slug == null)
|
||||||
slug = other.slug;
|
Slug = other.Slug;
|
||||||
if (Name == null)
|
if (Name == null)
|
||||||
Name = other.Name;
|
Name = other.Name;
|
||||||
if (Role == null)
|
if (Role == null)
|
||||||
Role = other.Role;
|
Role = other.Role;
|
||||||
if (Type == null)
|
if (Type == null)
|
||||||
Type = other.Type;
|
Type = other.Type;
|
||||||
if (imgPrimary == null)
|
if (ImgPrimary == null)
|
||||||
imgPrimary = other.imgPrimary;
|
ImgPrimary = other.ImgPrimary;
|
||||||
externalIDs += '|' + other.externalIDs;
|
ExternalIDs += '|' + other.ExternalIDs;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,11 +4,11 @@ namespace Kyoo.Models
|
|||||||
{
|
{
|
||||||
public class SearchResult
|
public class SearchResult
|
||||||
{
|
{
|
||||||
public string query;
|
public string Query;
|
||||||
public IEnumerable<Show> shows;
|
public IEnumerable<Show> Shows;
|
||||||
public IEnumerable<Episode> episodes;
|
public IEnumerable<Episode> Episodes;
|
||||||
public IEnumerable<People> people;
|
public IEnumerable<People> People;
|
||||||
public IEnumerable<Genre> genres;
|
public IEnumerable<Genre> Genres;
|
||||||
public IEnumerable<Studio> studios;
|
public IEnumerable<Studio> Studios;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,13 +4,13 @@ namespace Kyoo.Models
|
|||||||
{
|
{
|
||||||
public class Season : IMergable<Season>
|
public class Season : IMergable<Season>
|
||||||
{
|
{
|
||||||
[JsonIgnore] public readonly long id;
|
[JsonIgnore] public readonly long ID = -1;
|
||||||
[JsonIgnore] public long ShowID;
|
[JsonIgnore] public long ShowID = -1;
|
||||||
|
|
||||||
public long seasonNumber;
|
public long SeasonNumber = -1;
|
||||||
public string Title;
|
public string Title;
|
||||||
public string Overview;
|
public string Overview;
|
||||||
public long? year;
|
public long? Year;
|
||||||
|
|
||||||
[JsonIgnore] public string ImgPrimary;
|
[JsonIgnore] public string ImgPrimary;
|
||||||
public string ExternalIDs;
|
public string ExternalIDs;
|
||||||
@ -19,12 +19,12 @@ namespace Kyoo.Models
|
|||||||
|
|
||||||
public Season(long id, long showID, long seasonNumber, string title, string overview, long? year, string imgPrimary, string externalIDs)
|
public Season(long id, long showID, long seasonNumber, string title, string overview, long? year, string imgPrimary, string externalIDs)
|
||||||
{
|
{
|
||||||
this.id = id;
|
ID = id;
|
||||||
ShowID = showID;
|
ShowID = showID;
|
||||||
this.seasonNumber = seasonNumber;
|
SeasonNumber = seasonNumber;
|
||||||
Title = title;
|
Title = title;
|
||||||
Overview = overview;
|
Overview = overview;
|
||||||
this.year = year;
|
Year = year;
|
||||||
ImgPrimary = imgPrimary;
|
ImgPrimary = imgPrimary;
|
||||||
ExternalIDs = externalIDs;
|
ExternalIDs = externalIDs;
|
||||||
}
|
}
|
||||||
@ -45,14 +45,14 @@ namespace Kyoo.Models
|
|||||||
{
|
{
|
||||||
if (ShowID == -1)
|
if (ShowID == -1)
|
||||||
ShowID = other.ShowID;
|
ShowID = other.ShowID;
|
||||||
if (seasonNumber == -1)
|
if (SeasonNumber == -1)
|
||||||
seasonNumber = other.seasonNumber;
|
SeasonNumber = other.SeasonNumber;
|
||||||
if (Title == null)
|
if (Title == null)
|
||||||
Title = other.Title;
|
Title = other.Title;
|
||||||
if (Overview == null)
|
if (Overview == null)
|
||||||
Overview = other.Overview;
|
Overview = other.Overview;
|
||||||
if (year == null)
|
if (Year == null)
|
||||||
year = other.year;
|
Year = other.Year;
|
||||||
if (ImgPrimary == null)
|
if (ImgPrimary == null)
|
||||||
ImgPrimary = other.ImgPrimary;
|
ImgPrimary = other.ImgPrimary;
|
||||||
ExternalIDs += '|' + other.ExternalIDs;
|
ExternalIDs += '|' + other.ExternalIDs;
|
||||||
|
@ -8,7 +8,7 @@ namespace Kyoo.Models
|
|||||||
{
|
{
|
||||||
public class Show : IMergable<Show>
|
public class Show : IMergable<Show>
|
||||||
{
|
{
|
||||||
[JsonIgnore] public long id = -1;
|
[JsonIgnore] public long ID = -1;
|
||||||
|
|
||||||
public string Slug;
|
public string Slug;
|
||||||
public string Title;
|
public string Title;
|
||||||
@ -30,27 +30,21 @@ namespace Kyoo.Models
|
|||||||
public string ExternalIDs;
|
public string ExternalIDs;
|
||||||
|
|
||||||
//Used in the rest API excusively.
|
//Used in the rest API excusively.
|
||||||
public Studio studio;
|
public Studio Studio;
|
||||||
public IEnumerable<People> directors;
|
public IEnumerable<People> Directors;
|
||||||
public IEnumerable<People> people;
|
public IEnumerable<People> People;
|
||||||
public IEnumerable<Season> seasons;
|
public IEnumerable<Season> Seasons;
|
||||||
public bool IsCollection;
|
public bool IsCollection;
|
||||||
|
|
||||||
|
|
||||||
public string GetAliases()
|
public string GetAliases()
|
||||||
{
|
{
|
||||||
if (Aliases == null)
|
return Aliases == null ? null : string.Join('|', Aliases);
|
||||||
return null;
|
|
||||||
|
|
||||||
return string.Join('|', Aliases);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public string GetGenres()
|
public string GetGenres()
|
||||||
{
|
{
|
||||||
if (Genres == null)
|
return Genres == null ? null : string.Join('|', Genres);
|
||||||
return null;
|
|
||||||
|
|
||||||
return string.Join('|', Genres);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -58,7 +52,7 @@ namespace Kyoo.Models
|
|||||||
|
|
||||||
public Show(long id, string slug, string title, IEnumerable<string> aliases, string path, string overview, string trailerUrl, IEnumerable<Genre> genres, Status? status, long? startYear, long? endYear, string externalIDs)
|
public Show(long id, string slug, string title, IEnumerable<string> aliases, string path, string overview, string trailerUrl, IEnumerable<Genre> genres, Status? status, long? startYear, long? endYear, string externalIDs)
|
||||||
{
|
{
|
||||||
this.id = id;
|
ID = id;
|
||||||
Slug = slug;
|
Slug = slug;
|
||||||
Title = title;
|
Title = title;
|
||||||
Aliases = aliases;
|
Aliases = aliases;
|
||||||
@ -75,7 +69,7 @@ namespace Kyoo.Models
|
|||||||
|
|
||||||
public Show(long id, string slug, string title, IEnumerable<string> aliases, string path, string overview, string trailerUrl, Status? status, long? startYear, long? endYear, string imgPrimary, string imgThumb, string imgLogo, string imgBackdrop, string externalIDs)
|
public Show(long id, string slug, string title, IEnumerable<string> aliases, string path, string overview, string trailerUrl, Status? status, long? startYear, long? endYear, string imgPrimary, string imgThumb, string imgLogo, string imgBackdrop, string externalIDs)
|
||||||
{
|
{
|
||||||
this.id = id;
|
ID = id;
|
||||||
Slug = slug;
|
Slug = slug;
|
||||||
Title = title;
|
Title = title;
|
||||||
Aliases = aliases;
|
Aliases = aliases;
|
||||||
@ -146,38 +140,38 @@ namespace Kyoo.Models
|
|||||||
|
|
||||||
public Show SetGenres(ILibraryManager manager)
|
public Show SetGenres(ILibraryManager manager)
|
||||||
{
|
{
|
||||||
Genres = manager.GetGenreForShow(id);
|
Genres = manager.GetGenreForShow(ID);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Show SetStudio(ILibraryManager manager)
|
public Show SetStudio(ILibraryManager manager)
|
||||||
{
|
{
|
||||||
studio = manager.GetStudio(id);
|
Studio = manager.GetStudio(ID);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Show SetDirectors(ILibraryManager manager)
|
public Show SetDirectors(ILibraryManager manager)
|
||||||
{
|
{
|
||||||
directors = manager.GetDirectors(id);
|
Directors = manager.GetDirectors(ID);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Show SetPeople(ILibraryManager manager)
|
public Show SetPeople(ILibraryManager manager)
|
||||||
{
|
{
|
||||||
people = manager.GetPeople(id);
|
People = manager.GetPeople(ID);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Show SetSeasons(ILibraryManager manager)
|
public Show SetSeasons(ILibraryManager manager)
|
||||||
{
|
{
|
||||||
seasons = manager.GetSeasons(id);
|
Seasons = manager.GetSeasons(ID);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Show Merge(Show other)
|
public Show Merge(Show other)
|
||||||
{
|
{
|
||||||
if (id == -1)
|
if (ID == -1)
|
||||||
id = other.id;
|
ID = other.ID;
|
||||||
if (Slug == null)
|
if (Slug == null)
|
||||||
Slug = other.Slug;
|
Slug = other.Slug;
|
||||||
if (Title == null)
|
if (Title == null)
|
||||||
|
@ -4,7 +4,7 @@ namespace Kyoo.Models
|
|||||||
{
|
{
|
||||||
public class Studio
|
public class Studio
|
||||||
{
|
{
|
||||||
[JsonIgnore] public readonly long id;
|
[JsonIgnore] public readonly long ID = -1;
|
||||||
public string Slug;
|
public string Slug;
|
||||||
public string Name;
|
public string Name;
|
||||||
|
|
||||||
@ -16,7 +16,7 @@ namespace Kyoo.Models
|
|||||||
|
|
||||||
public Studio(long id, string slug, string name)
|
public Studio(long id, string slug, string name)
|
||||||
{
|
{
|
||||||
this.id = id;
|
this.ID = id;
|
||||||
Slug = slug;
|
Slug = slug;
|
||||||
Name = name;
|
Name = name;
|
||||||
}
|
}
|
||||||
|
@ -58,7 +58,7 @@ namespace Kyoo.Models
|
|||||||
public string DisplayName;
|
public string DisplayName;
|
||||||
public string Link;
|
public string Link;
|
||||||
|
|
||||||
[JsonIgnore] public long episodeID;
|
[JsonIgnore] public long EpisodeID;
|
||||||
[JsonIgnore] public bool IsExternal;
|
[JsonIgnore] public bool IsExternal;
|
||||||
|
|
||||||
public Track(StreamType type, string title, string language, bool isDefault, bool isForced, string codec, bool isExternal, string path)
|
public Track(StreamType type, string title, string language, bool isDefault, bool isForced, string codec, bool isExternal, string path)
|
||||||
|
@ -7,33 +7,33 @@ namespace Kyoo.Models
|
|||||||
{
|
{
|
||||||
public class WatchItem
|
public class WatchItem
|
||||||
{
|
{
|
||||||
[JsonIgnore] public readonly long episodeID;
|
[JsonIgnore] public readonly long EpisodeID = -1;
|
||||||
|
|
||||||
public string ShowTitle;
|
public string ShowTitle;
|
||||||
public string ShowSlug;
|
public string ShowSlug;
|
||||||
public long seasonNumber;
|
public long SeasonNumber;
|
||||||
public long episodeNumber;
|
public long EpisodeNumber;
|
||||||
public string Title;
|
public string Title;
|
||||||
public string Link;
|
public string Link;
|
||||||
public DateTime? ReleaseDate;
|
public DateTime? ReleaseDate;
|
||||||
[JsonIgnore] public string Path;
|
[JsonIgnore] public string Path;
|
||||||
public string previousEpisode;
|
public string PreviousEpisode;
|
||||||
public Episode nextEpisode;
|
public Episode NextEpisode;
|
||||||
|
|
||||||
public string container;
|
public string Container;
|
||||||
public Track video;
|
public Track Video;
|
||||||
public IEnumerable<Track> audios;
|
public IEnumerable<Track> Audios;
|
||||||
public IEnumerable<Track> subtitles;
|
public IEnumerable<Track> Subtitles;
|
||||||
|
|
||||||
public WatchItem() { }
|
public WatchItem() { }
|
||||||
|
|
||||||
public WatchItem(long episodeID, string showTitle, string showSlug, long seasonNumber, long episodeNumber, string title, DateTime? releaseDate, string path)
|
public WatchItem(long episodeID, string showTitle, string showSlug, long seasonNumber, long episodeNumber, string title, DateTime? releaseDate, string path)
|
||||||
{
|
{
|
||||||
this.episodeID = episodeID;
|
EpisodeID = episodeID;
|
||||||
ShowTitle = showTitle;
|
ShowTitle = showTitle;
|
||||||
ShowSlug = showSlug;
|
ShowSlug = showSlug;
|
||||||
this.seasonNumber = seasonNumber;
|
SeasonNumber = seasonNumber;
|
||||||
this.episodeNumber = episodeNumber;
|
EpisodeNumber = episodeNumber;
|
||||||
Title = title;
|
Title = title;
|
||||||
ReleaseDate = releaseDate;
|
ReleaseDate = releaseDate;
|
||||||
Path = path;
|
Path = path;
|
||||||
@ -43,8 +43,8 @@ namespace Kyoo.Models
|
|||||||
|
|
||||||
public WatchItem(long episodeID, string showTitle, string showSlug, long seasonNumber, long episodeNumber, string title, DateTime? releaseDate, string path, Track[] audios, Track[] subtitles) : this(episodeID, showTitle, showSlug, seasonNumber, episodeNumber, title, releaseDate, path)
|
public WatchItem(long episodeID, string showTitle, string showSlug, long seasonNumber, long episodeNumber, string title, DateTime? releaseDate, string path, Track[] audios, Track[] subtitles) : this(episodeID, showTitle, showSlug, seasonNumber, episodeNumber, title, releaseDate, path)
|
||||||
{
|
{
|
||||||
this.audios = audios;
|
Audios = audios;
|
||||||
this.subtitles = subtitles;
|
Subtitles = subtitles;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static WatchItem FromReader(System.Data.SQLite.SQLiteDataReader reader)
|
public static WatchItem FromReader(System.Data.SQLite.SQLiteDataReader reader)
|
||||||
@ -61,35 +61,35 @@ namespace Kyoo.Models
|
|||||||
|
|
||||||
public WatchItem SetStreams(ILibraryManager libraryManager)
|
public WatchItem SetStreams(ILibraryManager libraryManager)
|
||||||
{
|
{
|
||||||
(Track video, IEnumerable<Track> audios, IEnumerable<Track> subtitles) streams = libraryManager.GetStreams(episodeID, Link);
|
(Track video, IEnumerable<Track> audios, IEnumerable<Track> subtitles) streams = libraryManager.GetStreams(EpisodeID, Link);
|
||||||
|
|
||||||
container = Path.Substring(Path.LastIndexOf('.') + 1);
|
Container = Path.Substring(Path.LastIndexOf('.') + 1);
|
||||||
video = streams.video;
|
Video = streams.video;
|
||||||
audios = streams.audios;
|
Audios = streams.audios;
|
||||||
subtitles = streams.subtitles;
|
Subtitles = streams.subtitles;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public WatchItem SetPrevious(ILibraryManager libraryManager)
|
public WatchItem SetPrevious(ILibraryManager libraryManager)
|
||||||
{
|
{
|
||||||
long lastEp = episodeNumber - 1;
|
long lastEp = EpisodeNumber - 1;
|
||||||
if(lastEp > 0)
|
if(lastEp > 0)
|
||||||
previousEpisode = ShowSlug + "-s" + seasonNumber + "e" + lastEp;
|
PreviousEpisode = ShowSlug + "-s" + SeasonNumber + "e" + lastEp;
|
||||||
else if(seasonNumber > 1)
|
else if(SeasonNumber > 1)
|
||||||
{
|
{
|
||||||
int seasonCount = libraryManager.GetSeasonCount(ShowSlug, seasonNumber - 1);
|
int seasonCount = libraryManager.GetSeasonCount(ShowSlug, SeasonNumber - 1);
|
||||||
previousEpisode = ShowSlug + "-s" + (seasonNumber - 1) + "e" + seasonCount;
|
PreviousEpisode = ShowSlug + "-s" + (SeasonNumber - 1) + "e" + seasonCount;
|
||||||
}
|
}
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public WatchItem SetNext(ILibraryManager libraryManager)
|
public WatchItem SetNext(ILibraryManager libraryManager)
|
||||||
{
|
{
|
||||||
long seasonCount = libraryManager.GetSeasonCount(ShowSlug, seasonNumber);
|
long seasonCount = libraryManager.GetSeasonCount(ShowSlug, SeasonNumber);
|
||||||
if (episodeNumber >= seasonCount)
|
if (EpisodeNumber >= seasonCount)
|
||||||
nextEpisode = libraryManager.GetEpisode(ShowSlug, seasonNumber + 1, 1);
|
NextEpisode = libraryManager.GetEpisode(ShowSlug, SeasonNumber + 1, 1);
|
||||||
else
|
else
|
||||||
nextEpisode = libraryManager.GetEpisode(ShowSlug, seasonNumber, episodeNumber + 1);
|
NextEpisode = libraryManager.GetEpisode(ShowSlug, SeasonNumber, EpisodeNumber + 1);
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
using Kyoo.Models;
|
using System;
|
||||||
|
using Kyoo.Models;
|
||||||
using Microsoft.Extensions.Configuration;
|
using Microsoft.Extensions.Configuration;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
@ -67,25 +68,25 @@ namespace Kyoo.Controllers
|
|||||||
|
|
||||||
private async Task Scan(Library library, CancellationToken cancellationToken)
|
private async Task Scan(Library library, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
IEnumerable<string> files = new List<string>();
|
Console.WriteLine($"Scanning library {library.Name} at {string.Concat(library.Paths)}");
|
||||||
|
foreach (string path in library.Paths)
|
||||||
files = library.Paths.Aggregate(files, (current, path) =>
|
|
||||||
current.Concat(Directory.GetFiles(path, "*", SearchOption.AllDirectories)));
|
|
||||||
foreach (string file in files)
|
|
||||||
{
|
{
|
||||||
if (cancellationToken.IsCancellationRequested)
|
foreach (string file in Directory.GetFiles(path, "*", SearchOption.AllDirectories))
|
||||||
return;
|
{
|
||||||
if (!IsVideo(file))
|
if (cancellationToken.IsCancellationRequested)
|
||||||
continue;
|
return;
|
||||||
await RegisterFile(file, library);
|
if (!IsVideo(file))
|
||||||
|
continue;
|
||||||
|
string relativePath = file.Substring(path.Length);
|
||||||
|
await RegisterFile(file, relativePath, library);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task RegisterFile(string path, Library library)
|
private async Task RegisterFile(string path, string relativePath, Library library)
|
||||||
{
|
{
|
||||||
if (!libraryManager.IsEpisodeRegistered(path))
|
if (!libraryManager.IsEpisodeRegistered(path))
|
||||||
{
|
{
|
||||||
string relativePath = path.Substring(library.Paths.Length);
|
|
||||||
string patern = config.GetValue<string>("regex");
|
string patern = config.GetValue<string>("regex");
|
||||||
Regex regex = new Regex(patern, RegexOptions.IgnoreCase);
|
Regex regex = new Regex(patern, RegexOptions.IgnoreCase);
|
||||||
Match match = regex.Match(relativePath);
|
Match match = regex.Match(relativePath);
|
||||||
@ -97,7 +98,7 @@ namespace Kyoo.Controllers
|
|||||||
bool episodeSucess = long.TryParse(match.Groups["Episode"].Value, out long episodeNumber);
|
bool episodeSucess = long.TryParse(match.Groups["Episode"].Value, out long episodeNumber);
|
||||||
long absoluteNumber = -1;
|
long absoluteNumber = -1;
|
||||||
|
|
||||||
Debug.WriteLine("&Registering episode at: " + path);
|
Console.WriteLine("&Registering episode at: " + path);
|
||||||
if (!seasonSuccess || !episodeSucess)
|
if (!seasonSuccess || !episodeSucess)
|
||||||
{
|
{
|
||||||
//Considering that the episode is using absolute path.
|
//Considering that the episode is using absolute path.
|
||||||
@ -112,7 +113,7 @@ namespace Kyoo.Controllers
|
|||||||
|
|
||||||
if (!absoluteSucess)
|
if (!absoluteSucess)
|
||||||
{
|
{
|
||||||
Debug.WriteLine("&Couldn't find basic data for the episode (regexs didn't match)" + relativePath);
|
Console.WriteLine("&Couldn't find basic data for the episode (regexs didn't match) " + relativePath);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -120,6 +121,8 @@ namespace Kyoo.Controllers
|
|||||||
Show show = await RegisterOrGetShow(collectionName, showName, showPath, library);
|
Show show = await RegisterOrGetShow(collectionName, showName, showPath, library);
|
||||||
if (show != null)
|
if (show != null)
|
||||||
await RegisterEpisode(show, seasonNumber, episodeNumber, absoluteNumber, path, library);
|
await RegisterEpisode(show, seasonNumber, episodeNumber, absoluteNumber, path, library);
|
||||||
|
else
|
||||||
|
Console.Error.WriteLine($"Coudld not get informations about the show ${showName}.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -131,6 +134,8 @@ namespace Kyoo.Controllers
|
|||||||
{
|
{
|
||||||
Show show = await metadataProvider.GetShowFromName(showTitle, library);
|
Show show = await metadataProvider.GetShowFromName(showTitle, library);
|
||||||
show.Path = showPath;
|
show.Path = showPath;
|
||||||
|
show.Title = show.Title ?? showTitle;
|
||||||
|
show.Slug = show.Slug ?? Utility.ToSlug(showTitle);
|
||||||
showProviderIDs = show.ExternalIDs;
|
showProviderIDs = show.ExternalIDs;
|
||||||
showID = libraryManager.RegisterShow(show);
|
showID = libraryManager.RegisterShow(show);
|
||||||
|
|
||||||
@ -143,6 +148,7 @@ namespace Kyoo.Controllers
|
|||||||
if (!libraryManager.IsCollectionRegistered(Utility.ToSlug(collectionName), out long collectionID))
|
if (!libraryManager.IsCollectionRegistered(Utility.ToSlug(collectionName), out long collectionID))
|
||||||
{
|
{
|
||||||
Collection collection = await metadataProvider.GetCollectionFromName(collectionName, library);
|
Collection collection = await metadataProvider.GetCollectionFromName(collectionName, library);
|
||||||
|
collection.Name = collection.Name ?? collectionName;
|
||||||
collectionID = libraryManager.RegisterCollection(collection);
|
collectionID = libraryManager.RegisterCollection(collection);
|
||||||
}
|
}
|
||||||
libraryManager.AddShowToCollection(showID, collectionID);
|
libraryManager.AddShowToCollection(showID, collectionID);
|
||||||
@ -154,38 +160,40 @@ namespace Kyoo.Controllers
|
|||||||
else
|
else
|
||||||
showProviderIDs = libraryManager.GetShowExternalIDs(showID);
|
showProviderIDs = libraryManager.GetShowExternalIDs(showID);
|
||||||
|
|
||||||
return new Show { id = showID, ExternalIDs = showProviderIDs, Title = showTitle };
|
return new Show { ID = showID, ExternalIDs = showProviderIDs, Title = showTitle };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private async Task<long> RegisterSeason(Show show, long seasonNumber, Library library)
|
||||||
|
{
|
||||||
|
if (!libraryManager.IsSeasonRegistered(show.ID, seasonNumber, out long seasonID))
|
||||||
|
{
|
||||||
|
Season season = await metadataProvider.GetSeason(show, seasonNumber, library);
|
||||||
|
season.ShowID = show.ID;
|
||||||
|
season.SeasonNumber = season.SeasonNumber == -1 ? seasonNumber : season.SeasonNumber;
|
||||||
|
season.Title ??= $"Season {season.SeasonNumber}";
|
||||||
|
seasonID = libraryManager.RegisterSeason(season);
|
||||||
|
}
|
||||||
|
|
||||||
|
return seasonID;
|
||||||
|
}
|
||||||
|
|
||||||
private async Task RegisterEpisode(Show show, long seasonNumber, long episodeNumber, long absoluteNumber, string episodePath, Library library)
|
private async Task RegisterEpisode(Show show, long seasonNumber, long episodeNumber, long absoluteNumber, string episodePath, Library library)
|
||||||
{
|
{
|
||||||
long seasonID = -1;
|
long seasonID = -1;
|
||||||
if (seasonNumber != -1)
|
if (seasonNumber != -1)
|
||||||
{
|
seasonID = await RegisterSeason(show, seasonNumber, library);
|
||||||
if (!libraryManager.IsSeasonRegistered(show.id, seasonNumber, out seasonID))
|
|
||||||
{
|
|
||||||
Season season = await metadataProvider.GetSeason(show.Title, seasonNumber, library);
|
|
||||||
season.ShowID = show.id;
|
|
||||||
seasonID = libraryManager.RegisterSeason(season);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Episode episode = await metadataProvider.GetEpisode(show, seasonNumber, episodeNumber, absoluteNumber, library);
|
Episode episode = await metadataProvider.GetEpisode(show, seasonNumber, episodeNumber, absoluteNumber, library);
|
||||||
episode.ShowID = show.id;
|
episode.ShowID = show.ID;
|
||||||
episode.Path = episodePath;
|
episode.Path = episodePath;
|
||||||
|
episode.SeasonNumber = episode.SeasonNumber != -1 ? episode.SeasonNumber : seasonNumber;
|
||||||
|
episode.EpisodeNumber = episode.EpisodeNumber != -1 ? episode.EpisodeNumber : episodeNumber;
|
||||||
|
episode.AbsoluteNumber = episode.AbsoluteNumber != -1 ? episode.AbsoluteNumber : absoluteNumber;
|
||||||
|
|
||||||
if (seasonID == -1)
|
if (seasonID == -1)
|
||||||
{
|
seasonID = await RegisterSeason(show, seasonNumber, library);
|
||||||
if (!libraryManager.IsSeasonRegistered(show.id, episode.seasonNumber, out seasonID))
|
|
||||||
{
|
|
||||||
Season season = await metadataProvider.GetSeason(show.Title, episode.seasonNumber, library);
|
|
||||||
season.ShowID = show.id;
|
|
||||||
seasonID = libraryManager.RegisterSeason(season);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
episode.SeasonID = seasonID;
|
episode.SeasonID = seasonID;
|
||||||
episode.id = libraryManager.RegisterEpisode(episode);
|
episode.ID = libraryManager.RegisterEpisode(episode);
|
||||||
|
|
||||||
Track[] tracks = await transcoder.GetTrackInfo(episode.Path);
|
Track[] tracks = await transcoder.GetTrackInfo(episode.Path);
|
||||||
int subcount = 0;
|
int subcount = 0;
|
||||||
@ -196,7 +204,7 @@ namespace Kyoo.Controllers
|
|||||||
subcount++;
|
subcount++;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
track.episodeID = episode.id;
|
track.EpisodeID = episode.ID;
|
||||||
libraryManager.RegisterTrack(track);
|
libraryManager.RegisterTrack(track);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -207,7 +215,7 @@ namespace Kyoo.Controllers
|
|||||||
{
|
{
|
||||||
foreach (Track track in subtitles)
|
foreach (Track track in subtitles)
|
||||||
{
|
{
|
||||||
track.episodeID = episode.id;
|
track.EpisodeID = episode.ID;
|
||||||
libraryManager.RegisterTrack(track);
|
libraryManager.RegisterTrack(track);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -225,22 +233,21 @@ namespace Kyoo.Controllers
|
|||||||
{
|
{
|
||||||
string episodeLink = Path.GetFileNameWithoutExtension(episode.Path);
|
string episodeLink = Path.GetFileNameWithoutExtension(episode.Path);
|
||||||
|
|
||||||
if (sub.Contains(episodeLink))
|
if (!sub.Contains(episodeLink))
|
||||||
{
|
continue;
|
||||||
string language = sub.Substring(Path.GetDirectoryName(sub).Length + episodeLink.Length + 2, 3);
|
string language = sub.Substring(Path.GetDirectoryName(sub).Length + episodeLink.Length + 2, 3);
|
||||||
bool isDefault = sub.Contains("default");
|
bool isDefault = sub.Contains("default");
|
||||||
bool isForced = sub.Contains("forced");
|
bool isForced = sub.Contains("forced");
|
||||||
Track track = new Track(StreamType.Subtitle, null, language, isDefault, isForced, null, false, sub) { episodeID = episode.id };
|
Track track = new Track(StreamType.Subtitle, null, language, isDefault, isForced, null, false, sub) { EpisodeID = episode.ID };
|
||||||
|
|
||||||
if (Path.GetExtension(sub) == ".ass")
|
if (Path.GetExtension(sub) == ".ass")
|
||||||
track.Codec = "ass";
|
track.Codec = "ass";
|
||||||
else if (Path.GetExtension(sub) == ".srt")
|
else if (Path.GetExtension(sub) == ".srt")
|
||||||
track.Codec = "subrip";
|
track.Codec = "subrip";
|
||||||
else
|
else
|
||||||
track.Codec = null;
|
track.Codec = null;
|
||||||
libraryManager.RegisterTrack(track);
|
libraryManager.RegisterTrack(track);
|
||||||
subcount++;
|
subcount++;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return subcount;
|
return subcount;
|
||||||
}
|
}
|
||||||
|
@ -837,7 +837,7 @@ namespace Kyoo.Controllers
|
|||||||
Genre existingGenre = GetGenreBySlug(genre.Slug);
|
Genre existingGenre = GetGenreBySlug(genre.Slug);
|
||||||
|
|
||||||
if (existingGenre != null)
|
if (existingGenre != null)
|
||||||
return existingGenre.id;
|
return existingGenre.ID;
|
||||||
|
|
||||||
string query = "INSERT INTO genres (slug, name) VALUES($slug, $name);";
|
string query = "INSERT INTO genres (slug, name) VALUES($slug, $name);";
|
||||||
using (SQLiteCommand cmd = new SQLiteCommand(query, sqlConnection))
|
using (SQLiteCommand cmd = new SQLiteCommand(query, sqlConnection))
|
||||||
@ -866,7 +866,7 @@ namespace Kyoo.Controllers
|
|||||||
Studio existingStudio = GetStudioBySlug(studio.Slug);
|
Studio existingStudio = GetStudioBySlug(studio.Slug);
|
||||||
|
|
||||||
if (existingStudio != null)
|
if (existingStudio != null)
|
||||||
return existingStudio.id;
|
return existingStudio.ID;
|
||||||
|
|
||||||
string query = "INSERT INTO studios (slug, name) VALUES($slug, $name);";
|
string query = "INSERT INTO studios (slug, name) VALUES($slug, $name);";
|
||||||
using (SQLiteCommand cmd = new SQLiteCommand(query, sqlConnection))
|
using (SQLiteCommand cmd = new SQLiteCommand(query, sqlConnection))
|
||||||
@ -892,20 +892,20 @@ namespace Kyoo.Controllers
|
|||||||
|
|
||||||
public long GetOrCreatePeople(People people)
|
public long GetOrCreatePeople(People people)
|
||||||
{
|
{
|
||||||
People existingPeople = GetPeopleBySlug(people.slug);
|
People existingPeople = GetPeopleBySlug(people.Slug);
|
||||||
|
|
||||||
if (existingPeople != null)
|
if (existingPeople != null)
|
||||||
return existingPeople.id;
|
return existingPeople.ID;
|
||||||
|
|
||||||
string query = "INSERT INTO people (slug, name, imgPrimary, externalIDs) VALUES($slug, $name, $imgPrimary, $externalIDs);";
|
string query = "INSERT INTO people (slug, name, imgPrimary, externalIDs) VALUES($slug, $name, $imgPrimary, $externalIDs);";
|
||||||
using (SQLiteCommand cmd = new SQLiteCommand(query, sqlConnection))
|
using (SQLiteCommand cmd = new SQLiteCommand(query, sqlConnection))
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
cmd.Parameters.AddWithValue("$slug", people.slug);
|
cmd.Parameters.AddWithValue("$slug", people.Slug);
|
||||||
cmd.Parameters.AddWithValue("$name", people.Name);
|
cmd.Parameters.AddWithValue("$name", people.Name);
|
||||||
cmd.Parameters.AddWithValue("$imgPrimary", people.imgPrimary);
|
cmd.Parameters.AddWithValue("$imgPrimary", people.ImgPrimary);
|
||||||
cmd.Parameters.AddWithValue("$externalIDs", people.externalIDs);
|
cmd.Parameters.AddWithValue("$externalIDs", people.ExternalIDs);
|
||||||
cmd.ExecuteNonQuery();
|
cmd.ExecuteNonQuery();
|
||||||
|
|
||||||
cmd.CommandText = "SELECT LAST_INSERT_ROWID()";
|
cmd.CommandText = "SELECT LAST_INSERT_ROWID()";
|
||||||
@ -915,7 +915,7 @@ namespace Kyoo.Controllers
|
|||||||
{
|
{
|
||||||
Console.Error.WriteLine("SQL error while trying to insert a people ({0}).", people.Name);
|
Console.Error.WriteLine("SQL error while trying to insert a people ({0}).", people.Name);
|
||||||
cmd.CommandText = "SELECT * FROM people WHERE slug = $slug";
|
cmd.CommandText = "SELECT * FROM people WHERE slug = $slug";
|
||||||
cmd.Parameters.AddWithValue("$slug", people.slug);
|
cmd.Parameters.AddWithValue("$slug", people.Slug);
|
||||||
return (long)cmd.ExecuteScalar();
|
return (long)cmd.ExecuteScalar();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -958,7 +958,7 @@ namespace Kyoo.Controllers
|
|||||||
|
|
||||||
using (SQLiteCommand cmd = new SQLiteCommand(query, sqlConnection))
|
using (SQLiteCommand cmd = new SQLiteCommand(query, sqlConnection))
|
||||||
{
|
{
|
||||||
cmd.Parameters.AddWithValue("$libraryID", library.id);
|
cmd.Parameters.AddWithValue("$libraryID", library.ID);
|
||||||
cmd.Parameters.AddWithValue("$showID", showID);
|
cmd.Parameters.AddWithValue("$showID", showID);
|
||||||
cmd.ExecuteNonQuery();
|
cmd.ExecuteNonQuery();
|
||||||
}
|
}
|
||||||
@ -1002,10 +1002,10 @@ namespace Kyoo.Controllers
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (show.studio != null)
|
if (show.Studio != null)
|
||||||
{
|
{
|
||||||
cmd.CommandText = "INSERT INTO studiosLinks (studioID, showID) VALUES($studioID, $showID);";
|
cmd.CommandText = "INSERT INTO studiosLinks (studioID, showID) VALUES($studioID, $showID);";
|
||||||
long studioID = GetOrCreateStudio(show.studio);
|
long studioID = GetOrCreateStudio(show.Studio);
|
||||||
cmd.Parameters.AddWithValue("$studioID", studioID);
|
cmd.Parameters.AddWithValue("$studioID", studioID);
|
||||||
cmd.Parameters.AddWithValue("$showID", showID);
|
cmd.Parameters.AddWithValue("$showID", showID);
|
||||||
cmd.ExecuteNonQuery();
|
cmd.ExecuteNonQuery();
|
||||||
@ -1029,10 +1029,10 @@ namespace Kyoo.Controllers
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
cmd.Parameters.AddWithValue("$showID", season.ShowID);
|
cmd.Parameters.AddWithValue("$showID", season.ShowID);
|
||||||
cmd.Parameters.AddWithValue("$seasonNumber", season.seasonNumber);
|
cmd.Parameters.AddWithValue("$seasonNumber", season.SeasonNumber);
|
||||||
cmd.Parameters.AddWithValue("$title", season.Title);
|
cmd.Parameters.AddWithValue("$title", season.Title);
|
||||||
cmd.Parameters.AddWithValue("$overview", season.Overview);
|
cmd.Parameters.AddWithValue("$overview", season.Overview);
|
||||||
cmd.Parameters.AddWithValue("$year", season.year);
|
cmd.Parameters.AddWithValue("$year", season.Year);
|
||||||
cmd.Parameters.AddWithValue("$imgPrimary", season.ImgPrimary);
|
cmd.Parameters.AddWithValue("$imgPrimary", season.ImgPrimary);
|
||||||
cmd.Parameters.AddWithValue("$externalIDs", season.ExternalIDs);
|
cmd.Parameters.AddWithValue("$externalIDs", season.ExternalIDs);
|
||||||
cmd.ExecuteNonQuery();
|
cmd.ExecuteNonQuery();
|
||||||
@ -1045,7 +1045,7 @@ namespace Kyoo.Controllers
|
|||||||
Console.Error.WriteLine("SQL error while trying to insert a season ({0}), season probably already registered.", season.Title);
|
Console.Error.WriteLine("SQL error while trying to insert a season ({0}), season probably already registered.", season.Title);
|
||||||
cmd.CommandText = "SELECT * FROM seasons WHERE showID = $showID AND seasonNumber = $seasonNumber";
|
cmd.CommandText = "SELECT * FROM seasons WHERE showID = $showID AND seasonNumber = $seasonNumber";
|
||||||
cmd.Parameters.AddWithValue("$showID", season.ShowID);
|
cmd.Parameters.AddWithValue("$showID", season.ShowID);
|
||||||
cmd.Parameters.AddWithValue("$seasonNumber", season.seasonNumber);
|
cmd.Parameters.AddWithValue("$seasonNumber", season.SeasonNumber);
|
||||||
return (long)cmd.ExecuteScalar();
|
return (long)cmd.ExecuteScalar();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1060,9 +1060,9 @@ namespace Kyoo.Controllers
|
|||||||
{
|
{
|
||||||
cmd.Parameters.AddWithValue("$showID", episode.ShowID);
|
cmd.Parameters.AddWithValue("$showID", episode.ShowID);
|
||||||
cmd.Parameters.AddWithValue("$seasonID", episode.SeasonID);
|
cmd.Parameters.AddWithValue("$seasonID", episode.SeasonID);
|
||||||
cmd.Parameters.AddWithValue("$seasonNUmber", episode.seasonNumber);
|
cmd.Parameters.AddWithValue("$seasonNUmber", episode.SeasonNumber);
|
||||||
cmd.Parameters.AddWithValue("$episodeNumber", episode.episodeNumber);
|
cmd.Parameters.AddWithValue("$episodeNumber", episode.EpisodeNumber);
|
||||||
cmd.Parameters.AddWithValue("$absoluteNumber", episode.absoluteNumber);
|
cmd.Parameters.AddWithValue("$absoluteNumber", episode.AbsoluteNumber);
|
||||||
cmd.Parameters.AddWithValue("$path", episode.Path);
|
cmd.Parameters.AddWithValue("$path", episode.Path);
|
||||||
cmd.Parameters.AddWithValue("$title", episode.Title);
|
cmd.Parameters.AddWithValue("$title", episode.Title);
|
||||||
cmd.Parameters.AddWithValue("$overview", episode.Overview);
|
cmd.Parameters.AddWithValue("$overview", episode.Overview);
|
||||||
@ -1080,8 +1080,8 @@ namespace Kyoo.Controllers
|
|||||||
Console.Error.WriteLine("SQL error while trying to insert an episode ({0}), episode probably already registered.", episode.Link);
|
Console.Error.WriteLine("SQL error while trying to insert an episode ({0}), episode probably already registered.", episode.Link);
|
||||||
cmd.CommandText = "SELECT * FROM episodes WHERE showID = $showID AND seasonNumber = $seasonNumber AND episodeNumber = $episodeNumber";
|
cmd.CommandText = "SELECT * FROM episodes WHERE showID = $showID AND seasonNumber = $seasonNumber AND episodeNumber = $episodeNumber";
|
||||||
cmd.Parameters.AddWithValue("$showID", episode.ShowID);
|
cmd.Parameters.AddWithValue("$showID", episode.ShowID);
|
||||||
cmd.Parameters.AddWithValue("$seasonNumber", episode.seasonNumber);
|
cmd.Parameters.AddWithValue("$seasonNumber", episode.SeasonNumber);
|
||||||
cmd.Parameters.AddWithValue("$episodeNumber", episode.episodeNumber);
|
cmd.Parameters.AddWithValue("$episodeNumber", episode.EpisodeNumber);
|
||||||
return (long)cmd.ExecuteScalar();
|
return (long)cmd.ExecuteScalar();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1092,7 +1092,7 @@ namespace Kyoo.Controllers
|
|||||||
string query = "INSERT INTO tracks (episodeID, streamType, title, language, codec, isDefault, isForced, isExternal, path) VALUES($episodeID, $streamType, $title, $language, $codec, $isDefault, $isForced, $isExternal, $path);";
|
string query = "INSERT INTO tracks (episodeID, streamType, title, language, codec, isDefault, isForced, isExternal, path) VALUES($episodeID, $streamType, $title, $language, $codec, $isDefault, $isForced, $isExternal, $path);";
|
||||||
using (SQLiteCommand cmd = new SQLiteCommand(query, sqlConnection))
|
using (SQLiteCommand cmd = new SQLiteCommand(query, sqlConnection))
|
||||||
{
|
{
|
||||||
cmd.Parameters.AddWithValue("$episodeID", track.episodeID);
|
cmd.Parameters.AddWithValue("$episodeID", track.EpisodeID);
|
||||||
cmd.Parameters.AddWithValue("$streamType", track.Type);
|
cmd.Parameters.AddWithValue("$streamType", track.Type);
|
||||||
cmd.Parameters.AddWithValue("$title", track.Title);
|
cmd.Parameters.AddWithValue("$title", track.Title);
|
||||||
cmd.Parameters.AddWithValue("$language", track.Language);
|
cmd.Parameters.AddWithValue("$language", track.Language);
|
||||||
@ -1167,11 +1167,11 @@ namespace Kyoo.Controllers
|
|||||||
|
|
||||||
using (SQLiteCommand cmd = new SQLiteCommand(query, sqlConnection))
|
using (SQLiteCommand cmd = new SQLiteCommand(query, sqlConnection))
|
||||||
{
|
{
|
||||||
cmd.Parameters.AddWithValue("$episodeID", episode.id);
|
cmd.Parameters.AddWithValue("$episodeID", episode.ID);
|
||||||
cmd.ExecuteNonQuery();
|
cmd.ExecuteNonQuery();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (GetEpisodes(episode.ShowID, episode.seasonNumber).Count == 0)
|
if (GetEpisodes(episode.ShowID, episode.SeasonNumber).Count == 0)
|
||||||
RemoveSeason(episode.ShowID, episode.SeasonID);
|
RemoveSeason(episode.ShowID, episode.SeasonID);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -43,11 +43,19 @@ namespace Kyoo.Controllers
|
|||||||
|
|
||||||
plugins = pluginsPaths.Select(path =>
|
plugins = pluginsPaths.Select(path =>
|
||||||
{
|
{
|
||||||
Assembly ass = Assembly.LoadFile(path);
|
try
|
||||||
return (from type in ass.GetTypes()
|
{
|
||||||
where typeof(IPlugin).IsAssignableFrom(type)
|
Assembly ass = Assembly.LoadFile(Path.GetFullPath(path));
|
||||||
select (IPlugin)ActivatorUtilities.CreateInstance(provider, type, null)).FirstOrDefault();
|
return (from type in ass.GetTypes()
|
||||||
}).Where(x => x != null).ToList();
|
where typeof(IPlugin).IsAssignableFrom(type)
|
||||||
|
select (IPlugin) ActivatorUtilities.CreateInstance(provider, type)).FirstOrDefault();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Console.Error.WriteLine($"Error loading the plugin at ${path}.\nException: {ex.Message}");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}).Where(x => x != null).ToList();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -64,9 +64,9 @@ namespace Kyoo.Controllers
|
|||||||
return show;
|
return show;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<Season> GetSeason(string showName, long seasonNumber, Library library)
|
public async Task<Season> GetSeason(Show show, long seasonNumber, Library library)
|
||||||
{
|
{
|
||||||
return await GetMetadata(provider => provider.GetSeason(showName, seasonNumber), library, $"the season ${seasonNumber} of {showName}");
|
return await GetMetadata(provider => provider.GetSeason(show, seasonNumber), library, $"the season ${seasonNumber} of {show.Title}");
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<Episode> GetEpisode(Show show, long seasonNumber, long episodeNumber, long absoluteNumber, Library library)
|
public async Task<Episode> GetEpisode(Show show, long seasonNumber, long episodeNumber, long absoluteNumber, Library library)
|
||||||
|
@ -20,6 +20,8 @@ namespace Kyoo.Controllers.ThumbnailsManager
|
|||||||
|
|
||||||
public async Task<Show> Validate(Show show)
|
public async Task<Show> Validate(Show show)
|
||||||
{
|
{
|
||||||
|
if (show == null || show.Path == null)
|
||||||
|
return null;
|
||||||
string localThumb = Path.Combine(show.Path, "poster.jpg");
|
string localThumb = Path.Combine(show.Path, "poster.jpg");
|
||||||
string localLogo = Path.Combine(show.Path, "logo.png");
|
string localLogo = Path.Combine(show.Path, "logo.png");
|
||||||
string localBackdrop = Path.Combine(show.Path, "backdrop.jpg");
|
string localBackdrop = Path.Combine(show.Path, "backdrop.jpg");
|
||||||
@ -69,23 +71,24 @@ namespace Kyoo.Controllers.ThumbnailsManager
|
|||||||
|
|
||||||
public async Task<IEnumerable<People>> Validate(IEnumerable<People> people)
|
public async Task<IEnumerable<People>> Validate(IEnumerable<People> people)
|
||||||
{
|
{
|
||||||
|
if (people == null)
|
||||||
|
return null;
|
||||||
foreach (People peop in people)
|
foreach (People peop in people)
|
||||||
{
|
{
|
||||||
string root = config.GetValue<string>("peoplePath");
|
string root = config.GetValue<string>("peoplePath");
|
||||||
Directory.CreateDirectory(root);
|
Directory.CreateDirectory(root);
|
||||||
|
|
||||||
string localThumb = root + "/" + peop.slug + ".jpg";
|
string localThumb = root + "/" + peop.Slug + ".jpg";
|
||||||
if (peop.imgPrimary != null && !File.Exists(localThumb))
|
if (peop.ImgPrimary == null || File.Exists(localThumb))
|
||||||
|
continue;
|
||||||
|
try
|
||||||
{
|
{
|
||||||
try
|
using WebClient client = new WebClient();
|
||||||
{
|
await client.DownloadFileTaskAsync(new Uri(peop.ImgPrimary), localThumb);
|
||||||
using WebClient client = new WebClient();
|
}
|
||||||
await client.DownloadFileTaskAsync(new Uri(peop.imgPrimary), localThumb);
|
catch (WebException)
|
||||||
}
|
{
|
||||||
catch (WebException)
|
Console.Error.WriteLine("Couldn't download an image.");
|
||||||
{
|
|
||||||
Console.Error.WriteLine("Couldn't download an image.");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -94,18 +97,19 @@ namespace Kyoo.Controllers.ThumbnailsManager
|
|||||||
|
|
||||||
public async Task<Episode> Validate(Episode episode)
|
public async Task<Episode> Validate(Episode episode)
|
||||||
{
|
{
|
||||||
string localThumb = Path.ChangeExtension(episode.Path, "jpg");
|
if (episode == null || episode.Path == null)
|
||||||
if (episode.ImgPrimary != null && !File.Exists(localThumb))
|
return null;
|
||||||
|
string localThumb = Path.ChangeExtension(episode.Path, "jpg");
|
||||||
|
if (episode.ImgPrimary == null || File.Exists(localThumb))
|
||||||
|
return episode;
|
||||||
|
try
|
||||||
{
|
{
|
||||||
try
|
using WebClient client = new WebClient();
|
||||||
{
|
await client.DownloadFileTaskAsync(new Uri(episode.ImgPrimary), localThumb);
|
||||||
using WebClient client = new WebClient();
|
}
|
||||||
await client.DownloadFileTaskAsync(new Uri(episode.ImgPrimary), localThumb);
|
catch (WebException)
|
||||||
}
|
{
|
||||||
catch (WebException)
|
Console.Error.WriteLine("Couldn't download an image.");
|
||||||
{
|
|
||||||
Console.Error.WriteLine("Couldn't download an image.");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return episode;
|
return episode;
|
||||||
|
@ -30,7 +30,7 @@ namespace Kyoo.Controllers
|
|||||||
if (library == null)
|
if (library == null)
|
||||||
return NotFound();
|
return NotFound();
|
||||||
|
|
||||||
return libraryManager.GetShowsInLibrary(library.id);
|
return libraryManager.GetShowsInLibrary(library.ID);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -23,10 +23,10 @@ namespace Kyoo.Controllers
|
|||||||
|
|
||||||
if (people == null)
|
if (people == null)
|
||||||
return NotFound();
|
return NotFound();
|
||||||
Collection collection = new Collection(0, people.slug, people.Name, null, null)
|
Collection collection = new Collection(0, people.Slug, people.Name, null, null)
|
||||||
{
|
{
|
||||||
Shows = libraryManager.GetShowsByPeople(people.id),
|
Shows = libraryManager.GetShowsByPeople(people.ID),
|
||||||
Poster = "peopleimg/" + people.slug
|
Poster = "peopleimg/" + people.Slug
|
||||||
};
|
};
|
||||||
return collection;
|
return collection;
|
||||||
}
|
}
|
||||||
|
@ -20,12 +20,12 @@ namespace Kyoo.Controllers
|
|||||||
{
|
{
|
||||||
SearchResult result = new SearchResult
|
SearchResult result = new SearchResult
|
||||||
{
|
{
|
||||||
query = query,
|
Query = query,
|
||||||
shows = libraryManager.GetShows(query),
|
Shows = libraryManager.GetShows(query),
|
||||||
episodes = libraryManager.SearchEpisodes(query),
|
Episodes = libraryManager.SearchEpisodes(query),
|
||||||
people = libraryManager.SearchPeople(query),
|
People = libraryManager.SearchPeople(query),
|
||||||
genres = libraryManager.SearchGenres(query),
|
Genres = libraryManager.SearchGenres(query),
|
||||||
studios = libraryManager.SearchStudios(query)
|
Studios = libraryManager.SearchStudios(query)
|
||||||
};
|
};
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -50,12 +50,12 @@ namespace Kyoo.Controllers
|
|||||||
public async Task<string> ExtractSubtitle(string showSlug, long seasonNumber, long episodeNumber)
|
public async Task<string> ExtractSubtitle(string showSlug, long seasonNumber, long episodeNumber)
|
||||||
{
|
{
|
||||||
Episode episode = libraryManager.GetEpisode(showSlug, seasonNumber, episodeNumber);
|
Episode episode = libraryManager.GetEpisode(showSlug, seasonNumber, episodeNumber);
|
||||||
libraryManager.ClearSubtitles(episode.id);
|
libraryManager.ClearSubtitles(episode.ID);
|
||||||
|
|
||||||
Track[] tracks = await transcoder.ExtractSubtitles(episode.Path);
|
Track[] tracks = await transcoder.ExtractSubtitles(episode.Path);
|
||||||
foreach (Track track in tracks)
|
foreach (Track track in tracks)
|
||||||
{
|
{
|
||||||
track.episodeID = episode.id;
|
track.EpisodeID = episode.ID;
|
||||||
libraryManager.RegisterTrack(track);
|
libraryManager.RegisterTrack(track);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -68,12 +68,12 @@ namespace Kyoo.Controllers
|
|||||||
List<Episode> episodes = libraryManager.GetEpisodes(showSlug);
|
List<Episode> episodes = libraryManager.GetEpisodes(showSlug);
|
||||||
foreach (Episode episode in episodes)
|
foreach (Episode episode in episodes)
|
||||||
{
|
{
|
||||||
libraryManager.ClearSubtitles(episode.id);
|
libraryManager.ClearSubtitles(episode.ID);
|
||||||
|
|
||||||
Track[] tracks = await transcoder.ExtractSubtitles(episode.Path);
|
Track[] tracks = await transcoder.ExtractSubtitles(episode.Path);
|
||||||
foreach (Track track in tracks)
|
foreach (Track track in tracks)
|
||||||
{
|
{
|
||||||
track.episodeID = episode.id;
|
track.EpisodeID = episode.ID;
|
||||||
libraryManager.RegisterTrack(track);
|
libraryManager.RegisterTrack(track);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -32,12 +32,12 @@ namespace Kyoo
|
|||||||
services.AddControllers().AddNewtonsoftJson();
|
services.AddControllers().AddNewtonsoftJson();
|
||||||
services.AddHttpClient();
|
services.AddHttpClient();
|
||||||
|
|
||||||
services.AddSingleton<IPluginManager, PluginManager>();
|
|
||||||
services.AddSingleton<ILibraryManager, LibraryManager>();
|
services.AddSingleton<ILibraryManager, LibraryManager>();
|
||||||
services.AddSingleton<ITranscoder, Transcoder>();
|
services.AddSingleton<ITranscoder, Transcoder>();
|
||||||
services.AddSingleton<IThumbnailsManager, ThumbnailsManager>();
|
services.AddSingleton<IThumbnailsManager, ThumbnailsManager>();
|
||||||
services.AddSingleton<IProviderManager, ProviderManager>();
|
services.AddSingleton<IProviderManager, ProviderManager>();
|
||||||
services.AddSingleton<ICrawler, Crawler>();
|
services.AddSingleton<ICrawler, Crawler>();
|
||||||
|
services.AddSingleton<IPluginManager, PluginManager>();
|
||||||
}
|
}
|
||||||
|
|
||||||
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
|
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user