mirror of
https://github.com/zoriya/Kyoo.git
synced 2025-06-02 13:14:29 -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>
|
<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.5</PackageVersion>
|
<PackageVersion>1.0.6</PackageVersion>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
@ -51,6 +51,8 @@ namespace Kyoo.Models
|
|||||||
|
|
||||||
public Collection Merge(Collection collection)
|
public Collection Merge(Collection collection)
|
||||||
{
|
{
|
||||||
|
if (collection == null)
|
||||||
|
return this;
|
||||||
if (ID == -1)
|
if (ID == -1)
|
||||||
ID = collection.ID;
|
ID = collection.ID;
|
||||||
if (Slug == null)
|
if (Slug == null)
|
||||||
|
@ -108,6 +108,8 @@ namespace Kyoo.Models
|
|||||||
|
|
||||||
public Episode Merge(Episode other)
|
public Episode Merge(Episode other)
|
||||||
{
|
{
|
||||||
|
if (other == null)
|
||||||
|
return this;
|
||||||
if (ID == -1)
|
if (ID == -1)
|
||||||
ID = other.ID;
|
ID = other.ID;
|
||||||
if (ShowID == -1)
|
if (ShowID == -1)
|
||||||
|
@ -16,7 +16,7 @@ namespace Kyoo.Models
|
|||||||
|
|
||||||
public Genre(long id, string slug, string name)
|
public Genre(long id, string slug, string name)
|
||||||
{
|
{
|
||||||
this.ID = id;
|
ID = id;
|
||||||
Slug = slug;
|
Slug = slug;
|
||||||
Name = name;
|
Name = name;
|
||||||
}
|
}
|
||||||
|
@ -57,6 +57,8 @@ namespace Kyoo.Models
|
|||||||
|
|
||||||
public People Merge(People other)
|
public People Merge(People other)
|
||||||
{
|
{
|
||||||
|
if (other == null)
|
||||||
|
return this;
|
||||||
if (ID == -1)
|
if (ID == -1)
|
||||||
ID = other.ID;
|
ID = other.ID;
|
||||||
if (Slug == null)
|
if (Slug == null)
|
||||||
|
@ -43,6 +43,8 @@ namespace Kyoo.Models
|
|||||||
|
|
||||||
public Season Merge(Season other)
|
public Season Merge(Season other)
|
||||||
{
|
{
|
||||||
|
if (other == null)
|
||||||
|
return this;
|
||||||
if (ShowID == -1)
|
if (ShowID == -1)
|
||||||
ShowID = other.ShowID;
|
ShowID = other.ShowID;
|
||||||
if (SeasonNumber == -1)
|
if (SeasonNumber == -1)
|
||||||
|
@ -170,6 +170,8 @@ namespace Kyoo.Models
|
|||||||
|
|
||||||
public Show Merge(Show other)
|
public Show Merge(Show other)
|
||||||
{
|
{
|
||||||
|
if (other == null)
|
||||||
|
return this;
|
||||||
if (ID == -1)
|
if (ID == -1)
|
||||||
ID = other.ID;
|
ID = other.ID;
|
||||||
if (Slug == null)
|
if (Slug == null)
|
||||||
|
@ -16,7 +16,7 @@ namespace Kyoo.Models
|
|||||||
|
|
||||||
public Studio(long id, string slug, string name)
|
public Studio(long id, string slug, string name)
|
||||||
{
|
{
|
||||||
this.ID = id;
|
ID = id;
|
||||||
Slug = slug;
|
Slug = slug;
|
||||||
Name = name;
|
Name = name;
|
||||||
}
|
}
|
||||||
|
@ -94,7 +94,7 @@ namespace Kyoo.Models
|
|||||||
if (language == "fre")
|
if (language == "fre")
|
||||||
language = "fra";
|
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;
|
Link = "/subtitle/" + episodeSlug + "." + Language;
|
||||||
|
|
||||||
if (IsForced)
|
if (IsForced)
|
||||||
|
@ -18,10 +18,9 @@ namespace Kyoo.Controllers
|
|||||||
{
|
{
|
||||||
string databasePath = configuration.GetValue<string>("databasePath");
|
string databasePath = configuration.GetValue<string>("databasePath");
|
||||||
|
|
||||||
Debug.WriteLine("&Library Manager init, databasePath: " + databasePath);
|
|
||||||
if (!File.Exists(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)))
|
if (!Directory.Exists(Path.GetDirectoryName(databasePath)))
|
||||||
Directory.CreateDirectory(databasePath);
|
Directory.CreateDirectory(databasePath);
|
||||||
|
@ -23,12 +23,16 @@ namespace Kyoo.Controllers
|
|||||||
|
|
||||||
public T GetPlugin<T>(string name)
|
public T GetPlugin<T>(string name)
|
||||||
{
|
{
|
||||||
|
if (plugins == null)
|
||||||
|
return default;
|
||||||
return (T)(from plugin in plugins where plugin.Name == name && plugin is T
|
return (T)(from plugin in plugins where plugin.Name == name && plugin is T
|
||||||
select plugin).FirstOrDefault();
|
select plugin).FirstOrDefault();
|
||||||
}
|
}
|
||||||
|
|
||||||
public IEnumerable<T> GetPlugins<T>()
|
public IEnumerable<T> GetPlugins<T>()
|
||||||
{
|
{
|
||||||
|
if (plugins == null)
|
||||||
|
return null;
|
||||||
return from plugin in plugins where plugin is T
|
return from plugin in plugins where plugin is T
|
||||||
select (T)plugin;
|
select (T)plugin;
|
||||||
}
|
}
|
||||||
@ -52,7 +56,7 @@ namespace Kyoo.Controllers
|
|||||||
}
|
}
|
||||||
catch (Exception ex)
|
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;
|
return null;
|
||||||
}
|
}
|
||||||
}).Where(x => x != null).ToList();
|
}).Where(x => x != null).ToList();
|
||||||
|
@ -29,7 +29,7 @@ namespace Kyoo.Controllers
|
|||||||
if (library.Providers.Contains(provider.Name))
|
if (library.Providers.Contains(provider.Name))
|
||||||
ret = ret.Merge(await providerCall(provider));
|
ret = ret.Merge(await providerCall(provider));
|
||||||
} catch (Exception ex) {
|
} 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;
|
return ret;
|
||||||
@ -66,19 +66,19 @@ namespace Kyoo.Controllers
|
|||||||
|
|
||||||
public async Task<Season> GetSeason(Show show, long seasonNumber, Library library)
|
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)
|
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);
|
await thumbnailsManager.Validate(episode);
|
||||||
return episode;
|
return episode;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<IEnumerable<People>> GetPeople(Show show, Library library)
|
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);
|
people = await thumbnailsManager.Validate(people);
|
||||||
return people;
|
return people;
|
||||||
}
|
}
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<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.Mvc.NewtonsoftJson" Version="3.0.0" />
|
||||||
<PackageReference Include="Microsoft.AspNetCore.SpaServices" Version="3.0.0" />
|
<PackageReference Include="Microsoft.AspNetCore.SpaServices" Version="3.0.0" />
|
||||||
<PackageReference Include="Microsoft.AspNetCore.SpaServices.Extensions" 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