mirror of
https://github.com/zoriya/Kyoo.git
synced 2025-05-24 02:02:36 -04:00
Basic crawler working
This commit is contained in:
parent
5d96452309
commit
2d77ca992b
@ -11,27 +11,27 @@ namespace Kyoo.Controllers
|
||||
Task<Library> GetLibrary(string slug);
|
||||
Task<Collection> GetCollection(string slug);
|
||||
Task<Show> GetShow(string slug);
|
||||
Task<Season> GetSeason(string showSlug, long seasonNumber);
|
||||
Task<Episode> GetEpisode(string showSlug, long seasonNumber, long episodeNumber);
|
||||
Task<Season> GetSeason(string showSlug, int seasonNumber);
|
||||
Task<Episode> GetEpisode(string showSlug, int seasonNumber, int episodeNumber);
|
||||
Task<Episode> GetMovieEpisode(string movieSlug);
|
||||
Task<Track> GetTrack(long id);
|
||||
Task<Track> GetTrack(long episodeID, string language, bool isForced);
|
||||
Task<Track> GetTrack(int id);
|
||||
Task<Track> GetTrack(int episodeID, string language, bool isForced);
|
||||
Task<Genre> GetGenre(string slug);
|
||||
Task<Studio> GetStudio(string slug);
|
||||
Task<People> GetPeople(string slug);
|
||||
|
||||
// Get by relations
|
||||
Task<ICollection<Season>> GetSeasons(long showID);
|
||||
Task<ICollection<Season>> GetSeasons(int showID);
|
||||
Task<ICollection<Season>> GetSeasons(string showSlug);
|
||||
|
||||
Task<ICollection<Episode>> GetEpisodes(long showID, long seasonNumber);
|
||||
Task<ICollection<Episode>> GetEpisodes(string showSlug, long seasonNumber);
|
||||
Task<ICollection<Episode>> GetEpisodes(long seasonID);
|
||||
Task<ICollection<Episode>> GetEpisodes(int showID, int seasonNumber);
|
||||
Task<ICollection<Episode>> GetEpisodes(string showSlug, int seasonNumber);
|
||||
Task<ICollection<Episode>> GetEpisodes(int seasonID);
|
||||
|
||||
|
||||
// Helpers
|
||||
Task<Show> GetShowByPath(string path);
|
||||
Task AddShowLink(long showID, long? libraryID, long? collectionID);
|
||||
Task AddShowLink(int showID, int? libraryID, int? collectionID);
|
||||
Task AddShowLink([NotNull] Show show, Library library, Collection collection);
|
||||
|
||||
// Get all
|
||||
|
@ -14,8 +14,8 @@ namespace Kyoo.Controllers
|
||||
Task<IEnumerable<Show>> SearchShows(string showName, bool isMovie);
|
||||
Task<IEnumerable<PeopleLink>> GetPeople(Show show);
|
||||
|
||||
Task<Season> GetSeason(Show show, long seasonNumber);
|
||||
Task<Season> GetSeason(Show show, int seasonNumber);
|
||||
|
||||
Task<Episode> GetEpisode(Show show, long seasonNumber, long episodeNumber, long absoluteNumber);
|
||||
Task<Episode> GetEpisode(Show show, int seasonNumber, int episodeNumber, int absoluteNumber);
|
||||
}
|
||||
}
|
||||
|
@ -10,8 +10,8 @@ namespace Kyoo.Controllers
|
||||
Task<Show> CompleteShow(Show show, Library library);
|
||||
Task<Show> SearchShow(string showName, bool isMovie, Library library);
|
||||
Task<IEnumerable<Show>> SearchShows(string showName, bool isMovie, Library library);
|
||||
Task<Season> GetSeason(Show show, long seasonNumber, Library library);
|
||||
Task<Episode> GetEpisode(Show show, string episodePath, long seasonNumber, long episodeNumber, long absoluteNumber, Library library);
|
||||
Task<Season> GetSeason(Show show, int seasonNumber, Library library);
|
||||
Task<Episode> GetEpisode(Show show, string episodePath, int seasonNumber, int episodeNumber, int absoluteNumber, Library library);
|
||||
Task<IEnumerable<PeopleLink>> GetPeople(Show show, Library library);
|
||||
}
|
||||
}
|
@ -7,12 +7,12 @@ namespace Kyoo.Controllers
|
||||
{
|
||||
public interface IRepository<T>
|
||||
{
|
||||
Task<T> Get(long id);
|
||||
Task<T> Get(int id);
|
||||
Task<T> Get(string slug);
|
||||
Task<ICollection<T>> Search(string query);
|
||||
Task<ICollection<T>> GetAll();
|
||||
Task<long> Create([NotNull] T obj);
|
||||
Task<long> CreateIfNotExists([NotNull] T obj);
|
||||
Task<int> Create([NotNull] T obj);
|
||||
Task<int> CreateIfNotExists([NotNull] T obj);
|
||||
Task Edit([NotNull] T edited, bool resetOld);
|
||||
Task Delete(T obj);
|
||||
}
|
||||
@ -20,29 +20,29 @@ namespace Kyoo.Controllers
|
||||
public interface IShowRepository : IRepository<Show>
|
||||
{
|
||||
Task<Show> GetByPath(string path);
|
||||
Task AddShowLink(long showID, long? libraryID, long? collectionID);
|
||||
Task AddShowLink(int showID, int? libraryID, int? collectionID);
|
||||
}
|
||||
|
||||
public interface ISeasonRepository : IRepository<Season>
|
||||
{
|
||||
Task<Season> Get(string showSlug, long seasonNumber);
|
||||
Task<Season> Get(string showSlug, int seasonNumber);
|
||||
|
||||
Task<ICollection<Season>> GetSeasons(long showID);
|
||||
Task<ICollection<Season>> GetSeasons(int showID);
|
||||
Task<ICollection<Season>> GetSeasons(string showSlug);
|
||||
}
|
||||
|
||||
public interface IEpisodeRepository : IRepository<Episode>
|
||||
{
|
||||
Task<Episode> Get(string showSlug, long seasonNumber, long episodeNumber);
|
||||
Task<Episode> Get(string showSlug, int seasonNumber, int episodeNumber);
|
||||
|
||||
Task<ICollection<Episode>> GetEpisodes(long showID, long seasonNumber);
|
||||
Task<ICollection<Episode>> GetEpisodes(string showSlug, long seasonNumber);
|
||||
Task<ICollection<Episode>> GetEpisodes(long seasonID);
|
||||
Task<ICollection<Episode>> GetEpisodes(int showID, int seasonNumber);
|
||||
Task<ICollection<Episode>> GetEpisodes(string showSlug, int seasonNumber);
|
||||
Task<ICollection<Episode>> GetEpisodes(int seasonID);
|
||||
}
|
||||
|
||||
public interface ITrackRepository : IRepository<Track>
|
||||
{
|
||||
Task<Track> Get(long episodeID, string languageTag, bool isForced);
|
||||
Task<Track> Get(int episodeID, string languageTag, bool isForced);
|
||||
}
|
||||
public interface ILibraryRepository : IRepository<Library> {}
|
||||
public interface ICollectionRepository : IRepository<Collection> {}
|
||||
|
@ -7,7 +7,7 @@ namespace Kyoo.Models
|
||||
{
|
||||
public class Collection
|
||||
{
|
||||
[JsonIgnore] public long ID { get; set; }
|
||||
[JsonIgnore] public int ID { get; set; }
|
||||
public string Slug { get; set; }
|
||||
public string Name { get; set; }
|
||||
public string Poster { get; set; }
|
||||
|
@ -2,10 +2,10 @@ namespace Kyoo.Models
|
||||
{
|
||||
public class CollectionLink
|
||||
{
|
||||
public long ID { get; set; }
|
||||
public long? CollectionID { get; set; }
|
||||
public int ID { get; set; }
|
||||
public int? CollectionID { get; set; }
|
||||
public virtual Collection Collection { get; set; }
|
||||
public long ShowID { get; set; }
|
||||
public int ShowID { get; set; }
|
||||
public virtual Show Show { get; set; }
|
||||
|
||||
public CollectionLink() { }
|
||||
|
@ -6,21 +6,21 @@ namespace Kyoo.Models
|
||||
{
|
||||
public class Episode
|
||||
{
|
||||
[JsonIgnore] public long ID { get; set; }
|
||||
[JsonIgnore] public long ShowID { get; set; }
|
||||
[JsonIgnore] public int ID { get; set; }
|
||||
[JsonIgnore] public int ShowID { get; set; }
|
||||
[JsonIgnore] public virtual Show Show { get; set; }
|
||||
[JsonIgnore] public long? SeasonID { get; set; }
|
||||
[JsonIgnore] public int? SeasonID { get; set; }
|
||||
[JsonIgnore] public virtual Season Season { get; set; }
|
||||
|
||||
public long SeasonNumber { get; set; }
|
||||
public long EpisodeNumber { get; set; }
|
||||
public long AbsoluteNumber { get; set; }
|
||||
public int SeasonNumber { get; set; }
|
||||
public int EpisodeNumber { get; set; }
|
||||
public int AbsoluteNumber { get; set; }
|
||||
[JsonIgnore] public string Path { get; set; }
|
||||
public string Title { get; set; }
|
||||
public string Overview { get; set; }
|
||||
public DateTime? ReleaseDate { get; set; }
|
||||
|
||||
public long Runtime { get; set; } //This runtime variable should be in minutes
|
||||
public int Runtime { get; set; } //This runtime variable should be in minutes
|
||||
|
||||
[JsonIgnore] public string ImgPrimary { get; set; }
|
||||
public virtual IEnumerable<MetadataID> ExternalIDs { get; set; }
|
||||
@ -42,13 +42,13 @@ namespace Kyoo.Models
|
||||
|
||||
public Episode() { }
|
||||
|
||||
public Episode(long seasonNumber,
|
||||
long episodeNumber,
|
||||
long absoluteNumber,
|
||||
public Episode(int seasonNumber,
|
||||
int episodeNumber,
|
||||
int absoluteNumber,
|
||||
string title,
|
||||
string overview,
|
||||
DateTime? releaseDate,
|
||||
long runtime,
|
||||
int runtime,
|
||||
string imgPrimary,
|
||||
IEnumerable<MetadataID> externalIDs)
|
||||
{
|
||||
@ -63,16 +63,16 @@ namespace Kyoo.Models
|
||||
ExternalIDs = externalIDs;
|
||||
}
|
||||
|
||||
public Episode(long showID,
|
||||
long seasonID,
|
||||
long seasonNumber,
|
||||
long episodeNumber,
|
||||
long absoluteNumber,
|
||||
public Episode(int showID,
|
||||
int seasonID,
|
||||
int seasonNumber,
|
||||
int episodeNumber,
|
||||
int absoluteNumber,
|
||||
string path,
|
||||
string title,
|
||||
string overview,
|
||||
DateTime? releaseDate,
|
||||
long runtime,
|
||||
int runtime,
|
||||
string imgPrimary,
|
||||
IEnumerable<MetadataID> externalIDs)
|
||||
{
|
||||
@ -90,7 +90,7 @@ namespace Kyoo.Models
|
||||
ExternalIDs = externalIDs;
|
||||
}
|
||||
|
||||
public static string GetSlug(string showSlug, long seasonNumber, long episodeNumber)
|
||||
public static string GetSlug(string showSlug, int seasonNumber, int episodeNumber)
|
||||
{
|
||||
return showSlug + "-s" + seasonNumber + "e" + episodeNumber;
|
||||
}
|
||||
|
@ -4,7 +4,7 @@ namespace Kyoo.Models
|
||||
{
|
||||
public class Genre
|
||||
{
|
||||
[JsonIgnore] public long ID { get; set; }
|
||||
[JsonIgnore] public int ID { get; set; }
|
||||
public string Slug { get; set; }
|
||||
public string Name { get; set; }
|
||||
|
||||
@ -24,7 +24,7 @@ namespace Kyoo.Models
|
||||
Name = name;
|
||||
}
|
||||
|
||||
public Genre(long id, string slug, string name)
|
||||
public Genre(int id, string slug, string name)
|
||||
{
|
||||
ID = id;
|
||||
Slug = slug;
|
||||
|
@ -2,9 +2,9 @@ namespace Kyoo.Models
|
||||
{
|
||||
public class GenreLink
|
||||
{
|
||||
public long ShowID { get; set; }
|
||||
public int ShowID { get; set; }
|
||||
public virtual Show Show { get; set; }
|
||||
public long GenreID { get; set; }
|
||||
public int GenreID { get; set; }
|
||||
public virtual Genre Genre { get; set; }
|
||||
|
||||
public GenreLink() {}
|
||||
|
@ -1,5 +1,4 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Kyoo.Models.Attributes;
|
||||
using Newtonsoft.Json;
|
||||
@ -8,7 +7,7 @@ namespace Kyoo.Models
|
||||
{
|
||||
public class Library
|
||||
{
|
||||
[JsonIgnore] public long ID { get; set; }
|
||||
[JsonIgnore] public int ID { get; set; }
|
||||
public string Slug { get; set; }
|
||||
public string Name { get; set; }
|
||||
public IEnumerable<string> Paths { get; set; }
|
||||
|
@ -2,12 +2,12 @@ namespace Kyoo.Models
|
||||
{
|
||||
public class LibraryLink
|
||||
{
|
||||
public long ID { get; set; }
|
||||
public long LibraryID { get; set; }
|
||||
public int ID { get; set; }
|
||||
public int LibraryID { get; set; }
|
||||
public virtual Library Library { get; set; }
|
||||
public long? ShowID { get; set; }
|
||||
public int? ShowID { get; set; }
|
||||
public virtual Show Show { get; set; }
|
||||
public long? CollectionID { get; set; }
|
||||
public int? CollectionID { get; set; }
|
||||
public virtual Collection Collection { get; set; }
|
||||
|
||||
public LibraryLink() { }
|
||||
|
@ -4,20 +4,20 @@ namespace Kyoo.Models
|
||||
{
|
||||
public class MetadataID
|
||||
{
|
||||
[JsonIgnore] public long ID { get; set; }
|
||||
[JsonIgnore] public long ProviderID { get; set; }
|
||||
[JsonIgnore] public int ID { get; set; }
|
||||
[JsonIgnore] public int ProviderID { get; set; }
|
||||
public virtual ProviderID Provider {get; set; }
|
||||
|
||||
[JsonIgnore] public long? ShowID { get; set; }
|
||||
[JsonIgnore] public int? ShowID { get; set; }
|
||||
[JsonIgnore] public virtual Show Show { get; set; }
|
||||
|
||||
[JsonIgnore] public long? EpisodeID { get; set; }
|
||||
[JsonIgnore] public int? EpisodeID { get; set; }
|
||||
[JsonIgnore] public virtual Episode Episode { get; set; }
|
||||
|
||||
[JsonIgnore] public long? SeasonID { get; set; }
|
||||
[JsonIgnore] public int? SeasonID { get; set; }
|
||||
[JsonIgnore] public virtual Season Season { get; set; }
|
||||
|
||||
[JsonIgnore] public long? PeopleID { get; set; }
|
||||
[JsonIgnore] public int? PeopleID { get; set; }
|
||||
[JsonIgnore] public virtual People People { get; set; }
|
||||
|
||||
public string DataID { get; set; }
|
||||
|
@ -6,7 +6,7 @@ namespace Kyoo.Models
|
||||
{
|
||||
public class People
|
||||
{
|
||||
public long ID { get; set; }
|
||||
public int ID { get; set; }
|
||||
public string Slug { get; set; }
|
||||
public string Name { get; set; }
|
||||
[JsonIgnore] public string ImgPrimary { get; set; }
|
||||
|
@ -5,8 +5,8 @@ namespace Kyoo.Models
|
||||
{
|
||||
public class PeopleLink
|
||||
{
|
||||
[JsonIgnore] public long ID { get; set; }
|
||||
[JsonIgnore] public long PeopleID { get; set; }
|
||||
[JsonIgnore] public int ID { get; set; }
|
||||
[JsonIgnore] public int PeopleID { get; set; }
|
||||
[JsonIgnore] public virtual People People { get; set; }
|
||||
|
||||
public string Slug
|
||||
@ -27,7 +27,7 @@ namespace Kyoo.Models
|
||||
set => People.ExternalIDs = value;
|
||||
}
|
||||
|
||||
[JsonIgnore] public long ShowID { get; set; }
|
||||
[JsonIgnore] public int ShowID { get; set; }
|
||||
[JsonIgnore] public virtual Show Show { get; set; }
|
||||
public string Role { get; set; }
|
||||
public string Type { get; set; }
|
||||
|
@ -4,13 +4,13 @@ namespace Kyoo.Models
|
||||
{
|
||||
public class ProviderID
|
||||
{
|
||||
[JsonIgnore] public long ID { get; set; }
|
||||
[JsonIgnore] public int ID { get; set; }
|
||||
public string Name { get; set; }
|
||||
public string Logo { get; set; }
|
||||
|
||||
public ProviderID() { }
|
||||
|
||||
public ProviderID(long id, string name, string logo)
|
||||
public ProviderID(int id, string name, string logo)
|
||||
{
|
||||
ID = id;
|
||||
Name = name;
|
||||
|
@ -4,10 +4,10 @@ namespace Kyoo.Models
|
||||
{
|
||||
public class ProviderLink
|
||||
{
|
||||
[JsonIgnore] public long ID { get; set; }
|
||||
[JsonIgnore] public long ProviderID { get; set; }
|
||||
[JsonIgnore] public int ID { get; set; }
|
||||
[JsonIgnore] public int ProviderID { get; set; }
|
||||
[JsonIgnore] public virtual ProviderID Provider { get; set; }
|
||||
[JsonIgnore] public long? LibraryID { get; set; }
|
||||
[JsonIgnore] public int? LibraryID { get; set; }
|
||||
[JsonIgnore] public virtual Library Library { get; set; }
|
||||
|
||||
public ProviderLink() { }
|
||||
|
@ -5,15 +5,15 @@ namespace Kyoo.Models
|
||||
{
|
||||
public class Season
|
||||
{
|
||||
[JsonIgnore] public long ID { get; set; }
|
||||
[JsonIgnore] public long ShowID { get; set; }
|
||||
[JsonIgnore] public int ID { get; set; }
|
||||
[JsonIgnore] public int ShowID { get; set; }
|
||||
|
||||
public long SeasonNumber { get; set; } = -1;
|
||||
public int SeasonNumber { get; set; } = -1;
|
||||
|
||||
public string Slug => $"{Show.Slug}-s{SeasonNumber}";
|
||||
public string Title { get; set; }
|
||||
public string Overview { get; set; }
|
||||
public long? Year { get; set; }
|
||||
public int? Year { get; set; }
|
||||
|
||||
[JsonIgnore] public string ImgPrimary { get; set; }
|
||||
public virtual IEnumerable<MetadataID> ExternalIDs { get; set; }
|
||||
@ -23,11 +23,11 @@ namespace Kyoo.Models
|
||||
|
||||
public Season() { }
|
||||
|
||||
public Season(long showID,
|
||||
long seasonNumber,
|
||||
public Season(int showID,
|
||||
int seasonNumber,
|
||||
string title,
|
||||
string overview,
|
||||
long? year,
|
||||
int? year,
|
||||
string imgPrimary,
|
||||
IEnumerable<MetadataID> externalIDs)
|
||||
{
|
||||
|
@ -7,7 +7,7 @@ namespace Kyoo.Models
|
||||
{
|
||||
public class Show : IOnMerge
|
||||
{
|
||||
[JsonIgnore] public long ID { get; set; }
|
||||
[JsonIgnore] public int ID { get; set; }
|
||||
|
||||
public string Slug { get; set; }
|
||||
public string Title { get; set; }
|
||||
@ -17,8 +17,8 @@ namespace Kyoo.Models
|
||||
public Status? Status { get; set; }
|
||||
public string TrailerUrl { get; set; }
|
||||
|
||||
public long? StartYear { get; set; }
|
||||
public long? EndYear { get; set; }
|
||||
public int? StartYear { get; set; }
|
||||
public int? EndYear { get; set; }
|
||||
|
||||
public string Poster { get; set; }
|
||||
public string Logo { get; set; }
|
||||
@ -36,7 +36,7 @@ namespace Kyoo.Models
|
||||
set => GenreLinks = value?.Select(x => new GenreLink(this, x)).ToList();
|
||||
}
|
||||
[NotMergable] [JsonIgnore] public virtual IEnumerable<GenreLink> GenreLinks { get; set; }
|
||||
[JsonIgnore] public long StudioID { get; set; }
|
||||
[JsonIgnore] public int? StudioID { get; set; }
|
||||
public virtual Studio Studio { get; set; }
|
||||
[JsonIgnore] public virtual IEnumerable<PeopleLink> People { get; set; }
|
||||
[JsonIgnore] public virtual IEnumerable<Season> Seasons { get; set; }
|
||||
@ -51,8 +51,8 @@ namespace Kyoo.Models
|
||||
string trailerUrl,
|
||||
IEnumerable<Genre> genres,
|
||||
Status? status,
|
||||
long? startYear,
|
||||
long? endYear,
|
||||
int? startYear,
|
||||
int? endYear,
|
||||
IEnumerable<MetadataID> externalIDs)
|
||||
{
|
||||
Slug = slug;
|
||||
@ -76,8 +76,8 @@ namespace Kyoo.Models
|
||||
string overview,
|
||||
string trailerUrl,
|
||||
Status? status,
|
||||
long? startYear,
|
||||
long? endYear,
|
||||
int? startYear,
|
||||
int? endYear,
|
||||
string poster,
|
||||
string logo,
|
||||
string backdrop,
|
||||
|
@ -5,7 +5,7 @@ namespace Kyoo.Models
|
||||
{
|
||||
public class Studio
|
||||
{
|
||||
[JsonIgnore] public long ID { get; set; }
|
||||
[JsonIgnore] public int ID { get; set; }
|
||||
public string Slug { get; set; }
|
||||
public string Name { get; set; }
|
||||
|
||||
|
@ -55,8 +55,8 @@ namespace Kyoo.Models
|
||||
|
||||
public class Track : Stream
|
||||
{
|
||||
[JsonIgnore] public long ID { get; set; }
|
||||
[JsonIgnore] public long EpisodeID { get; set; }
|
||||
[JsonIgnore] public int ID { get; set; }
|
||||
[JsonIgnore] public int EpisodeID { get; set; }
|
||||
public bool IsDefault
|
||||
{
|
||||
get => isDefault;
|
||||
|
@ -7,12 +7,12 @@ namespace Kyoo.Models
|
||||
{
|
||||
public class WatchItem
|
||||
{
|
||||
[JsonIgnore] public readonly long EpisodeID = -1;
|
||||
[JsonIgnore] public readonly int EpisodeID = -1;
|
||||
|
||||
public string ShowTitle;
|
||||
public string ShowSlug;
|
||||
public long SeasonNumber;
|
||||
public long EpisodeNumber;
|
||||
public int SeasonNumber;
|
||||
public int EpisodeNumber;
|
||||
public string Title;
|
||||
public string Link;
|
||||
public DateTime? ReleaseDate;
|
||||
@ -28,11 +28,11 @@ namespace Kyoo.Models
|
||||
|
||||
public WatchItem() { }
|
||||
|
||||
public WatchItem(long episodeID,
|
||||
public WatchItem(int episodeID,
|
||||
string showTitle,
|
||||
string showSlug,
|
||||
long seasonNumber,
|
||||
long episodeNumber,
|
||||
int seasonNumber,
|
||||
int episodeNumber,
|
||||
string title,
|
||||
DateTime? releaseDate,
|
||||
string path)
|
||||
@ -50,11 +50,11 @@ namespace Kyoo.Models
|
||||
Link = Episode.GetSlug(ShowSlug, seasonNumber, episodeNumber);
|
||||
}
|
||||
|
||||
public WatchItem(long episodeID,
|
||||
public WatchItem(int episodeID,
|
||||
string showTitle,
|
||||
string showSlug,
|
||||
long seasonNumber,
|
||||
long episodeNumber,
|
||||
int seasonNumber,
|
||||
int episodeNumber,
|
||||
string title,
|
||||
DateTime? releaseDate,
|
||||
string path,
|
||||
|
@ -18,18 +18,27 @@ namespace Kyoo.Controllers
|
||||
private readonly IPeopleRepository _people;
|
||||
private readonly IProviderRepository _providers;
|
||||
|
||||
public LibraryManager(DatabaseContext database)
|
||||
public LibraryManager(ILibraryRepository libraries,
|
||||
ICollectionRepository collections,
|
||||
IShowRepository shows,
|
||||
ISeasonRepository seasons,
|
||||
IEpisodeRepository episodes,
|
||||
ITrackRepository tracks,
|
||||
IGenreRepository genres,
|
||||
IStudioRepository studios,
|
||||
IProviderRepository providers,
|
||||
IPeopleRepository people)
|
||||
{
|
||||
_providers = new ProviderRepository(database);
|
||||
_libraries = new LibraryRepository(database, _providers);
|
||||
_collections = new CollectionRepository(database);
|
||||
_genres = new GenreRepository(database);
|
||||
_people = new PeopleRepository(database, _providers);
|
||||
_studios = new StudioRepository(database);
|
||||
_shows = new ShowRepository(database, _genres, _people, _studios, _providers);
|
||||
_seasons = new SeasonRepository(database, _providers);
|
||||
_episodes = new EpisodeRepository(database, _providers);
|
||||
_tracks = new TrackRepository(database);
|
||||
_libraries = libraries;
|
||||
_collections = collections;
|
||||
_shows = shows;
|
||||
_seasons = seasons;
|
||||
_episodes = episodes;
|
||||
_tracks = tracks;
|
||||
_genres = genres;
|
||||
_studios = studios;
|
||||
_providers = providers;
|
||||
_people = people;
|
||||
}
|
||||
|
||||
public Task<Library> GetLibrary(string slug)
|
||||
@ -47,12 +56,12 @@ namespace Kyoo.Controllers
|
||||
return _shows.Get(slug);
|
||||
}
|
||||
|
||||
public Task<Season> GetSeason(string showSlug, long seasonNumber)
|
||||
public Task<Season> GetSeason(string showSlug, int seasonNumber)
|
||||
{
|
||||
return _seasons.Get(showSlug, seasonNumber);
|
||||
}
|
||||
|
||||
public Task<Episode> GetEpisode(string showSlug, long seasonNumber, long episodeNumber)
|
||||
public Task<Episode> GetEpisode(string showSlug, int seasonNumber, int episodeNumber)
|
||||
{
|
||||
return _episodes.Get(showSlug, seasonNumber, episodeNumber);
|
||||
}
|
||||
@ -62,12 +71,12 @@ namespace Kyoo.Controllers
|
||||
return _episodes.Get(movieSlug);
|
||||
}
|
||||
|
||||
public Task<Track> GetTrack(long id)
|
||||
public Task<Track> GetTrack(int id)
|
||||
{
|
||||
return _tracks.Get(id);
|
||||
}
|
||||
|
||||
public Task<Track> GetTrack(long episodeID, string language, bool isForced)
|
||||
public Task<Track> GetTrack(int episodeID, string language, bool isForced)
|
||||
{
|
||||
return _tracks.Get(episodeID, language, isForced);
|
||||
}
|
||||
@ -137,7 +146,7 @@ namespace Kyoo.Controllers
|
||||
return _providers.GetAll();
|
||||
}
|
||||
|
||||
public Task<ICollection<Season>> GetSeasons(long showID)
|
||||
public Task<ICollection<Season>> GetSeasons(int showID)
|
||||
{
|
||||
return _seasons.GetSeasons(showID);
|
||||
}
|
||||
@ -147,17 +156,17 @@ namespace Kyoo.Controllers
|
||||
return _seasons.GetSeasons(showSlug);
|
||||
}
|
||||
|
||||
public Task<ICollection<Episode>> GetEpisodes(long showID, long seasonNumber)
|
||||
public Task<ICollection<Episode>> GetEpisodes(int showID, int seasonNumber)
|
||||
{
|
||||
return _episodes.GetEpisodes(showID, seasonNumber);
|
||||
}
|
||||
|
||||
public Task<ICollection<Episode>> GetEpisodes(string showSlug, long seasonNumber)
|
||||
public Task<ICollection<Episode>> GetEpisodes(string showSlug, int seasonNumber)
|
||||
{
|
||||
return _episodes.GetEpisodes(showSlug, seasonNumber);
|
||||
}
|
||||
|
||||
public Task<ICollection<Episode>> GetEpisodes(long seasonID)
|
||||
public Task<ICollection<Episode>> GetEpisodes(int seasonID)
|
||||
{
|
||||
return _episodes.GetEpisodes(seasonID);
|
||||
}
|
||||
@ -167,7 +176,7 @@ namespace Kyoo.Controllers
|
||||
return _shows.GetByPath(path);
|
||||
}
|
||||
|
||||
public Task AddShowLink(long showID, long? libraryID, long? collectionID)
|
||||
public Task AddShowLink(int showID, int? libraryID, int? collectionID)
|
||||
{
|
||||
return _shows.AddShowLink(showID, libraryID, collectionID);
|
||||
}
|
||||
|
@ -113,13 +113,14 @@ namespace Kyoo.Controllers
|
||||
});
|
||||
}
|
||||
|
||||
public async Task<Season> GetSeason(Show show, long seasonNumber, Library library)
|
||||
public async Task<Season> GetSeason(Show show, int seasonNumber, Library library)
|
||||
{
|
||||
Season season = await GetMetadata(
|
||||
provider => provider.GetSeason(show, seasonNumber),
|
||||
library,
|
||||
$"the season {seasonNumber} of {show.Title}");
|
||||
season.Show = show;
|
||||
season.ShowID = show.ID;
|
||||
season.SeasonNumber = season.SeasonNumber == -1 ? seasonNumber : season.SeasonNumber;
|
||||
season.Title ??= $"Season {season.SeasonNumber}";
|
||||
return season;
|
||||
@ -127,9 +128,9 @@ namespace Kyoo.Controllers
|
||||
|
||||
public async Task<Episode> GetEpisode(Show show,
|
||||
string episodePath,
|
||||
long seasonNumber,
|
||||
long episodeNumber,
|
||||
long absoluteNumber,
|
||||
int seasonNumber,
|
||||
int episodeNumber,
|
||||
int absoluteNumber,
|
||||
Library library)
|
||||
{
|
||||
Episode episode = await GetMetadata(
|
||||
@ -137,6 +138,7 @@ namespace Kyoo.Controllers
|
||||
library,
|
||||
"an episode");
|
||||
episode.Show = show;
|
||||
episode.ShowID = show.ID;
|
||||
episode.Path = episodePath;
|
||||
episode.SeasonNumber = episode.SeasonNumber != -1 ? episode.SeasonNumber : seasonNumber;
|
||||
episode.EpisodeNumber = episode.EpisodeNumber != -1 ? episode.EpisodeNumber : episodeNumber;
|
||||
@ -155,6 +157,7 @@ namespace Kyoo.Controllers
|
||||
.Select(x =>
|
||||
{
|
||||
x.Show = show;
|
||||
x.ShowID = show.ID;
|
||||
return x;
|
||||
}).ToList();
|
||||
}
|
||||
|
@ -18,7 +18,7 @@ namespace Kyoo.Controllers
|
||||
_database = database;
|
||||
}
|
||||
|
||||
public Task<Collection> Get(long id)
|
||||
public Task<Collection> Get(int id)
|
||||
{
|
||||
return _database.Collections.FirstOrDefaultAsync(x => x.ID == id);
|
||||
}
|
||||
@ -41,7 +41,7 @@ namespace Kyoo.Controllers
|
||||
return await _database.Collections.ToListAsync();
|
||||
}
|
||||
|
||||
public async Task<long> Create(Collection obj)
|
||||
public async Task<int> Create(Collection obj)
|
||||
{
|
||||
if (obj == null)
|
||||
throw new ArgumentNullException(nameof(obj));
|
||||
@ -51,7 +51,7 @@ namespace Kyoo.Controllers
|
||||
return obj.ID;
|
||||
}
|
||||
|
||||
public async Task<long> CreateIfNotExists(Collection obj)
|
||||
public async Task<int> CreateIfNotExists(Collection obj)
|
||||
{
|
||||
if (obj == null)
|
||||
throw new ArgumentNullException(nameof(obj));
|
||||
|
@ -5,22 +5,23 @@ using System.Threading.Tasks;
|
||||
using Kyoo.Models;
|
||||
using Kyoo.Models.Exceptions;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
|
||||
namespace Kyoo.Controllers
|
||||
{
|
||||
public class EpisodeRepository : IEpisodeRepository
|
||||
{
|
||||
private readonly DatabaseContext _database;
|
||||
private readonly IProviderRepository _providers;
|
||||
private readonly IServiceProvider _serviceProvider;
|
||||
|
||||
|
||||
public EpisodeRepository(DatabaseContext database, IProviderRepository providers)
|
||||
public EpisodeRepository(DatabaseContext database, IServiceProvider serviceProvider)
|
||||
{
|
||||
_database = database;
|
||||
_providers = providers;
|
||||
_serviceProvider = serviceProvider;
|
||||
}
|
||||
|
||||
public async Task<Episode> Get(long id)
|
||||
public async Task<Episode> Get(int id)
|
||||
{
|
||||
return await _database.Episodes.FirstOrDefaultAsync(x => x.ID == id);
|
||||
}
|
||||
@ -32,14 +33,14 @@ namespace Kyoo.Controllers
|
||||
if (sIndex == -1 || eIndex == -1 || eIndex < sIndex)
|
||||
throw new InvalidOperationException("Invalid episode slug. Format: {showSlug}-s{seasonNumber}-e{episodeNumber}");
|
||||
string showSlug = slug.Substring(0, sIndex);
|
||||
if (!long.TryParse(slug.Substring(sIndex + 2), out long seasonNumber))
|
||||
if (!int.TryParse(slug.Substring(sIndex + 2), out int seasonNumber))
|
||||
throw new InvalidOperationException("Invalid episode slug. Format: {showSlug}-s{seasonNumber}-e{episodeNumber}");
|
||||
if (!long.TryParse(slug.Substring(eIndex + 2), out long episodeNumber))
|
||||
if (!int.TryParse(slug.Substring(eIndex + 2), out int episodeNumber))
|
||||
throw new InvalidOperationException("Invalid episode slug. Format: {showSlug}-s{seasonNumber}-e{episodeNumber}");
|
||||
return Get(showSlug, seasonNumber, episodeNumber);
|
||||
}
|
||||
|
||||
public async Task<Episode> Get(string showSlug, long seasonNumber, long episodeNumber)
|
||||
public async Task<Episode> Get(string showSlug, int seasonNumber, int episodeNumber)
|
||||
{
|
||||
return await _database.Episodes.FirstOrDefaultAsync(x => x.Show.Slug == showSlug
|
||||
&& x.SeasonNumber == seasonNumber
|
||||
@ -59,7 +60,7 @@ namespace Kyoo.Controllers
|
||||
return await _database.Episodes.ToListAsync();
|
||||
}
|
||||
|
||||
public async Task<long> Create(Episode obj)
|
||||
public async Task<int> Create(Episode obj)
|
||||
{
|
||||
if (obj == null)
|
||||
throw new ArgumentNullException(nameof(obj));
|
||||
@ -70,7 +71,7 @@ namespace Kyoo.Controllers
|
||||
return obj.ID;
|
||||
}
|
||||
|
||||
public async Task<long> CreateIfNotExists(Episode obj)
|
||||
public async Task<int> CreateIfNotExists(Episode obj)
|
||||
{
|
||||
if (obj == null)
|
||||
throw new ArgumentNullException(nameof(obj));
|
||||
@ -104,11 +105,17 @@ namespace Kyoo.Controllers
|
||||
if (obj.ShowID <= 0)
|
||||
throw new InvalidOperationException($"Can't store an episode not related to any show (showID: {obj.ShowID}).");
|
||||
|
||||
obj.ExternalIDs = (await Task.WhenAll(obj.ExternalIDs.Select(async x =>
|
||||
if (obj.ExternalIDs != null)
|
||||
{
|
||||
x.ProviderID = await _providers.CreateIfNotExists(x.Provider);
|
||||
return x;
|
||||
}))).ToList();
|
||||
obj.ExternalIDs = (await Task.WhenAll(obj.ExternalIDs.Select(async x =>
|
||||
{
|
||||
using IServiceScope serviceScope = _serviceProvider.CreateScope();
|
||||
IProviderRepository providers = serviceScope.ServiceProvider.GetService<IProviderRepository>();
|
||||
|
||||
x.ProviderID = await providers.CreateIfNotExists(x.Provider);
|
||||
return x;
|
||||
}))).ToList();
|
||||
}
|
||||
}
|
||||
|
||||
public async Task Delete(Episode obj)
|
||||
@ -117,19 +124,19 @@ namespace Kyoo.Controllers
|
||||
await _database.SaveChangesAsync();
|
||||
}
|
||||
|
||||
public async Task<ICollection<Episode>> GetEpisodes(long showID, long seasonNumber)
|
||||
public async Task<ICollection<Episode>> GetEpisodes(int showID, int seasonNumber)
|
||||
{
|
||||
return await _database.Episodes.Where(x => x.ShowID == showID
|
||||
&& x.SeasonNumber == seasonNumber).ToListAsync();
|
||||
}
|
||||
|
||||
public async Task<ICollection<Episode>> GetEpisodes(string showSlug, long seasonNumber)
|
||||
public async Task<ICollection<Episode>> GetEpisodes(string showSlug, int seasonNumber)
|
||||
{
|
||||
return await _database.Episodes.Where(x => x.Show.Slug == showSlug
|
||||
&& x.SeasonNumber == seasonNumber).ToListAsync();
|
||||
}
|
||||
|
||||
public async Task<ICollection<Episode>> GetEpisodes(long seasonID)
|
||||
public async Task<ICollection<Episode>> GetEpisodes(int seasonID)
|
||||
{
|
||||
return await _database.Episodes.Where(x => x.SeasonID == seasonID).ToListAsync();
|
||||
}
|
||||
|
@ -18,7 +18,7 @@ namespace Kyoo.Controllers
|
||||
_database = database;
|
||||
}
|
||||
|
||||
public async Task<Genre> Get(long id)
|
||||
public async Task<Genre> Get(int id)
|
||||
{
|
||||
return await _database.Genres.FirstOrDefaultAsync(x => x.ID == id);
|
||||
}
|
||||
@ -41,7 +41,7 @@ namespace Kyoo.Controllers
|
||||
return await _database.Genres.ToListAsync();
|
||||
}
|
||||
|
||||
public async Task<long> Create(Genre obj)
|
||||
public async Task<int> Create(Genre obj)
|
||||
{
|
||||
if (obj == null)
|
||||
throw new ArgumentNullException(nameof(obj));
|
||||
@ -51,7 +51,7 @@ namespace Kyoo.Controllers
|
||||
return obj.ID;
|
||||
}
|
||||
|
||||
public async Task<long> CreateIfNotExists(Genre obj)
|
||||
public async Task<int> CreateIfNotExists(Genre obj)
|
||||
{
|
||||
if (obj == null)
|
||||
throw new ArgumentNullException(nameof(obj));
|
||||
|
@ -5,29 +5,30 @@ using System.Threading.Tasks;
|
||||
using Kyoo.Models;
|
||||
using Kyoo.Models.Exceptions;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
|
||||
namespace Kyoo.Controllers
|
||||
{
|
||||
public class LibraryRepository : ILibraryRepository
|
||||
{
|
||||
private readonly DatabaseContext _database;
|
||||
private readonly IProviderRepository _providers;
|
||||
private readonly IServiceProvider _serviceProvider;
|
||||
|
||||
|
||||
public LibraryRepository(DatabaseContext database, IProviderRepository providers)
|
||||
public LibraryRepository(DatabaseContext database, IServiceProvider serviceProvider)
|
||||
{
|
||||
_database = database;
|
||||
_providers = providers;
|
||||
_serviceProvider = serviceProvider;
|
||||
}
|
||||
|
||||
public Task<Library> Get(long id)
|
||||
public Task<Library> Get(int id)
|
||||
{
|
||||
return _database.Libraries.FirstOrDefaultAsync(x => x.ID == id);
|
||||
}
|
||||
|
||||
public Task<Library> Get(string slug)
|
||||
{
|
||||
return _database.Libraries.FirstOrDefaultAsync(x => x.Name == slug);
|
||||
return _database.Libraries.FirstOrDefaultAsync(x => x.Slug == slug);
|
||||
}
|
||||
|
||||
public async Task<ICollection<Library>> Search(string query)
|
||||
@ -43,19 +44,19 @@ namespace Kyoo.Controllers
|
||||
return await _database.Libraries.ToListAsync();
|
||||
}
|
||||
|
||||
public async Task<long> Create(Library obj)
|
||||
public async Task<int> Create(Library obj)
|
||||
{
|
||||
if (obj == null)
|
||||
throw new ArgumentNullException(nameof(obj));
|
||||
|
||||
obj.Links = null;
|
||||
await Validate(obj);
|
||||
await _database.Libraries.AddAsync(obj);
|
||||
_database.Entry(obj).State = EntityState.Added;
|
||||
await _database.SaveChangesAsync();
|
||||
return obj.ID;
|
||||
}
|
||||
|
||||
public async Task<long> CreateIfNotExists(Library obj)
|
||||
public async Task<int> CreateIfNotExists(Library obj)
|
||||
{
|
||||
if (obj == null)
|
||||
throw new ArgumentNullException(nameof(obj));
|
||||
@ -87,7 +88,10 @@ namespace Kyoo.Controllers
|
||||
{
|
||||
obj.ProviderLinks = (await Task.WhenAll(obj.ProviderLinks.Select(async x =>
|
||||
{
|
||||
x.ProviderID = await _providers.CreateIfNotExists(x.Provider);
|
||||
using IServiceScope serviceScope = _serviceProvider.CreateScope();
|
||||
IProviderRepository providers = serviceScope.ServiceProvider.GetService<IProviderRepository>();
|
||||
|
||||
x.ProviderID = await providers.CreateIfNotExists(x.Provider);
|
||||
return x;
|
||||
}))).ToList();
|
||||
}
|
||||
|
@ -19,7 +19,7 @@ namespace Kyoo.Controllers
|
||||
_providers = providers;
|
||||
}
|
||||
|
||||
public Task<People> Get(long id)
|
||||
public Task<People> Get(int id)
|
||||
{
|
||||
return _database.Peoples.FirstOrDefaultAsync(x => x.ID == id);
|
||||
}
|
||||
@ -42,7 +42,7 @@ namespace Kyoo.Controllers
|
||||
return await _database.Peoples.ToListAsync();
|
||||
}
|
||||
|
||||
public async Task<long> Create(People obj)
|
||||
public async Task<int> Create(People obj)
|
||||
{
|
||||
if (obj == null)
|
||||
throw new ArgumentNullException(nameof(obj));
|
||||
@ -55,7 +55,7 @@ namespace Kyoo.Controllers
|
||||
return obj.ID;
|
||||
}
|
||||
|
||||
public async Task<long> CreateIfNotExists(People obj)
|
||||
public async Task<int> CreateIfNotExists(People obj)
|
||||
{
|
||||
if (obj == null)
|
||||
throw new ArgumentNullException(nameof(obj));
|
||||
|
@ -18,7 +18,7 @@ namespace Kyoo.Controllers
|
||||
_database = database;
|
||||
}
|
||||
|
||||
public async Task<ProviderID> Get(long id)
|
||||
public async Task<ProviderID> Get(int id)
|
||||
{
|
||||
return await _database.Providers.FirstOrDefaultAsync(x => x.ID == id);
|
||||
}
|
||||
@ -41,17 +41,17 @@ namespace Kyoo.Controllers
|
||||
return await _database.Providers.ToListAsync();
|
||||
}
|
||||
|
||||
public async Task<long> Create(ProviderID obj)
|
||||
public async Task<int> Create(ProviderID obj)
|
||||
{
|
||||
if (obj == null)
|
||||
throw new ArgumentNullException(nameof(obj));
|
||||
|
||||
|
||||
await _database.Providers.AddAsync(obj);
|
||||
await _database.SaveChangesAsync();
|
||||
return obj.ID;
|
||||
}
|
||||
|
||||
public async Task<long> CreateIfNotExists(ProviderID obj)
|
||||
public async Task<int> CreateIfNotExists(ProviderID obj)
|
||||
{
|
||||
if (obj == null)
|
||||
throw new ArgumentNullException(nameof(obj));
|
||||
|
@ -5,22 +5,23 @@ using System.Threading.Tasks;
|
||||
using Kyoo.Models;
|
||||
using Kyoo.Models.Exceptions;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
|
||||
namespace Kyoo.Controllers
|
||||
{
|
||||
public class SeasonRepository : ISeasonRepository
|
||||
{
|
||||
private readonly DatabaseContext _database;
|
||||
private readonly IProviderRepository _providers;
|
||||
private readonly IServiceProvider _serviceProvider;
|
||||
|
||||
|
||||
public SeasonRepository(DatabaseContext database, IProviderRepository providers)
|
||||
public SeasonRepository(DatabaseContext database, IServiceProvider serviceProvider)
|
||||
{
|
||||
_database = database;
|
||||
_providers = providers;
|
||||
_serviceProvider = serviceProvider;
|
||||
}
|
||||
|
||||
public async Task<Season> Get(long id)
|
||||
public async Task<Season> Get(int id)
|
||||
{
|
||||
return await _database.Seasons.FirstOrDefaultAsync(x => x.ID == id);
|
||||
}
|
||||
@ -31,12 +32,12 @@ namespace Kyoo.Controllers
|
||||
if (index == -1)
|
||||
throw new InvalidOperationException("Invalid season slug. Format: {showSlug}-s{seasonNumber}");
|
||||
string showSlug = slug.Substring(0, index);
|
||||
if (!long.TryParse(slug.Substring(index + 2), out long seasonNumber))
|
||||
if (!int.TryParse(slug.Substring(index + 2), out int seasonNumber))
|
||||
throw new InvalidOperationException("Invalid season slug. Format: {showSlug}-s{seasonNumber}");
|
||||
return Get(showSlug, seasonNumber);
|
||||
}
|
||||
|
||||
public async Task<Season> Get(string showSlug, long seasonNumber)
|
||||
public async Task<Season> Get(string showSlug, int seasonNumber)
|
||||
{
|
||||
return await _database.Seasons.FirstOrDefaultAsync(x => x.Show.Slug == showSlug
|
||||
&& x.SeasonNumber == seasonNumber);
|
||||
@ -55,7 +56,7 @@ namespace Kyoo.Controllers
|
||||
return await _database.Seasons.ToListAsync();
|
||||
}
|
||||
|
||||
public async Task<long> Create(Season obj)
|
||||
public async Task<int> Create(Season obj)
|
||||
{
|
||||
if (obj == null)
|
||||
throw new ArgumentNullException(nameof(obj));
|
||||
@ -69,7 +70,7 @@ namespace Kyoo.Controllers
|
||||
return obj.ID;
|
||||
}
|
||||
|
||||
public async Task<long> CreateIfNotExists(Season obj)
|
||||
public async Task<int> CreateIfNotExists(Season obj)
|
||||
{
|
||||
if (obj == null)
|
||||
throw new ArgumentNullException(nameof(obj));
|
||||
@ -102,12 +103,18 @@ namespace Kyoo.Controllers
|
||||
{
|
||||
if (obj.ShowID <= 0)
|
||||
throw new InvalidOperationException($"Can't store a season not related to any show (showID: {obj.ShowID}).");
|
||||
|
||||
obj.ExternalIDs = (await Task.WhenAll(obj.ExternalIDs.Select(async x =>
|
||||
|
||||
if (obj.ExternalIDs != null)
|
||||
{
|
||||
x.ProviderID = await _providers.CreateIfNotExists(x.Provider);
|
||||
return x;
|
||||
}))).ToList();
|
||||
obj.ExternalIDs = (await Task.WhenAll(obj.ExternalIDs.Select(async x =>
|
||||
{
|
||||
using IServiceScope serviceScope = _serviceProvider.CreateScope();
|
||||
IProviderRepository providers = serviceScope.ServiceProvider.GetService<IProviderRepository>();
|
||||
|
||||
x.ProviderID = await providers.CreateIfNotExists(x.Provider);
|
||||
return x;
|
||||
}))).ToList();
|
||||
}
|
||||
}
|
||||
|
||||
public async Task Delete(Season obj)
|
||||
@ -116,7 +123,7 @@ namespace Kyoo.Controllers
|
||||
await _database.SaveChangesAsync();
|
||||
}
|
||||
|
||||
public async Task<ICollection<Season>> GetSeasons(long showID)
|
||||
public async Task<ICollection<Season>> GetSeasons(int showID)
|
||||
{
|
||||
return await _database.Seasons.Where(x => x.ShowID == showID).ToListAsync();
|
||||
}
|
||||
|
@ -5,31 +5,26 @@ using System.Threading.Tasks;
|
||||
using Kyoo.Models;
|
||||
using Kyoo.Models.Exceptions;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
|
||||
namespace Kyoo.Controllers
|
||||
{
|
||||
public class ShowRepository : IShowRepository
|
||||
{
|
||||
private readonly DatabaseContext _database;
|
||||
private readonly IGenreRepository _genres;
|
||||
private readonly IPeopleRepository _people;
|
||||
private readonly IStudioRepository _studio;
|
||||
private readonly IProviderRepository _providers;
|
||||
private readonly IServiceProvider _serviceProvider;
|
||||
private readonly IStudioRepository _studios;
|
||||
|
||||
public ShowRepository(DatabaseContext database,
|
||||
IGenreRepository genres,
|
||||
IPeopleRepository people,
|
||||
IStudioRepository studio,
|
||||
IProviderRepository providers)
|
||||
IServiceProvider serviceProvider,
|
||||
IStudioRepository studios)
|
||||
{
|
||||
_database = database;
|
||||
_genres = genres;
|
||||
_people = people;
|
||||
_studio = studio;
|
||||
_providers = providers;
|
||||
_serviceProvider = serviceProvider;
|
||||
_studios = studios;
|
||||
}
|
||||
|
||||
public async Task<Show> Get(long id)
|
||||
public async Task<Show> Get(int id)
|
||||
{
|
||||
return await _database.Shows.FirstOrDefaultAsync(x => x.ID == id);
|
||||
}
|
||||
@ -58,22 +53,18 @@ namespace Kyoo.Controllers
|
||||
return await _database.Shows.ToListAsync();
|
||||
}
|
||||
|
||||
public async Task<long> Create(Show obj)
|
||||
public async Task<int> Create(Show obj)
|
||||
{
|
||||
if (obj == null)
|
||||
throw new ArgumentNullException(nameof(obj));
|
||||
|
||||
await Validate(obj);
|
||||
|
||||
obj.Seasons = null;
|
||||
obj.Episodes = null;
|
||||
|
||||
await _database.Shows.AddAsync(obj);
|
||||
_database.Entry(obj).State = EntityState.Added;
|
||||
await _database.SaveChangesAsync();
|
||||
return obj.ID;
|
||||
}
|
||||
|
||||
public async Task<long> CreateIfNotExists(Show obj)
|
||||
public async Task<int> CreateIfNotExists(Show obj)
|
||||
{
|
||||
if (obj == null)
|
||||
throw new ArgumentNullException(nameof(obj));
|
||||
@ -103,22 +94,44 @@ namespace Kyoo.Controllers
|
||||
|
||||
private async Task Validate(Show obj)
|
||||
{
|
||||
obj.StudioID = await _studio.CreateIfNotExists(obj.Studio);
|
||||
obj.GenreLinks = (await Task.WhenAll(obj.GenreLinks.Select(async x =>
|
||||
if (obj.Studio != null)
|
||||
obj.StudioID = await _studios.CreateIfNotExists(obj.Studio);
|
||||
|
||||
if (obj.GenreLinks != null)
|
||||
{
|
||||
x.GenreID = await _genres.CreateIfNotExists(x.Genre);
|
||||
return x;
|
||||
}))).ToList();
|
||||
obj.People = (await Task.WhenAll(obj.People.Select(async x =>
|
||||
obj.GenreLinks = (await Task.WhenAll(obj.GenreLinks.Select(async x =>
|
||||
{
|
||||
using IServiceScope serviceScope = _serviceProvider.CreateScope();
|
||||
IGenreRepository genres = serviceScope.ServiceProvider.GetService<IGenreRepository>();
|
||||
|
||||
x.GenreID = await genres.CreateIfNotExists(x.Genre);
|
||||
return x;
|
||||
}))).ToList();
|
||||
}
|
||||
|
||||
if (obj.People != null)
|
||||
{
|
||||
x.PeopleID = await _people.CreateIfNotExists(x.People);
|
||||
return x;
|
||||
}))).ToList();
|
||||
obj.ExternalIDs = (await Task.WhenAll(obj.ExternalIDs.Select(async x =>
|
||||
obj.People = (await Task.WhenAll(obj.People.Select(async x =>
|
||||
{
|
||||
using IServiceScope serviceScope = _serviceProvider.CreateScope();
|
||||
IPeopleRepository people = serviceScope.ServiceProvider.GetService<IPeopleRepository>();
|
||||
|
||||
x.PeopleID = await people.CreateIfNotExists(x.People);
|
||||
return x;
|
||||
}))).ToList();
|
||||
}
|
||||
|
||||
if (obj.ExternalIDs != null)
|
||||
{
|
||||
x.ProviderID = await _providers.CreateIfNotExists(x.Provider);
|
||||
return x;
|
||||
}))).ToList();
|
||||
obj.ExternalIDs = (await Task.WhenAll(obj.ExternalIDs.Select(async x =>
|
||||
{
|
||||
using IServiceScope serviceScope = _serviceProvider.CreateScope();
|
||||
IProviderRepository providers = serviceScope.ServiceProvider.GetService<IProviderRepository>();
|
||||
|
||||
x.ProviderID = await providers.CreateIfNotExists(x.Provider);
|
||||
return x;
|
||||
}))).ToList();
|
||||
}
|
||||
}
|
||||
|
||||
public async Task Delete(Show show)
|
||||
@ -127,7 +140,7 @@ namespace Kyoo.Controllers
|
||||
await _database.SaveChangesAsync();
|
||||
}
|
||||
|
||||
public Task AddShowLink(long showID, long? libraryID, long? collectionID)
|
||||
public async Task AddShowLink(int showID, int? libraryID, int? collectionID)
|
||||
{
|
||||
if (collectionID != null)
|
||||
{
|
||||
@ -147,7 +160,7 @@ namespace Kyoo.Controllers
|
||||
x => x.LibraryID == libraryID && x.CollectionID == collectionID && x.ShowID == null);
|
||||
}
|
||||
|
||||
return Task.CompletedTask;
|
||||
await _database.SaveChangesAsync();
|
||||
}
|
||||
}
|
||||
}
|
@ -18,7 +18,7 @@ namespace Kyoo.Controllers
|
||||
_database = database;
|
||||
}
|
||||
|
||||
public async Task<Studio> Get(long id)
|
||||
public async Task<Studio> Get(int id)
|
||||
{
|
||||
return await _database.Studios.FirstOrDefaultAsync(x => x.ID == id);
|
||||
}
|
||||
@ -41,7 +41,7 @@ namespace Kyoo.Controllers
|
||||
return await _database.Studios.ToListAsync();
|
||||
}
|
||||
|
||||
public async Task<long> Create(Studio obj)
|
||||
public async Task<int> Create(Studio obj)
|
||||
{
|
||||
if (obj == null)
|
||||
throw new ArgumentNullException(nameof(obj));
|
||||
@ -51,7 +51,7 @@ namespace Kyoo.Controllers
|
||||
return obj.ID;
|
||||
}
|
||||
|
||||
public async Task<long> CreateIfNotExists(Studio obj)
|
||||
public async Task<int> CreateIfNotExists(Studio obj)
|
||||
{
|
||||
if (obj == null)
|
||||
throw new ArgumentNullException(nameof(obj));
|
||||
|
@ -17,7 +17,7 @@ namespace Kyoo.Controllers
|
||||
_database = database;
|
||||
}
|
||||
|
||||
public async Task<Track> Get(long id)
|
||||
public async Task<Track> Get(int id)
|
||||
{
|
||||
return await _database.Tracks.FirstOrDefaultAsync(x => x.ID == id);
|
||||
}
|
||||
@ -27,7 +27,7 @@ namespace Kyoo.Controllers
|
||||
throw new InvalidOperationException("Tracks do not support the get by slug method.");
|
||||
}
|
||||
|
||||
public Task<Track> Get(long episodeID, string languageTag, bool isForced)
|
||||
public Task<Track> Get(int episodeID, string languageTag, bool isForced)
|
||||
{
|
||||
return _database.Tracks.FirstOrDefaultAsync(x => x.EpisodeID == episodeID
|
||||
&& x.Language == languageTag
|
||||
@ -44,7 +44,7 @@ namespace Kyoo.Controllers
|
||||
return await _database.Tracks.ToListAsync();
|
||||
}
|
||||
|
||||
public async Task<long> Create(Track obj)
|
||||
public async Task<int> Create(Track obj)
|
||||
{
|
||||
if (obj == null)
|
||||
throw new ArgumentNullException(nameof(obj));
|
||||
@ -58,7 +58,7 @@ namespace Kyoo.Controllers
|
||||
return obj.ID;
|
||||
}
|
||||
|
||||
public Task<long> CreateIfNotExists(Track obj)
|
||||
public Task<int> CreateIfNotExists(Track obj)
|
||||
{
|
||||
return Create(obj);
|
||||
}
|
||||
|
@ -10,7 +10,7 @@ using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||
namespace Kyoo.Models.DatabaseMigrations.Internal
|
||||
{
|
||||
[DbContext(typeof(DatabaseContext))]
|
||||
[Migration("20200526235513_Initial")]
|
||||
[Migration("20200607010830_Initial")]
|
||||
partial class Initial
|
||||
{
|
||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||
@ -23,9 +23,9 @@ namespace Kyoo.Models.DatabaseMigrations.Internal
|
||||
|
||||
modelBuilder.Entity("Kyoo.Models.Collection", b =>
|
||||
{
|
||||
b.Property<long>("ID")
|
||||
b.Property<int>("ID")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("bigint")
|
||||
.HasColumnType("integer")
|
||||
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
|
||||
|
||||
b.Property<string>("ImgPrimary")
|
||||
@ -53,16 +53,16 @@ namespace Kyoo.Models.DatabaseMigrations.Internal
|
||||
|
||||
modelBuilder.Entity("Kyoo.Models.CollectionLink", b =>
|
||||
{
|
||||
b.Property<long>("ID")
|
||||
b.Property<int>("ID")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("bigint")
|
||||
.HasColumnType("integer")
|
||||
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
|
||||
|
||||
b.Property<long?>("CollectionID")
|
||||
.HasColumnType("bigint");
|
||||
b.Property<int?>("CollectionID")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<long>("ShowID")
|
||||
.HasColumnType("bigint");
|
||||
b.Property<int>("ShowID")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("ID");
|
||||
|
||||
@ -75,16 +75,16 @@ namespace Kyoo.Models.DatabaseMigrations.Internal
|
||||
|
||||
modelBuilder.Entity("Kyoo.Models.Episode", b =>
|
||||
{
|
||||
b.Property<long>("ID")
|
||||
b.Property<int>("ID")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("bigint")
|
||||
.HasColumnType("integer")
|
||||
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
|
||||
|
||||
b.Property<long>("AbsoluteNumber")
|
||||
.HasColumnType("bigint");
|
||||
b.Property<int>("AbsoluteNumber")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<long>("EpisodeNumber")
|
||||
.HasColumnType("bigint");
|
||||
b.Property<int>("EpisodeNumber")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<string>("ImgPrimary")
|
||||
.HasColumnType("text");
|
||||
@ -98,17 +98,17 @@ namespace Kyoo.Models.DatabaseMigrations.Internal
|
||||
b.Property<DateTime?>("ReleaseDate")
|
||||
.HasColumnType("timestamp without time zone");
|
||||
|
||||
b.Property<long>("Runtime")
|
||||
.HasColumnType("bigint");
|
||||
b.Property<int>("Runtime")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<long?>("SeasonID")
|
||||
.HasColumnType("bigint");
|
||||
b.Property<int?>("SeasonID")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<long>("SeasonNumber")
|
||||
.HasColumnType("bigint");
|
||||
b.Property<int>("SeasonNumber")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<long>("ShowID")
|
||||
.HasColumnType("bigint");
|
||||
b.Property<int>("ShowID")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<string>("Title")
|
||||
.HasColumnType("text");
|
||||
@ -124,9 +124,9 @@ namespace Kyoo.Models.DatabaseMigrations.Internal
|
||||
|
||||
modelBuilder.Entity("Kyoo.Models.Genre", b =>
|
||||
{
|
||||
b.Property<long>("ID")
|
||||
b.Property<int>("ID")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("bigint")
|
||||
.HasColumnType("integer")
|
||||
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
|
||||
|
||||
b.Property<string>("Name")
|
||||
@ -145,11 +145,11 @@ namespace Kyoo.Models.DatabaseMigrations.Internal
|
||||
|
||||
modelBuilder.Entity("Kyoo.Models.GenreLink", b =>
|
||||
{
|
||||
b.Property<long>("ShowID")
|
||||
.HasColumnType("bigint");
|
||||
b.Property<int>("ShowID")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<long>("GenreID")
|
||||
.HasColumnType("bigint");
|
||||
b.Property<int>("GenreID")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("ShowID", "GenreID");
|
||||
|
||||
@ -160,9 +160,9 @@ namespace Kyoo.Models.DatabaseMigrations.Internal
|
||||
|
||||
modelBuilder.Entity("Kyoo.Models.Library", b =>
|
||||
{
|
||||
b.Property<long>("ID")
|
||||
b.Property<int>("ID")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("bigint")
|
||||
.HasColumnType("integer")
|
||||
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
|
||||
|
||||
b.Property<string>("Name")
|
||||
@ -184,19 +184,19 @@ namespace Kyoo.Models.DatabaseMigrations.Internal
|
||||
|
||||
modelBuilder.Entity("Kyoo.Models.LibraryLink", b =>
|
||||
{
|
||||
b.Property<long>("ID")
|
||||
b.Property<int>("ID")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("bigint")
|
||||
.HasColumnType("integer")
|
||||
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
|
||||
|
||||
b.Property<long?>("CollectionID")
|
||||
.HasColumnType("bigint");
|
||||
b.Property<int?>("CollectionID")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<long>("LibraryID")
|
||||
.HasColumnType("bigint");
|
||||
b.Property<int>("LibraryID")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<long?>("ShowID")
|
||||
.HasColumnType("bigint");
|
||||
b.Property<int?>("ShowID")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("ID");
|
||||
|
||||
@ -211,31 +211,31 @@ namespace Kyoo.Models.DatabaseMigrations.Internal
|
||||
|
||||
modelBuilder.Entity("Kyoo.Models.MetadataID", b =>
|
||||
{
|
||||
b.Property<long>("ID")
|
||||
b.Property<int>("ID")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("bigint")
|
||||
.HasColumnType("integer")
|
||||
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
|
||||
|
||||
b.Property<string>("DataID")
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<long?>("EpisodeID")
|
||||
.HasColumnType("bigint");
|
||||
b.Property<int?>("EpisodeID")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<string>("Link")
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<long?>("PeopleID")
|
||||
.HasColumnType("bigint");
|
||||
b.Property<int?>("PeopleID")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<long>("ProviderID")
|
||||
.HasColumnType("bigint");
|
||||
b.Property<int>("ProviderID")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<long?>("SeasonID")
|
||||
.HasColumnType("bigint");
|
||||
b.Property<int?>("SeasonID")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<long?>("ShowID")
|
||||
.HasColumnType("bigint");
|
||||
b.Property<int?>("ShowID")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("ID");
|
||||
|
||||
@ -254,9 +254,9 @@ namespace Kyoo.Models.DatabaseMigrations.Internal
|
||||
|
||||
modelBuilder.Entity("Kyoo.Models.People", b =>
|
||||
{
|
||||
b.Property<long>("ID")
|
||||
b.Property<int>("ID")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("bigint")
|
||||
.HasColumnType("integer")
|
||||
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
|
||||
|
||||
b.Property<string>("ImgPrimary")
|
||||
@ -278,19 +278,19 @@ namespace Kyoo.Models.DatabaseMigrations.Internal
|
||||
|
||||
modelBuilder.Entity("Kyoo.Models.PeopleLink", b =>
|
||||
{
|
||||
b.Property<long>("ID")
|
||||
b.Property<int>("ID")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("bigint")
|
||||
.HasColumnType("integer")
|
||||
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
|
||||
|
||||
b.Property<long>("PeopleID")
|
||||
.HasColumnType("bigint");
|
||||
b.Property<int>("PeopleID")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<string>("Role")
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<long>("ShowID")
|
||||
.HasColumnType("bigint");
|
||||
b.Property<int>("ShowID")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<string>("Type")
|
||||
.HasColumnType("text");
|
||||
@ -306,9 +306,9 @@ namespace Kyoo.Models.DatabaseMigrations.Internal
|
||||
|
||||
modelBuilder.Entity("Kyoo.Models.ProviderID", b =>
|
||||
{
|
||||
b.Property<long>("ID")
|
||||
b.Property<int>("ID")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("bigint")
|
||||
.HasColumnType("integer")
|
||||
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
|
||||
|
||||
b.Property<string>("Logo")
|
||||
@ -327,16 +327,16 @@ namespace Kyoo.Models.DatabaseMigrations.Internal
|
||||
|
||||
modelBuilder.Entity("Kyoo.Models.ProviderLink", b =>
|
||||
{
|
||||
b.Property<long>("ID")
|
||||
b.Property<int>("ID")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("bigint")
|
||||
.HasColumnType("integer")
|
||||
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
|
||||
|
||||
b.Property<long?>("LibraryID")
|
||||
.HasColumnType("bigint");
|
||||
b.Property<int?>("LibraryID")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<long>("ProviderID")
|
||||
.HasColumnType("bigint");
|
||||
b.Property<int>("ProviderID")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("ID");
|
||||
|
||||
@ -349,9 +349,9 @@ namespace Kyoo.Models.DatabaseMigrations.Internal
|
||||
|
||||
modelBuilder.Entity("Kyoo.Models.Season", b =>
|
||||
{
|
||||
b.Property<long>("ID")
|
||||
b.Property<int>("ID")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("bigint")
|
||||
.HasColumnType("integer")
|
||||
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
|
||||
|
||||
b.Property<string>("ImgPrimary")
|
||||
@ -360,17 +360,17 @@ namespace Kyoo.Models.DatabaseMigrations.Internal
|
||||
b.Property<string>("Overview")
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<long>("SeasonNumber")
|
||||
.HasColumnType("bigint");
|
||||
b.Property<int>("SeasonNumber")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<long>("ShowID")
|
||||
.HasColumnType("bigint");
|
||||
b.Property<int>("ShowID")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<string>("Title")
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<long?>("Year")
|
||||
.HasColumnType("bigint");
|
||||
b.Property<int?>("Year")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("ID");
|
||||
|
||||
@ -381,9 +381,9 @@ namespace Kyoo.Models.DatabaseMigrations.Internal
|
||||
|
||||
modelBuilder.Entity("Kyoo.Models.Show", b =>
|
||||
{
|
||||
b.Property<long>("ID")
|
||||
b.Property<int>("ID")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("bigint")
|
||||
.HasColumnType("integer")
|
||||
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
|
||||
|
||||
b.Property<string>("Aliases")
|
||||
@ -392,8 +392,8 @@ namespace Kyoo.Models.DatabaseMigrations.Internal
|
||||
b.Property<string>("Backdrop")
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<long?>("EndYear")
|
||||
.HasColumnType("bigint");
|
||||
b.Property<int?>("EndYear")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<bool>("IsMovie")
|
||||
.HasColumnType("boolean");
|
||||
@ -413,14 +413,14 @@ namespace Kyoo.Models.DatabaseMigrations.Internal
|
||||
b.Property<string>("Slug")
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<long?>("StartYear")
|
||||
.HasColumnType("bigint");
|
||||
b.Property<int?>("StartYear")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int?>("Status")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<long?>("StudioID")
|
||||
.HasColumnType("bigint");
|
||||
b.Property<int?>("StudioID")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<string>("Title")
|
||||
.HasColumnType("text");
|
||||
@ -440,9 +440,9 @@ namespace Kyoo.Models.DatabaseMigrations.Internal
|
||||
|
||||
modelBuilder.Entity("Kyoo.Models.Studio", b =>
|
||||
{
|
||||
b.Property<long>("ID")
|
||||
b.Property<int>("ID")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("bigint")
|
||||
.HasColumnType("integer")
|
||||
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
|
||||
|
||||
b.Property<string>("Name")
|
||||
@ -461,16 +461,16 @@ namespace Kyoo.Models.DatabaseMigrations.Internal
|
||||
|
||||
modelBuilder.Entity("Kyoo.Models.Track", b =>
|
||||
{
|
||||
b.Property<long>("ID")
|
||||
b.Property<int>("ID")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("bigint")
|
||||
.HasColumnType("integer")
|
||||
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
|
||||
|
||||
b.Property<string>("Codec")
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<long>("EpisodeID")
|
||||
.HasColumnType("bigint");
|
||||
b.Property<int>("EpisodeID")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<bool>("IsDefault")
|
||||
.HasColumnType("boolean");
|
@ -12,7 +12,7 @@ namespace Kyoo.Models.DatabaseMigrations.Internal
|
||||
name: "Collections",
|
||||
columns: table => new
|
||||
{
|
||||
ID = table.Column<long>(nullable: false)
|
||||
ID = table.Column<int>(nullable: false)
|
||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||
Slug = table.Column<string>(nullable: true),
|
||||
Name = table.Column<string>(nullable: true),
|
||||
@ -29,7 +29,7 @@ namespace Kyoo.Models.DatabaseMigrations.Internal
|
||||
name: "Genres",
|
||||
columns: table => new
|
||||
{
|
||||
ID = table.Column<long>(nullable: false)
|
||||
ID = table.Column<int>(nullable: false)
|
||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||
Slug = table.Column<string>(nullable: true),
|
||||
Name = table.Column<string>(nullable: true)
|
||||
@ -43,7 +43,7 @@ namespace Kyoo.Models.DatabaseMigrations.Internal
|
||||
name: "Libraries",
|
||||
columns: table => new
|
||||
{
|
||||
ID = table.Column<long>(nullable: false)
|
||||
ID = table.Column<int>(nullable: false)
|
||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||
Slug = table.Column<string>(nullable: true),
|
||||
Name = table.Column<string>(nullable: true),
|
||||
@ -58,7 +58,7 @@ namespace Kyoo.Models.DatabaseMigrations.Internal
|
||||
name: "Peoples",
|
||||
columns: table => new
|
||||
{
|
||||
ID = table.Column<long>(nullable: false)
|
||||
ID = table.Column<int>(nullable: false)
|
||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||
Slug = table.Column<string>(nullable: true),
|
||||
Name = table.Column<string>(nullable: true),
|
||||
@ -73,7 +73,7 @@ namespace Kyoo.Models.DatabaseMigrations.Internal
|
||||
name: "Providers",
|
||||
columns: table => new
|
||||
{
|
||||
ID = table.Column<long>(nullable: false)
|
||||
ID = table.Column<int>(nullable: false)
|
||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||
Name = table.Column<string>(nullable: true),
|
||||
Logo = table.Column<string>(nullable: true)
|
||||
@ -87,7 +87,7 @@ namespace Kyoo.Models.DatabaseMigrations.Internal
|
||||
name: "Studios",
|
||||
columns: table => new
|
||||
{
|
||||
ID = table.Column<long>(nullable: false)
|
||||
ID = table.Column<int>(nullable: false)
|
||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||
Slug = table.Column<string>(nullable: true),
|
||||
Name = table.Column<string>(nullable: true)
|
||||
@ -101,10 +101,10 @@ namespace Kyoo.Models.DatabaseMigrations.Internal
|
||||
name: "ProviderLinks",
|
||||
columns: table => new
|
||||
{
|
||||
ID = table.Column<long>(nullable: false)
|
||||
ID = table.Column<int>(nullable: false)
|
||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||
ProviderID = table.Column<long>(nullable: false),
|
||||
LibraryID = table.Column<long>(nullable: true)
|
||||
ProviderID = table.Column<int>(nullable: false),
|
||||
LibraryID = table.Column<int>(nullable: true)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
@ -127,7 +127,7 @@ namespace Kyoo.Models.DatabaseMigrations.Internal
|
||||
name: "Shows",
|
||||
columns: table => new
|
||||
{
|
||||
ID = table.Column<long>(nullable: false)
|
||||
ID = table.Column<int>(nullable: false)
|
||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||
Slug = table.Column<string>(nullable: true),
|
||||
Title = table.Column<string>(nullable: true),
|
||||
@ -136,13 +136,13 @@ namespace Kyoo.Models.DatabaseMigrations.Internal
|
||||
Overview = table.Column<string>(nullable: true),
|
||||
Status = table.Column<int>(nullable: true),
|
||||
TrailerUrl = table.Column<string>(nullable: true),
|
||||
StartYear = table.Column<long>(nullable: true),
|
||||
EndYear = table.Column<long>(nullable: true),
|
||||
StartYear = table.Column<int>(nullable: true),
|
||||
EndYear = table.Column<int>(nullable: true),
|
||||
Poster = table.Column<string>(nullable: true),
|
||||
Logo = table.Column<string>(nullable: true),
|
||||
Backdrop = table.Column<string>(nullable: true),
|
||||
IsMovie = table.Column<bool>(nullable: false),
|
||||
StudioID = table.Column<long>(nullable: true)
|
||||
StudioID = table.Column<int>(nullable: true)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
@ -159,10 +159,10 @@ namespace Kyoo.Models.DatabaseMigrations.Internal
|
||||
name: "CollectionLinks",
|
||||
columns: table => new
|
||||
{
|
||||
ID = table.Column<long>(nullable: false)
|
||||
ID = table.Column<int>(nullable: false)
|
||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||
CollectionID = table.Column<long>(nullable: true),
|
||||
ShowID = table.Column<long>(nullable: false)
|
||||
CollectionID = table.Column<int>(nullable: true),
|
||||
ShowID = table.Column<int>(nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
@ -185,8 +185,8 @@ namespace Kyoo.Models.DatabaseMigrations.Internal
|
||||
name: "GenreLinks",
|
||||
columns: table => new
|
||||
{
|
||||
ShowID = table.Column<long>(nullable: false),
|
||||
GenreID = table.Column<long>(nullable: false)
|
||||
ShowID = table.Column<int>(nullable: false),
|
||||
GenreID = table.Column<int>(nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
@ -209,11 +209,11 @@ namespace Kyoo.Models.DatabaseMigrations.Internal
|
||||
name: "LibraryLinks",
|
||||
columns: table => new
|
||||
{
|
||||
ID = table.Column<long>(nullable: false)
|
||||
ID = table.Column<int>(nullable: false)
|
||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||
LibraryID = table.Column<long>(nullable: false),
|
||||
ShowID = table.Column<long>(nullable: true),
|
||||
CollectionID = table.Column<long>(nullable: true)
|
||||
LibraryID = table.Column<int>(nullable: false),
|
||||
ShowID = table.Column<int>(nullable: true),
|
||||
CollectionID = table.Column<int>(nullable: true)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
@ -242,10 +242,10 @@ namespace Kyoo.Models.DatabaseMigrations.Internal
|
||||
name: "PeopleLinks",
|
||||
columns: table => new
|
||||
{
|
||||
ID = table.Column<long>(nullable: false)
|
||||
ID = table.Column<int>(nullable: false)
|
||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||
PeopleID = table.Column<long>(nullable: false),
|
||||
ShowID = table.Column<long>(nullable: false),
|
||||
PeopleID = table.Column<int>(nullable: false),
|
||||
ShowID = table.Column<int>(nullable: false),
|
||||
Role = table.Column<string>(nullable: true),
|
||||
Type = table.Column<string>(nullable: true)
|
||||
},
|
||||
@ -270,13 +270,13 @@ namespace Kyoo.Models.DatabaseMigrations.Internal
|
||||
name: "Seasons",
|
||||
columns: table => new
|
||||
{
|
||||
ID = table.Column<long>(nullable: false)
|
||||
ID = table.Column<int>(nullable: false)
|
||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||
ShowID = table.Column<long>(nullable: false),
|
||||
SeasonNumber = table.Column<long>(nullable: false),
|
||||
ShowID = table.Column<int>(nullable: false),
|
||||
SeasonNumber = table.Column<int>(nullable: false),
|
||||
Title = table.Column<string>(nullable: true),
|
||||
Overview = table.Column<string>(nullable: true),
|
||||
Year = table.Column<long>(nullable: true),
|
||||
Year = table.Column<int>(nullable: true),
|
||||
ImgPrimary = table.Column<string>(nullable: true)
|
||||
},
|
||||
constraints: table =>
|
||||
@ -294,18 +294,18 @@ namespace Kyoo.Models.DatabaseMigrations.Internal
|
||||
name: "Episodes",
|
||||
columns: table => new
|
||||
{
|
||||
ID = table.Column<long>(nullable: false)
|
||||
ID = table.Column<int>(nullable: false)
|
||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||
ShowID = table.Column<long>(nullable: false),
|
||||
SeasonID = table.Column<long>(nullable: true),
|
||||
SeasonNumber = table.Column<long>(nullable: false),
|
||||
EpisodeNumber = table.Column<long>(nullable: false),
|
||||
AbsoluteNumber = table.Column<long>(nullable: false),
|
||||
ShowID = table.Column<int>(nullable: false),
|
||||
SeasonID = table.Column<int>(nullable: true),
|
||||
SeasonNumber = table.Column<int>(nullable: false),
|
||||
EpisodeNumber = table.Column<int>(nullable: false),
|
||||
AbsoluteNumber = table.Column<int>(nullable: false),
|
||||
Path = table.Column<string>(nullable: true),
|
||||
Title = table.Column<string>(nullable: true),
|
||||
Overview = table.Column<string>(nullable: true),
|
||||
ReleaseDate = table.Column<DateTime>(nullable: true),
|
||||
Runtime = table.Column<long>(nullable: false),
|
||||
Runtime = table.Column<int>(nullable: false),
|
||||
ImgPrimary = table.Column<string>(nullable: true)
|
||||
},
|
||||
constraints: table =>
|
||||
@ -329,13 +329,13 @@ namespace Kyoo.Models.DatabaseMigrations.Internal
|
||||
name: "MetadataIds",
|
||||
columns: table => new
|
||||
{
|
||||
ID = table.Column<long>(nullable: false)
|
||||
ID = table.Column<int>(nullable: false)
|
||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||
ProviderID = table.Column<long>(nullable: false),
|
||||
ShowID = table.Column<long>(nullable: true),
|
||||
EpisodeID = table.Column<long>(nullable: true),
|
||||
SeasonID = table.Column<long>(nullable: true),
|
||||
PeopleID = table.Column<long>(nullable: true),
|
||||
ProviderID = table.Column<int>(nullable: false),
|
||||
ShowID = table.Column<int>(nullable: true),
|
||||
EpisodeID = table.Column<int>(nullable: true),
|
||||
SeasonID = table.Column<int>(nullable: true),
|
||||
PeopleID = table.Column<int>(nullable: true),
|
||||
DataID = table.Column<string>(nullable: true),
|
||||
Link = table.Column<string>(nullable: true)
|
||||
},
|
||||
@ -378,14 +378,14 @@ namespace Kyoo.Models.DatabaseMigrations.Internal
|
||||
name: "Tracks",
|
||||
columns: table => new
|
||||
{
|
||||
ID = table.Column<long>(nullable: false)
|
||||
ID = table.Column<int>(nullable: false)
|
||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||
Title = table.Column<string>(nullable: true),
|
||||
Language = table.Column<string>(nullable: true),
|
||||
Codec = table.Column<string>(nullable: true),
|
||||
Path = table.Column<string>(nullable: true),
|
||||
Type = table.Column<int>(nullable: false),
|
||||
EpisodeID = table.Column<long>(nullable: false),
|
||||
EpisodeID = table.Column<int>(nullable: false),
|
||||
IsDefault = table.Column<bool>(nullable: false),
|
||||
IsForced = table.Column<bool>(nullable: false),
|
||||
IsExternal = table.Column<bool>(nullable: false)
|
@ -21,9 +21,9 @@ namespace Kyoo.Models.DatabaseMigrations.Internal
|
||||
|
||||
modelBuilder.Entity("Kyoo.Models.Collection", b =>
|
||||
{
|
||||
b.Property<long>("ID")
|
||||
b.Property<int>("ID")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("bigint")
|
||||
.HasColumnType("integer")
|
||||
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
|
||||
|
||||
b.Property<string>("ImgPrimary")
|
||||
@ -51,16 +51,16 @@ namespace Kyoo.Models.DatabaseMigrations.Internal
|
||||
|
||||
modelBuilder.Entity("Kyoo.Models.CollectionLink", b =>
|
||||
{
|
||||
b.Property<long>("ID")
|
||||
b.Property<int>("ID")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("bigint")
|
||||
.HasColumnType("integer")
|
||||
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
|
||||
|
||||
b.Property<long?>("CollectionID")
|
||||
.HasColumnType("bigint");
|
||||
b.Property<int?>("CollectionID")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<long>("ShowID")
|
||||
.HasColumnType("bigint");
|
||||
b.Property<int>("ShowID")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("ID");
|
||||
|
||||
@ -73,16 +73,16 @@ namespace Kyoo.Models.DatabaseMigrations.Internal
|
||||
|
||||
modelBuilder.Entity("Kyoo.Models.Episode", b =>
|
||||
{
|
||||
b.Property<long>("ID")
|
||||
b.Property<int>("ID")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("bigint")
|
||||
.HasColumnType("integer")
|
||||
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
|
||||
|
||||
b.Property<long>("AbsoluteNumber")
|
||||
.HasColumnType("bigint");
|
||||
b.Property<int>("AbsoluteNumber")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<long>("EpisodeNumber")
|
||||
.HasColumnType("bigint");
|
||||
b.Property<int>("EpisodeNumber")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<string>("ImgPrimary")
|
||||
.HasColumnType("text");
|
||||
@ -96,17 +96,17 @@ namespace Kyoo.Models.DatabaseMigrations.Internal
|
||||
b.Property<DateTime?>("ReleaseDate")
|
||||
.HasColumnType("timestamp without time zone");
|
||||
|
||||
b.Property<long>("Runtime")
|
||||
.HasColumnType("bigint");
|
||||
b.Property<int>("Runtime")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<long?>("SeasonID")
|
||||
.HasColumnType("bigint");
|
||||
b.Property<int?>("SeasonID")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<long>("SeasonNumber")
|
||||
.HasColumnType("bigint");
|
||||
b.Property<int>("SeasonNumber")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<long>("ShowID")
|
||||
.HasColumnType("bigint");
|
||||
b.Property<int>("ShowID")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<string>("Title")
|
||||
.HasColumnType("text");
|
||||
@ -122,9 +122,9 @@ namespace Kyoo.Models.DatabaseMigrations.Internal
|
||||
|
||||
modelBuilder.Entity("Kyoo.Models.Genre", b =>
|
||||
{
|
||||
b.Property<long>("ID")
|
||||
b.Property<int>("ID")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("bigint")
|
||||
.HasColumnType("integer")
|
||||
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
|
||||
|
||||
b.Property<string>("Name")
|
||||
@ -143,11 +143,11 @@ namespace Kyoo.Models.DatabaseMigrations.Internal
|
||||
|
||||
modelBuilder.Entity("Kyoo.Models.GenreLink", b =>
|
||||
{
|
||||
b.Property<long>("ShowID")
|
||||
.HasColumnType("bigint");
|
||||
b.Property<int>("ShowID")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<long>("GenreID")
|
||||
.HasColumnType("bigint");
|
||||
b.Property<int>("GenreID")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("ShowID", "GenreID");
|
||||
|
||||
@ -158,9 +158,9 @@ namespace Kyoo.Models.DatabaseMigrations.Internal
|
||||
|
||||
modelBuilder.Entity("Kyoo.Models.Library", b =>
|
||||
{
|
||||
b.Property<long>("ID")
|
||||
b.Property<int>("ID")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("bigint")
|
||||
.HasColumnType("integer")
|
||||
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
|
||||
|
||||
b.Property<string>("Name")
|
||||
@ -182,19 +182,19 @@ namespace Kyoo.Models.DatabaseMigrations.Internal
|
||||
|
||||
modelBuilder.Entity("Kyoo.Models.LibraryLink", b =>
|
||||
{
|
||||
b.Property<long>("ID")
|
||||
b.Property<int>("ID")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("bigint")
|
||||
.HasColumnType("integer")
|
||||
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
|
||||
|
||||
b.Property<long?>("CollectionID")
|
||||
.HasColumnType("bigint");
|
||||
b.Property<int?>("CollectionID")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<long>("LibraryID")
|
||||
.HasColumnType("bigint");
|
||||
b.Property<int>("LibraryID")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<long?>("ShowID")
|
||||
.HasColumnType("bigint");
|
||||
b.Property<int?>("ShowID")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("ID");
|
||||
|
||||
@ -209,31 +209,31 @@ namespace Kyoo.Models.DatabaseMigrations.Internal
|
||||
|
||||
modelBuilder.Entity("Kyoo.Models.MetadataID", b =>
|
||||
{
|
||||
b.Property<long>("ID")
|
||||
b.Property<int>("ID")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("bigint")
|
||||
.HasColumnType("integer")
|
||||
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
|
||||
|
||||
b.Property<string>("DataID")
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<long?>("EpisodeID")
|
||||
.HasColumnType("bigint");
|
||||
b.Property<int?>("EpisodeID")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<string>("Link")
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<long?>("PeopleID")
|
||||
.HasColumnType("bigint");
|
||||
b.Property<int?>("PeopleID")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<long>("ProviderID")
|
||||
.HasColumnType("bigint");
|
||||
b.Property<int>("ProviderID")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<long?>("SeasonID")
|
||||
.HasColumnType("bigint");
|
||||
b.Property<int?>("SeasonID")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<long?>("ShowID")
|
||||
.HasColumnType("bigint");
|
||||
b.Property<int?>("ShowID")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("ID");
|
||||
|
||||
@ -252,9 +252,9 @@ namespace Kyoo.Models.DatabaseMigrations.Internal
|
||||
|
||||
modelBuilder.Entity("Kyoo.Models.People", b =>
|
||||
{
|
||||
b.Property<long>("ID")
|
||||
b.Property<int>("ID")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("bigint")
|
||||
.HasColumnType("integer")
|
||||
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
|
||||
|
||||
b.Property<string>("ImgPrimary")
|
||||
@ -276,19 +276,19 @@ namespace Kyoo.Models.DatabaseMigrations.Internal
|
||||
|
||||
modelBuilder.Entity("Kyoo.Models.PeopleLink", b =>
|
||||
{
|
||||
b.Property<long>("ID")
|
||||
b.Property<int>("ID")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("bigint")
|
||||
.HasColumnType("integer")
|
||||
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
|
||||
|
||||
b.Property<long>("PeopleID")
|
||||
.HasColumnType("bigint");
|
||||
b.Property<int>("PeopleID")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<string>("Role")
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<long>("ShowID")
|
||||
.HasColumnType("bigint");
|
||||
b.Property<int>("ShowID")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<string>("Type")
|
||||
.HasColumnType("text");
|
||||
@ -304,9 +304,9 @@ namespace Kyoo.Models.DatabaseMigrations.Internal
|
||||
|
||||
modelBuilder.Entity("Kyoo.Models.ProviderID", b =>
|
||||
{
|
||||
b.Property<long>("ID")
|
||||
b.Property<int>("ID")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("bigint")
|
||||
.HasColumnType("integer")
|
||||
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
|
||||
|
||||
b.Property<string>("Logo")
|
||||
@ -325,16 +325,16 @@ namespace Kyoo.Models.DatabaseMigrations.Internal
|
||||
|
||||
modelBuilder.Entity("Kyoo.Models.ProviderLink", b =>
|
||||
{
|
||||
b.Property<long>("ID")
|
||||
b.Property<int>("ID")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("bigint")
|
||||
.HasColumnType("integer")
|
||||
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
|
||||
|
||||
b.Property<long?>("LibraryID")
|
||||
.HasColumnType("bigint");
|
||||
b.Property<int?>("LibraryID")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<long>("ProviderID")
|
||||
.HasColumnType("bigint");
|
||||
b.Property<int>("ProviderID")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("ID");
|
||||
|
||||
@ -347,9 +347,9 @@ namespace Kyoo.Models.DatabaseMigrations.Internal
|
||||
|
||||
modelBuilder.Entity("Kyoo.Models.Season", b =>
|
||||
{
|
||||
b.Property<long>("ID")
|
||||
b.Property<int>("ID")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("bigint")
|
||||
.HasColumnType("integer")
|
||||
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
|
||||
|
||||
b.Property<string>("ImgPrimary")
|
||||
@ -358,17 +358,17 @@ namespace Kyoo.Models.DatabaseMigrations.Internal
|
||||
b.Property<string>("Overview")
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<long>("SeasonNumber")
|
||||
.HasColumnType("bigint");
|
||||
b.Property<int>("SeasonNumber")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<long>("ShowID")
|
||||
.HasColumnType("bigint");
|
||||
b.Property<int>("ShowID")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<string>("Title")
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<long?>("Year")
|
||||
.HasColumnType("bigint");
|
||||
b.Property<int?>("Year")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("ID");
|
||||
|
||||
@ -379,9 +379,9 @@ namespace Kyoo.Models.DatabaseMigrations.Internal
|
||||
|
||||
modelBuilder.Entity("Kyoo.Models.Show", b =>
|
||||
{
|
||||
b.Property<long>("ID")
|
||||
b.Property<int>("ID")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("bigint")
|
||||
.HasColumnType("integer")
|
||||
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
|
||||
|
||||
b.Property<string>("Aliases")
|
||||
@ -390,8 +390,8 @@ namespace Kyoo.Models.DatabaseMigrations.Internal
|
||||
b.Property<string>("Backdrop")
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<long?>("EndYear")
|
||||
.HasColumnType("bigint");
|
||||
b.Property<int?>("EndYear")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<bool>("IsMovie")
|
||||
.HasColumnType("boolean");
|
||||
@ -411,14 +411,14 @@ namespace Kyoo.Models.DatabaseMigrations.Internal
|
||||
b.Property<string>("Slug")
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<long?>("StartYear")
|
||||
.HasColumnType("bigint");
|
||||
b.Property<int?>("StartYear")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int?>("Status")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<long?>("StudioID")
|
||||
.HasColumnType("bigint");
|
||||
b.Property<int?>("StudioID")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<string>("Title")
|
||||
.HasColumnType("text");
|
||||
@ -438,9 +438,9 @@ namespace Kyoo.Models.DatabaseMigrations.Internal
|
||||
|
||||
modelBuilder.Entity("Kyoo.Models.Studio", b =>
|
||||
{
|
||||
b.Property<long>("ID")
|
||||
b.Property<int>("ID")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("bigint")
|
||||
.HasColumnType("integer")
|
||||
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
|
||||
|
||||
b.Property<string>("Name")
|
||||
@ -459,16 +459,16 @@ namespace Kyoo.Models.DatabaseMigrations.Internal
|
||||
|
||||
modelBuilder.Entity("Kyoo.Models.Track", b =>
|
||||
{
|
||||
b.Property<long>("ID")
|
||||
b.Property<int>("ID")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("bigint")
|
||||
.HasColumnType("integer")
|
||||
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
|
||||
|
||||
b.Property<string>("Codec")
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<long>("EpisodeID")
|
||||
.HasColumnType("bigint");
|
||||
b.Property<int>("EpisodeID")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<bool>("IsDefault")
|
||||
.HasColumnType("boolean");
|
||||
|
@ -137,6 +137,18 @@ namespace Kyoo
|
||||
AllowedOrigins = { new Uri(publicUrl).GetLeftPart(UriPartial.Authority) }
|
||||
});
|
||||
|
||||
|
||||
services.AddTransient<ILibraryRepository, LibraryRepository>();
|
||||
services.AddTransient<ICollectionRepository, CollectionRepository>();
|
||||
services.AddTransient<IShowRepository, ShowRepository>();
|
||||
services.AddTransient<ISeasonRepository, SeasonRepository>();
|
||||
services.AddTransient<IEpisodeRepository, EpisodeRepository>();
|
||||
services.AddTransient<ITrackRepository, TrackRepository>();
|
||||
services.AddTransient<IPeopleRepository, PeopleRepository>();
|
||||
services.AddTransient<IStudioRepository, StudioRepository>();
|
||||
services.AddTransient<IGenreRepository, GenreRepository>();
|
||||
services.AddTransient<IProviderRepository, ProviderRepository>();
|
||||
|
||||
services.AddScoped<ILibraryManager, LibraryManager>();
|
||||
services.AddSingleton<ITranscoder, Transcoder>();
|
||||
services.AddSingleton<IThumbnailsManager, ThumbnailsManager>();
|
||||
|
@ -134,9 +134,9 @@ namespace Kyoo.Controllers
|
||||
string showPath = Path.GetDirectoryName(path);
|
||||
string collectionName = match.Groups["Collection"]?.Value;
|
||||
string showName = match.Groups["ShowTitle"].Value;
|
||||
long seasonNumber = long.TryParse(match.Groups["Season"].Value, out long tmp) ? tmp : -1;
|
||||
long episodeNumber = long.TryParse(match.Groups["Episode"].Value, out tmp) ? tmp : -1;
|
||||
long absoluteNumber = long.TryParse(match.Groups["Absolute"].Value, out tmp) ? tmp : -1;
|
||||
int seasonNumber = int.TryParse(match.Groups["Season"].Value, out int tmp) ? tmp : -1;
|
||||
int episodeNumber = int.TryParse(match.Groups["Episode"].Value, out tmp) ? tmp : -1;
|
||||
int absoluteNumber = int.TryParse(match.Groups["Absolute"].Value, out tmp) ? tmp : -1;
|
||||
|
||||
Collection collection = await GetCollection(libraryManager, collectionName, library);
|
||||
bool isMovie = seasonNumber == -1 && episodeNumber == -1 && absoluteNumber == -1;
|
||||
@ -188,7 +188,7 @@ namespace Kyoo.Controllers
|
||||
|
||||
private async Task<Season> GetSeason(ILibraryManager libraryManager,
|
||||
Show show,
|
||||
long seasonNumber,
|
||||
int seasonNumber,
|
||||
Library library)
|
||||
{
|
||||
if (seasonNumber == -1)
|
||||
@ -207,8 +207,8 @@ namespace Kyoo.Controllers
|
||||
private async Task<Episode> GetEpisode(ILibraryManager libraryManager,
|
||||
Show show,
|
||||
Season season,
|
||||
long episodeNumber,
|
||||
long absoluteNumber,
|
||||
int episodeNumber,
|
||||
int absoluteNumber,
|
||||
string episodePath,
|
||||
Library library)
|
||||
{
|
||||
@ -221,6 +221,7 @@ namespace Kyoo.Controllers
|
||||
|
||||
season ??= await GetSeason(libraryManager, show, episode.SeasonNumber, library);
|
||||
episode.Season = season;
|
||||
episode.SeasonID = season?.ID;
|
||||
if (season == null)
|
||||
{
|
||||
await Console.Error.WriteLineAsync("Error: You don't have any provider that support absolute epiode numbering. Install one and try again.");
|
||||
@ -234,7 +235,13 @@ namespace Kyoo.Controllers
|
||||
|
||||
private async Task<Episode> GetMovie(Show show, string episodePath)
|
||||
{
|
||||
Episode episode = new Episode {Title = show.Title, Path = episodePath, Show = show};
|
||||
Episode episode = new Episode
|
||||
{
|
||||
Title = show.Title,
|
||||
Path = episodePath,
|
||||
Show = show,
|
||||
ShowID = show.ID
|
||||
};
|
||||
episode.Tracks = await GetTracks(episode);
|
||||
return episode;
|
||||
}
|
||||
|
@ -21,7 +21,7 @@ namespace Kyoo.Api
|
||||
|
||||
[HttpGet("{showSlug}/season/{seasonNumber}")]
|
||||
[Authorize(Policy="Read")]
|
||||
public async Task<ActionResult<IEnumerable<Episode>>> GetEpisodesForSeason(string showSlug, long seasonNumber)
|
||||
public async Task<ActionResult<IEnumerable<Episode>>> GetEpisodesForSeason(string showSlug, int seasonNumber)
|
||||
{
|
||||
IEnumerable<Episode> episodes = await _libraryManager.GetEpisodes(showSlug, seasonNumber);
|
||||
|
||||
@ -34,7 +34,7 @@ namespace Kyoo.Api
|
||||
[HttpGet("{showSlug}/season/{seasonNumber}/episode/{episodeNumber}")]
|
||||
[Authorize(Policy="Read")]
|
||||
[JsonDetailed]
|
||||
public async Task<ActionResult<Episode>> GetEpisode(string showSlug, long seasonNumber, long episodeNumber)
|
||||
public async Task<ActionResult<Episode>> GetEpisode(string showSlug, int seasonNumber, int episodeNumber)
|
||||
{
|
||||
Episode episode = await _libraryManager.GetEpisode(showSlug, seasonNumber, episodeNumber);
|
||||
|
||||
|
@ -41,7 +41,7 @@ namespace Kyoo.Api
|
||||
return BadRequest(new {error = "The library's name must be set and not empty"});
|
||||
if (library.Paths == null || !library.Paths.Any())
|
||||
return BadRequest(new {error = "The library should have a least one path."});
|
||||
if (_libraryManager.GetLibrary(library.Slug) != null)
|
||||
if (await _libraryManager.GetLibrary(library.Slug) != null)
|
||||
return BadRequest(new {error = "Duplicated library slug"});
|
||||
await _libraryManager.RegisterLibrary(library);
|
||||
_taskManager.StartTask("scan", library.Slug);
|
||||
|
@ -43,7 +43,7 @@ namespace Kyoo.Api
|
||||
string idString = identifier.IndexOf('-') != -1
|
||||
? identifier.Substring(0, identifier.IndexOf('-'))
|
||||
: identifier;
|
||||
long.TryParse(idString, out long id);
|
||||
int.TryParse(idString, out int id);
|
||||
subtitle = await _libraryManager.GetTrack(id);
|
||||
}
|
||||
|
||||
|
@ -77,7 +77,7 @@ namespace Kyoo.Api
|
||||
|
||||
[HttpGet("thumb/{showSlug}-s{seasonNumber}e{episodeNumber}")]
|
||||
[Authorize(Policy="Read")]
|
||||
public async Task<IActionResult> GetEpisodeThumb(string showSlug, long seasonNumber, long episodeNumber)
|
||||
public async Task<IActionResult> GetEpisodeThumb(string showSlug, int seasonNumber, int episodeNumber)
|
||||
{
|
||||
string path = (await _libraryManager.GetEpisode(showSlug, seasonNumber, episodeNumber))?.Path;
|
||||
if (path == null)
|
||||
|
@ -27,7 +27,7 @@ namespace Kyoo.Api
|
||||
|
||||
[HttpGet("{showSlug}-s{seasonNumber}e{episodeNumber}")]
|
||||
[Authorize(Policy="Play")]
|
||||
public async Task<IActionResult> Index(string showSlug, long seasonNumber, long episodeNumber)
|
||||
public async Task<IActionResult> Index(string showSlug, int seasonNumber, int episodeNumber)
|
||||
{
|
||||
Episode episode = await _libraryManager.GetEpisode(showSlug, seasonNumber, episodeNumber);
|
||||
|
||||
@ -38,7 +38,7 @@ namespace Kyoo.Api
|
||||
|
||||
[HttpGet("transmux/{showSlug}-s{seasonNumber}e{episodeNumber}")]
|
||||
[Authorize(Policy="Play")]
|
||||
public async Task<IActionResult> Transmux(string showSlug, long seasonNumber, long episodeNumber)
|
||||
public async Task<IActionResult> Transmux(string showSlug, int seasonNumber, int episodeNumber)
|
||||
{
|
||||
Episode episode = await _libraryManager.GetEpisode(showSlug, seasonNumber, episodeNumber);
|
||||
|
||||
@ -61,7 +61,7 @@ namespace Kyoo.Api
|
||||
|
||||
[HttpGet("transcode/{showSlug}-s{seasonNumber}e{episodeNumber}")]
|
||||
[Authorize(Policy="Play")]
|
||||
public async Task<IActionResult> Transcode(string showSlug, long seasonNumber, long episodeNumber)
|
||||
public async Task<IActionResult> Transcode(string showSlug, int seasonNumber, int episodeNumber)
|
||||
{
|
||||
Episode episode = await _libraryManager.GetEpisode(showSlug, seasonNumber, episodeNumber);
|
||||
|
||||
|
@ -19,7 +19,7 @@ namespace Kyoo.Api
|
||||
|
||||
[HttpGet("{showSlug}-s{seasonNumber}e{episodeNumber}")]
|
||||
[Authorize(Policy="Read")]
|
||||
public async Task<ActionResult<WatchItem>> Index(string showSlug, long seasonNumber, long episodeNumber)
|
||||
public async Task<ActionResult<WatchItem>> Index(string showSlug, int seasonNumber, int episodeNumber)
|
||||
{
|
||||
Episode item = await _libraryManager.GetEpisode(showSlug, seasonNumber, episodeNumber);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user