Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix metadata 403's and Add images to search results #54

Merged
merged 3 commits into from
Mar 15, 2020
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Jellyfin.Plugin.Anime/Jellyfin.Plugin.Anime.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<RootNamespace>Jellyfin.Plugin.Anime</RootNamespace>
<AssemblyVersion>4.0.0</AssemblyVersion>
<FileVersion>4.0.0</FileVersion>
<AssemblyVersion>5.0.0</AssemblyVersion>
<FileVersion>5.0.0</FileVersion>
</PropertyGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ public class AniDbTitleDownloader : IAniDbTitleDownloader
/// <summary>
/// The URL for retrieving a list of all anime titles and their AniDB IDs.
/// </summary>
private const string TitlesUrl = "http://anidb.net/api/animetitles.xml.gz";
private const string TitlesUrl = "http://anidb.net/api/anime-titles.xml.gz";
dkanada marked this conversation as resolved.
Show resolved Hide resolved
private const string UserAgent = "jellyfin-plugin-anime";
dkanada marked this conversation as resolved.
Show resolved Hide resolved

private readonly IApplicationPaths _paths;
private readonly ILogger _logger;
Expand Down Expand Up @@ -79,17 +80,7 @@ public async Task Load(CancellationToken cancellationToken)
private async Task DownloadTitles(string titlesFile)
{
_logger.LogDebug("Downloading new AniDB titles file.");

var client = new WebClient();

await AniDbSeriesProvider.RequestLimiter.Tick().ConfigureAwait(false);
await Task.Delay(Plugin.Instance.Configuration.AniDB_wait_time).ConfigureAwait(false);
using (var stream = await client.OpenReadTaskAsync(TitlesUrl))
using (var unzipped = new GZipStream(stream, CompressionMode.Decompress))
using (var writer = File.Open(titlesFile, FileMode.Create, FileAccess.Write))
{
await unzipped.CopyToAsync(writer).ConfigureAwait(false);
}
dkanada marked this conversation as resolved.
Show resolved Hide resolved
await DownloadTitles_static(titlesFile);
}

/// <summary>
Expand All @@ -101,6 +92,7 @@ private async Task DownloadTitles(string titlesFile)
private static async Task DownloadTitles_static(string titlesFile)
{
var client = new WebClient();
client.Headers.Add("User-Agent", UserAgent);

await AniDbSeriesProvider.RequestLimiter.Tick().ConfigureAwait(false);
await Task.Delay(Plugin.Instance.Configuration.AniDB_wait_time).ConfigureAwait(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,8 @@ await AniDbSeriesProvider.GetSeriesData(

public Task<HttpResponseInfo> GetImageResponse(string url, CancellationToken cancellationToken)
{
throw new NotImplementedException();
var imageProvider = new AniDbImageProvider(_httpClient, _configurationManager.ApplicationPaths);
return imageProvider.GetImageResponse(url, cancellationToken);
}

private async Task ParseAdditionalEpisodeXml(FileInfo xml, Episode episode, string metadataLanguage)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,15 @@ public async Task<IEnumerable<RemoteSearchResult>> GetSearchResults(SeriesInfo s

if (metadata.HasMetadata)
{
var seriesId = metadata.Item.ProviderIds.GetOrDefault(ProviderNames.AniDb);
var imageProvider = new AniDbImageProvider(_httpClient, _appPaths);
var images = await imageProvider.GetImages(seriesId, cancellationToken);
var res = new RemoteSearchResult
{
Name = metadata.Item.Name,
PremiereDate = metadata.Item.PremiereDate,
ProductionYear = metadata.Item.ProductionYear,
ImageUrl = images.Any() ? images.First().Url : null,
ProviderIds = metadata.Item.ProviderIds,
SearchProviderName = Name
};
Expand Down
2 changes: 1 addition & 1 deletion build.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
name: "jellyfin-plugin-anime"
guid: "a4df60c5-6ab4-412a-8f79-2cab93fb2bc5"
version: "4"
version: "5"
jellyfin_version: "10.3.0"
owner: "jellyfin"
nicename: "Anime"
Expand Down