mirror of
https://github.com/zoriya/Kyoo.git
synced 2025-05-24 02:02:36 -04:00
Finishing the plugin manager and the provider manager
This commit is contained in:
parent
8b8e89d123
commit
87d01c6044
@ -11,7 +11,7 @@
|
||||
<Company>SDG</Company>
|
||||
<PackageLicenseExpression>GPL-3.0-or-later</PackageLicenseExpression>
|
||||
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance>
|
||||
<PackageVersion>1.0.5</PackageVersion>
|
||||
<PackageVersion>1.0.6</PackageVersion>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
@ -51,6 +51,8 @@ namespace Kyoo.Models
|
||||
|
||||
public Collection Merge(Collection collection)
|
||||
{
|
||||
if (collection == null)
|
||||
return this;
|
||||
if (ID == -1)
|
||||
ID = collection.ID;
|
||||
if (Slug == null)
|
||||
|
@ -108,6 +108,8 @@ namespace Kyoo.Models
|
||||
|
||||
public Episode Merge(Episode other)
|
||||
{
|
||||
if (other == null)
|
||||
return this;
|
||||
if (ID == -1)
|
||||
ID = other.ID;
|
||||
if (ShowID == -1)
|
||||
|
@ -16,7 +16,7 @@ namespace Kyoo.Models
|
||||
|
||||
public Genre(long id, string slug, string name)
|
||||
{
|
||||
this.ID = id;
|
||||
ID = id;
|
||||
Slug = slug;
|
||||
Name = name;
|
||||
}
|
||||
|
@ -57,6 +57,8 @@ namespace Kyoo.Models
|
||||
|
||||
public People Merge(People other)
|
||||
{
|
||||
if (other == null)
|
||||
return this;
|
||||
if (ID == -1)
|
||||
ID = other.ID;
|
||||
if (Slug == null)
|
||||
|
@ -43,6 +43,8 @@ namespace Kyoo.Models
|
||||
|
||||
public Season Merge(Season other)
|
||||
{
|
||||
if (other == null)
|
||||
return this;
|
||||
if (ShowID == -1)
|
||||
ShowID = other.ShowID;
|
||||
if (SeasonNumber == -1)
|
||||
|
@ -170,6 +170,8 @@ namespace Kyoo.Models
|
||||
|
||||
public Show Merge(Show other)
|
||||
{
|
||||
if (other == null)
|
||||
return this;
|
||||
if (ID == -1)
|
||||
ID = other.ID;
|
||||
if (Slug == null)
|
||||
|
@ -16,7 +16,7 @@ namespace Kyoo.Models
|
||||
|
||||
public Studio(long id, string slug, string name)
|
||||
{
|
||||
this.ID = id;
|
||||
ID = id;
|
||||
Slug = slug;
|
||||
Name = name;
|
||||
}
|
||||
|
@ -94,7 +94,7 @@ namespace Kyoo.Models
|
||||
if (language == "fre")
|
||||
language = "fra";
|
||||
|
||||
DisplayName = CultureInfo.GetCultures(CultureTypes.NeutralCultures).FirstOrDefault(x => x.ThreeLetterISOLanguageName == language)?.DisplayName ?? language;
|
||||
DisplayName = CultureInfo.GetCultures(CultureTypes.NeutralCultures).FirstOrDefault(x => x.ThreeLetterISOLanguageName == language)?.EnglishName ?? language;
|
||||
Link = "/subtitle/" + episodeSlug + "." + Language;
|
||||
|
||||
if (IsForced)
|
||||
|
@ -18,10 +18,9 @@ namespace Kyoo.Controllers
|
||||
{
|
||||
string databasePath = configuration.GetValue<string>("databasePath");
|
||||
|
||||
Debug.WriteLine("&Library Manager init, databasePath: " + databasePath);
|
||||
if (!File.Exists(databasePath))
|
||||
{
|
||||
Debug.WriteLine("&Database doesn't exist, creating one.");
|
||||
Console.WriteLine($"Creating the database at {databasePath}.");
|
||||
|
||||
if (!Directory.Exists(Path.GetDirectoryName(databasePath)))
|
||||
Directory.CreateDirectory(databasePath);
|
||||
|
@ -22,13 +22,17 @@ namespace Kyoo.Controllers
|
||||
}
|
||||
|
||||
public T GetPlugin<T>(string name)
|
||||
{
|
||||
{
|
||||
if (plugins == null)
|
||||
return default;
|
||||
return (T)(from plugin in plugins where plugin.Name == name && plugin is T
|
||||
select plugin).FirstOrDefault();
|
||||
}
|
||||
|
||||
public IEnumerable<T> GetPlugins<T>()
|
||||
{
|
||||
{
|
||||
if (plugins == null)
|
||||
return null;
|
||||
return from plugin in plugins where plugin is T
|
||||
select (T)plugin;
|
||||
}
|
||||
@ -52,7 +56,7 @@ namespace Kyoo.Controllers
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.Error.WriteLine($"Error loading the plugin at ${path}.\nException: {ex.Message}");
|
||||
Console.Error.WriteLine($"Error loading the plugin at {path}.\nException: {ex.Message}");
|
||||
return null;
|
||||
}
|
||||
}).Where(x => x != null).ToList();
|
||||
|
@ -29,7 +29,7 @@ namespace Kyoo.Controllers
|
||||
if (library.Providers.Contains(provider.Name))
|
||||
ret = ret.Merge(await providerCall(provider));
|
||||
} catch (Exception ex) {
|
||||
Console.Error.WriteLine($"The provider {provider.Name} coudln't work for {what}. (Excepetion: {ex.Message}");
|
||||
Console.Error.WriteLine($"The provider {provider.Name} coudln't work for {what}. (Exception: {ex.Message}");
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
@ -66,19 +66,19 @@ namespace Kyoo.Controllers
|
||||
|
||||
public async Task<Season> GetSeason(Show show, long seasonNumber, Library library)
|
||||
{
|
||||
return await GetMetadata(provider => provider.GetSeason(show, seasonNumber), library, $"the season ${seasonNumber} of {show.Title}");
|
||||
return await GetMetadata(provider => provider.GetSeason(show, seasonNumber), library, $"the season {seasonNumber} of {show.Title}");
|
||||
}
|
||||
|
||||
public async Task<Episode> GetEpisode(Show show, long seasonNumber, long episodeNumber, long absoluteNumber, Library library)
|
||||
{
|
||||
Episode episode = await GetMetadata(provider => provider.GetEpisode(show, seasonNumber, episodeNumber, absoluteNumber), library, $"an episode");
|
||||
Episode episode = await GetMetadata(provider => provider.GetEpisode(show, seasonNumber, episodeNumber, absoluteNumber), library, "an episode");
|
||||
await thumbnailsManager.Validate(episode);
|
||||
return episode;
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<People>> GetPeople(Show show, Library library)
|
||||
{
|
||||
IEnumerable<People> people = await GetMetadata(provider => provider.GetPeople(show), library, $"unknown data");
|
||||
IEnumerable<People> people = await GetMetadata(provider => provider.GetPeople(show), library, "unknown data");
|
||||
people = await thumbnailsManager.Validate(people);
|
||||
return people;
|
||||
}
|
||||
|
@ -17,6 +17,7 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.AspNet.WebApi.Client" Version="5.2.7" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="3.0.0" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.SpaServices" Version="3.0.0" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.SpaServices.Extensions" Version="3.0.0" />
|
||||
|
@ -1 +1 @@
|
||||
Subproject commit d8f72ff87020f2d38a4552f6083ef0659bf1f2be
|
||||
Subproject commit bedf98f85d2cf669a1d1c4af35271841133cfec2
|
Loading…
x
Reference in New Issue
Block a user