mirror of
https://github.com/zoriya/Kyoo.git
synced 2025-05-31 04:04:21 -04:00
Now using PeopleLink instead of People when we were talking about people related to a show
This commit is contained in:
parent
d8a21f1cf1
commit
9d6da207fe
@ -9,7 +9,7 @@ namespace Kyoo.Controllers
|
|||||||
//Read values
|
//Read values
|
||||||
string GetShowExternalIDs(long showID);
|
string GetShowExternalIDs(long showID);
|
||||||
Studio GetStudio(long showID);
|
Studio GetStudio(long showID);
|
||||||
IEnumerable<People> GetPeople(long showID);
|
IEnumerable<PeopleLink> GetPeople(long showID);
|
||||||
IEnumerable<Genre> GetGenreForShow(long showID);
|
IEnumerable<Genre> GetGenreForShow(long showID);
|
||||||
IEnumerable<Season> GetSeasons(long showID);
|
IEnumerable<Season> GetSeasons(long showID);
|
||||||
int GetSeasonCount(string showSlug, long seasonNumber);
|
int GetSeasonCount(string showSlug, long seasonNumber);
|
||||||
|
@ -14,7 +14,7 @@ namespace Kyoo.Controllers
|
|||||||
//For the show
|
//For the show
|
||||||
Task<Show> GetShowByID(string id);
|
Task<Show> GetShowByID(string id);
|
||||||
Task<Show> GetShowFromName(string showName);
|
Task<Show> GetShowFromName(string showName);
|
||||||
Task<IEnumerable<People>> GetPeople(Show show);
|
Task<IEnumerable<PeopleLink>> GetPeople(Show show);
|
||||||
|
|
||||||
//For the seasons
|
//For the seasons
|
||||||
Task<Season> GetSeason(Show show, long seasonNumber);
|
Task<Season> GetSeason(Show show, long seasonNumber);
|
||||||
|
@ -10,6 +10,6 @@ namespace Kyoo.Controllers
|
|||||||
Task<Show> GetShowFromName(string showName, string showPath, Library library);
|
Task<Show> GetShowFromName(string showName, string showPath, Library library);
|
||||||
Task<Season> GetSeason(Show show, long seasonNumber, 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<Episode> GetEpisode(Show show, string episodePath, long seasonNumber, long episodeNumber, long absoluteNumber, Library library);
|
||||||
Task<IEnumerable<People>> GetPeople(Show show, Library library);
|
Task<IEnumerable<PeopleLink>> GetPeople(Show show, Library library);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -7,7 +7,7 @@ namespace Kyoo.Controllers
|
|||||||
public interface IThumbnailsManager
|
public interface IThumbnailsManager
|
||||||
{
|
{
|
||||||
Task<Show> Validate(Show show);
|
Task<Show> Validate(Show show);
|
||||||
Task<IEnumerable<People>> Validate(IEnumerable<People> actors);
|
Task<IEnumerable<PeopleLink>> Validate(List<PeopleLink> actors);
|
||||||
Task<Episode> Validate(Episode episode);
|
Task<Episode> Validate(Episode episode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
<Company>SDG</Company>
|
<Company>SDG</Company>
|
||||||
<PackageLicenseExpression>GPL-3.0-or-later</PackageLicenseExpression>
|
<PackageLicenseExpression>GPL-3.0-or-later</PackageLicenseExpression>
|
||||||
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance>
|
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance>
|
||||||
<PackageVersion>1.0.7</PackageVersion>
|
<PackageVersion>1.0.9</PackageVersion>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
@ -8,12 +8,10 @@ namespace Kyoo.Models
|
|||||||
[JsonIgnore] public long ID { get; set; }
|
[JsonIgnore] public long ID { get; set; }
|
||||||
public string Slug { get; set; }
|
public string Slug { get; set; }
|
||||||
public string Name { get; set; }
|
public string Name { get; set; }
|
||||||
public string Role;
|
|
||||||
public string Type;
|
|
||||||
[JsonIgnore] public string ImgPrimary { get; set; }
|
[JsonIgnore] public string ImgPrimary { get; set; }
|
||||||
public string ExternalIDs { get; set; }
|
public string ExternalIDs { get; set; }
|
||||||
|
|
||||||
public virtual IEnumerable<PeopleLink> Roles { get; set; }
|
[JsonIgnore] public virtual IEnumerable<PeopleLink> Roles { get; set; }
|
||||||
|
|
||||||
public People() {}
|
public People() {}
|
||||||
|
|
||||||
@ -25,36 +23,6 @@ namespace Kyoo.Models
|
|||||||
ExternalIDs = externalIDs;
|
ExternalIDs = externalIDs;
|
||||||
}
|
}
|
||||||
|
|
||||||
public People(string slug, string name, string role, string type, string imgPrimary, string externalIDs)
|
|
||||||
{
|
|
||||||
Slug = slug;
|
|
||||||
Name = name;
|
|
||||||
Role = role;
|
|
||||||
Type = type;
|
|
||||||
ImgPrimary = imgPrimary;
|
|
||||||
ExternalIDs = externalIDs;
|
|
||||||
}
|
|
||||||
|
|
||||||
public People SetRoleType(string role, string type)
|
|
||||||
{
|
|
||||||
Role = role;
|
|
||||||
Type = type;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public PeopleLink ToLink(Show show)
|
|
||||||
{
|
|
||||||
return new PeopleLink
|
|
||||||
{
|
|
||||||
People = this,
|
|
||||||
PeopleID = ID,
|
|
||||||
Role = Role,
|
|
||||||
Type = Type,
|
|
||||||
Show = show,
|
|
||||||
ShowID = show.ID
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
public People Merge(People other)
|
public People Merge(People other)
|
||||||
{
|
{
|
||||||
if (other == null)
|
if (other == null)
|
||||||
@ -65,10 +33,6 @@ namespace Kyoo.Models
|
|||||||
Slug = other.Slug;
|
Slug = other.Slug;
|
||||||
if (Name == null)
|
if (Name == null)
|
||||||
Name = other.Name;
|
Name = other.Name;
|
||||||
if (Role == null)
|
|
||||||
Role = other.Role;
|
|
||||||
if (Type == null)
|
|
||||||
Type = other.Type;
|
|
||||||
if (ImgPrimary == null)
|
if (ImgPrimary == null)
|
||||||
ImgPrimary = other.ImgPrimary;
|
ImgPrimary = other.ImgPrimary;
|
||||||
ExternalIDs += '|' + other.ExternalIDs;
|
ExternalIDs += '|' + other.ExternalIDs;
|
||||||
|
@ -1,13 +1,31 @@
|
|||||||
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
namespace Kyoo.Models
|
namespace Kyoo.Models
|
||||||
{
|
{
|
||||||
public class PeopleLink
|
public class PeopleLink
|
||||||
{
|
{
|
||||||
public long ID { get; set; }
|
[JsonIgnore] public long ID { get; set; }
|
||||||
public long PeopleID { get; set; }
|
[JsonIgnore] public long PeopleID { get; set; }
|
||||||
public People People { get; set; }
|
public People People { get; set; }
|
||||||
public long ShowID { get; set; }
|
[JsonIgnore] public long ShowID { get; set; }
|
||||||
public Show Show { get; set; }
|
[JsonIgnore] public Show Show { get; set; }
|
||||||
public string Role { get; set; }
|
public string Role { get; set; }
|
||||||
public string Type { get; set; }
|
public string Type { get; set; }
|
||||||
|
|
||||||
|
public PeopleLink() {}
|
||||||
|
|
||||||
|
public PeopleLink(People people, string role, string type)
|
||||||
|
{
|
||||||
|
People = people;
|
||||||
|
Role = role;
|
||||||
|
Type = type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public PeopleLink(string slug, string name, string role, string type, string imgPrimary, string externalIDs)
|
||||||
|
{
|
||||||
|
People = new People(slug, name, imgPrimary, externalIDs);
|
||||||
|
Role = role;
|
||||||
|
Type = type;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -29,10 +29,10 @@ namespace Kyoo.Models
|
|||||||
|
|
||||||
public bool IsCollection;
|
public bool IsCollection;
|
||||||
|
|
||||||
public IEnumerable<Genre> Genres;
|
public virtual IEnumerable<Genre> Genres { get; set; }
|
||||||
public virtual Studio Studio { get; set; }
|
public virtual Studio Studio { get; set; }
|
||||||
[JsonIgnore] public virtual IEnumerable<PeopleLink> People { get; set; }
|
public virtual IEnumerable<PeopleLink> People { get; set; }
|
||||||
[JsonIgnore] public virtual IEnumerable<Season> Seasons { get; set; }
|
public virtual IEnumerable<Season> Seasons { get; set; }
|
||||||
[JsonIgnore] public virtual IEnumerable<Episode> Episodes { get; set; }
|
[JsonIgnore] public virtual IEnumerable<Episode> Episodes { get; set; }
|
||||||
|
|
||||||
|
|
||||||
|
@ -1 +1 @@
|
|||||||
Subproject commit d18cfcbc3b2b3b309d5d90aee673c9146aa55faa
|
Subproject commit 1a7094979c79dd3e50760afbc6bf5b2286e7ab9d
|
@ -141,7 +141,7 @@ namespace Kyoo.Controllers
|
|||||||
if (show != null)
|
if (show != null)
|
||||||
return show;
|
return show;
|
||||||
show = await _metadataProvider.GetShowFromName(showTitle, showPath, library);
|
show = await _metadataProvider.GetShowFromName(showTitle, showPath, library);
|
||||||
show.People = (from people in await _metadataProvider.GetPeople(show, library) select people.ToLink(show)).ToList();
|
show.People = (from people in await _metadataProvider.GetPeople(show, library) select people).ToList();
|
||||||
return show;
|
return show;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -76,7 +76,14 @@ namespace Kyoo.Controllers
|
|||||||
|
|
||||||
public Show GetShowBySlug(string slug)
|
public Show GetShowBySlug(string slug)
|
||||||
{
|
{
|
||||||
return (from show in _database.Shows where show.Slug == slug select show).FirstOrDefault();
|
Show ret = (from show in _database.Shows where show.Slug == slug select show).FirstOrDefault();
|
||||||
|
if (ret == null)
|
||||||
|
return null;
|
||||||
|
//_database.Entry(ret).Collection(x => x.Genres).Load();
|
||||||
|
_database.Entry(ret).Reference(x => x.Studio).Load();
|
||||||
|
_database.Entry(ret).Collection(x => x.People).Load();
|
||||||
|
_database.Entry(ret).Collection(x => x.Seasons).Load();
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Show GetShow(string path)
|
public Show GetShow(string path)
|
||||||
@ -157,9 +164,9 @@ namespace Kyoo.Controllers
|
|||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IEnumerable<People> GetPeople(long showID)
|
public IEnumerable<PeopleLink> GetPeople(long showID)
|
||||||
{
|
{
|
||||||
return from link in _database.PeopleLinks where link.ShowID == showID select link.People.SetRoleType(link.Role, link.Type);
|
return from link in _database.PeopleLinks where link.ShowID == showID select link;
|
||||||
}
|
}
|
||||||
|
|
||||||
public People GetPeopleBySlug(string slug)
|
public People GetPeopleBySlug(string slug)
|
||||||
|
@ -90,10 +90,10 @@ namespace Kyoo.Controllers
|
|||||||
return episode;
|
return episode;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<IEnumerable<People>> GetPeople(Show show, Library library)
|
public async Task<IEnumerable<PeopleLink>> GetPeople(Show show, Library library)
|
||||||
{
|
{
|
||||||
IEnumerable<People> people = await GetMetadata(provider => provider.GetPeople(show), library, "unknown data");
|
IEnumerable<PeopleLink> people = await GetMetadata(provider => provider.GetPeople(show), library, "unknown data");
|
||||||
people = await _thumbnailsManager.Validate(people);
|
people = await _thumbnailsManager.Validate(people.ToList());
|
||||||
return people;
|
return people;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -68,22 +68,22 @@ namespace Kyoo.Controllers
|
|||||||
return show;
|
return show;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<IEnumerable<People>> Validate(IEnumerable<People> people)
|
public async Task<IEnumerable<PeopleLink>> Validate(List<PeopleLink> people)
|
||||||
{
|
{
|
||||||
if (people == null)
|
if (people == null)
|
||||||
return null;
|
return null;
|
||||||
foreach (People peop in people)
|
foreach (PeopleLink 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.People.Slug + ".jpg";
|
||||||
if (peop.ImgPrimary == null || File.Exists(localThumb))
|
if (peop.People.ImgPrimary == null || File.Exists(localThumb))
|
||||||
continue;
|
continue;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
using WebClient client = new WebClient();
|
using WebClient client = new WebClient();
|
||||||
await client.DownloadFileTaskAsync(new Uri(peop.ImgPrimary), localThumb);
|
await client.DownloadFileTaskAsync(new Uri(peop.People.ImgPrimary), localThumb);
|
||||||
}
|
}
|
||||||
catch (WebException)
|
catch (WebException)
|
||||||
{
|
{
|
||||||
|
@ -43,7 +43,7 @@ namespace Kyoo
|
|||||||
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.AddScoped<ICrawler, Crawler>();
|
||||||
services.AddSingleton<IPluginManager, PluginManager>();
|
services.AddSingleton<IPluginManager, PluginManager>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user