mirror of
https://github.com/jellyfin/jellyfin-plugin-fanart.git
synced 2024-11-23 05:39:54 +00:00
fix all build errors and pull api key from plugin settings
This commit is contained in:
parent
56319f35b6
commit
05af4134ad
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,3 +1,4 @@
|
|||||||
bin/
|
bin/
|
||||||
obj/
|
obj/
|
||||||
|
.idea/
|
||||||
.vs/
|
.vs/
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
|
|
||||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||||
# Visual Studio 15
|
# Visual Studio 15
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Jellyfin.Plugin.Template", "Jellyfin.Plugin.Template\Jellyfin.Plugin.Template.csproj", "{D921B930-CF91-406F-ACBC-08914DCD0D34}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Jellyfin.Plugin.Fanart", "Jellyfin.Plugin.Fanart\Jellyfin.Plugin.Fanart.csproj", "{D921B930-CF91-406F-ACBC-08914DCD0D34}"
|
||||||
EndProject
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using Jellyfin.Plugin.Template.Configuration;
|
using Jellyfin.Plugin.Fanart.Configuration;
|
||||||
using MediaBrowser.Common.Configuration;
|
using MediaBrowser.Common.Configuration;
|
||||||
using MediaBrowser.Common.Plugins;
|
using MediaBrowser.Common.Plugins;
|
||||||
using MediaBrowser.Model.Plugins;
|
using MediaBrowser.Model.Plugins;
|
||||||
|
@ -17,9 +17,9 @@ using MediaBrowser.Model.IO;
|
|||||||
using MediaBrowser.Model.Providers;
|
using MediaBrowser.Model.Providers;
|
||||||
using MediaBrowser.Model.Serialization;
|
using MediaBrowser.Model.Serialization;
|
||||||
|
|
||||||
namespace MediaBrowser.Providers.Music
|
namespace Jellyfin.Plugin.Fanart.Providers
|
||||||
{
|
{
|
||||||
public class FanartAlbumProvider : IRemoteImageProvider, IHasOrder
|
public class AlbumProvider : IRemoteImageProvider, IHasOrder
|
||||||
{
|
{
|
||||||
private readonly CultureInfo _usCulture = new CultureInfo("en-US");
|
private readonly CultureInfo _usCulture = new CultureInfo("en-US");
|
||||||
private readonly IServerConfigurationManager _config;
|
private readonly IServerConfigurationManager _config;
|
||||||
@ -27,7 +27,7 @@ namespace MediaBrowser.Providers.Music
|
|||||||
private readonly IFileSystem _fileSystem;
|
private readonly IFileSystem _fileSystem;
|
||||||
private readonly IJsonSerializer _jsonSerializer;
|
private readonly IJsonSerializer _jsonSerializer;
|
||||||
|
|
||||||
public FanartAlbumProvider(IServerConfigurationManager config, IHttpClient httpClient, IFileSystem fileSystem, IJsonSerializer jsonSerializer)
|
public AlbumProvider(IServerConfigurationManager config, IHttpClient httpClient, IFileSystem fileSystem, IJsonSerializer jsonSerializer)
|
||||||
{
|
{
|
||||||
_config = config;
|
_config = config;
|
||||||
_httpClient = httpClient;
|
_httpClient = httpClient;
|
||||||
@ -37,7 +37,7 @@ namespace MediaBrowser.Providers.Music
|
|||||||
|
|
||||||
public string Name => ProviderName;
|
public string Name => ProviderName;
|
||||||
|
|
||||||
public static string ProviderName => "FanArt";
|
public static string ProviderName => "Fanart";
|
||||||
|
|
||||||
public bool Supports(BaseItem item)
|
public bool Supports(BaseItem item)
|
||||||
{
|
{
|
||||||
@ -70,9 +70,9 @@ namespace MediaBrowser.Providers.Music
|
|||||||
|
|
||||||
if (!string.IsNullOrEmpty(artistMusicBrainzId))
|
if (!string.IsNullOrEmpty(artistMusicBrainzId))
|
||||||
{
|
{
|
||||||
await FanartArtistProvider.Current.EnsureArtistJson(artistMusicBrainzId, cancellationToken).ConfigureAwait(false);
|
await ArtistProvider.Current.EnsureArtistJson(artistMusicBrainzId, cancellationToken).ConfigureAwait(false);
|
||||||
|
|
||||||
var artistJsonPath = FanartArtistProvider.GetArtistJsonPath(_config.CommonApplicationPaths, artistMusicBrainzId);
|
var artistJsonPath = ArtistProvider.GetArtistJsonPath(_config.CommonApplicationPaths, artistMusicBrainzId);
|
||||||
|
|
||||||
var musicBrainzReleaseGroupId = album.GetProviderId(MetadataProviders.MusicBrainzReleaseGroup);
|
var musicBrainzReleaseGroupId = album.GetProviderId(MetadataProviders.MusicBrainzReleaseGroup);
|
||||||
|
|
||||||
@ -131,7 +131,7 @@ namespace MediaBrowser.Providers.Music
|
|||||||
/// <param name="cancellationToken">The cancellation token.</param>
|
/// <param name="cancellationToken">The cancellation token.</param>
|
||||||
private void AddImages(List<RemoteImageInfo> list, string path, string releaseId, string releaseGroupId, CancellationToken cancellationToken)
|
private void AddImages(List<RemoteImageInfo> list, string path, string releaseId, string releaseGroupId, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
var obj = _jsonSerializer.DeserializeFromFile<FanartArtistProvider.FanartArtistResponse>(path);
|
var obj = _jsonSerializer.DeserializeFromFile<ArtistProvider.ArtistResponse>(path);
|
||||||
|
|
||||||
if (obj.albums != null)
|
if (obj.albums != null)
|
||||||
{
|
{
|
||||||
@ -146,7 +146,7 @@ namespace MediaBrowser.Providers.Music
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void PopulateImages(List<RemoteImageInfo> list,
|
private void PopulateImages(List<RemoteImageInfo> list,
|
||||||
List<FanartArtistProvider.FanartArtistImage> images,
|
List<ArtistProvider.ArtistImage> images,
|
||||||
ImageType type,
|
ImageType type,
|
||||||
int width,
|
int width,
|
||||||
int height)
|
int height)
|
@ -19,15 +19,13 @@ using MediaBrowser.Model.IO;
|
|||||||
using MediaBrowser.Model.Net;
|
using MediaBrowser.Model.Net;
|
||||||
using MediaBrowser.Model.Providers;
|
using MediaBrowser.Model.Providers;
|
||||||
using MediaBrowser.Model.Serialization;
|
using MediaBrowser.Model.Serialization;
|
||||||
using MediaBrowser.Providers.TV;
|
|
||||||
using MediaBrowser.Providers.TV.FanArt;
|
|
||||||
|
|
||||||
namespace MediaBrowser.Providers.Music
|
namespace Jellyfin.Plugin.Fanart.Providers
|
||||||
{
|
{
|
||||||
public class FanartArtistProvider : IRemoteImageProvider, IHasOrder
|
public class ArtistProvider : IRemoteImageProvider, IHasOrder
|
||||||
{
|
{
|
||||||
internal const string ApiKey = "184e1a2b1fe3b94935365411f919f638";
|
internal const string ApiKey = "184e1a2b1fe3b94935365411f919f638";
|
||||||
private const string FanArtBaseUrl = "https://webservice.fanart.tv/v3.1/music/{1}?api_key={0}";
|
private const string BaseUrl = "https://webservice.fanart.tv/v3.1/music/{1}?api_key={0}";
|
||||||
|
|
||||||
private readonly CultureInfo _usCulture = new CultureInfo("en-US");
|
private readonly CultureInfo _usCulture = new CultureInfo("en-US");
|
||||||
private readonly IServerConfigurationManager _config;
|
private readonly IServerConfigurationManager _config;
|
||||||
@ -35,9 +33,9 @@ namespace MediaBrowser.Providers.Music
|
|||||||
private readonly IFileSystem _fileSystem;
|
private readonly IFileSystem _fileSystem;
|
||||||
private readonly IJsonSerializer _jsonSerializer;
|
private readonly IJsonSerializer _jsonSerializer;
|
||||||
|
|
||||||
internal static FanartArtistProvider Current;
|
internal static ArtistProvider Current;
|
||||||
|
|
||||||
public FanartArtistProvider(IServerConfigurationManager config, IHttpClient httpClient, IFileSystem fileSystem, IJsonSerializer jsonSerializer)
|
public ArtistProvider(IServerConfigurationManager config, IHttpClient httpClient, IFileSystem fileSystem, IJsonSerializer jsonSerializer)
|
||||||
{
|
{
|
||||||
_config = config;
|
_config = config;
|
||||||
_httpClient = httpClient;
|
_httpClient = httpClient;
|
||||||
@ -49,7 +47,7 @@ namespace MediaBrowser.Providers.Music
|
|||||||
|
|
||||||
public string Name => ProviderName;
|
public string Name => ProviderName;
|
||||||
|
|
||||||
public static string ProviderName => "FanArt";
|
public static string ProviderName => "Fanart";
|
||||||
|
|
||||||
public bool Supports(BaseItem item)
|
public bool Supports(BaseItem item)
|
||||||
{
|
{
|
||||||
@ -133,7 +131,7 @@ namespace MediaBrowser.Providers.Music
|
|||||||
/// <param name="cancellationToken">The cancellation token.</param>
|
/// <param name="cancellationToken">The cancellation token.</param>
|
||||||
private void AddImages(List<RemoteImageInfo> list, string path, CancellationToken cancellationToken)
|
private void AddImages(List<RemoteImageInfo> list, string path, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
var obj = _jsonSerializer.DeserializeFromFile<FanartArtistResponse>(path);
|
var obj = _jsonSerializer.DeserializeFromFile<ArtistResponse>(path);
|
||||||
|
|
||||||
PopulateImages(list, obj.artistbackground, ImageType.Backdrop, 1920, 1080);
|
PopulateImages(list, obj.artistbackground, ImageType.Backdrop, 1920, 1080);
|
||||||
PopulateImages(list, obj.artistthumb, ImageType.Primary, 500, 281);
|
PopulateImages(list, obj.artistthumb, ImageType.Primary, 500, 281);
|
||||||
@ -145,7 +143,7 @@ namespace MediaBrowser.Providers.Music
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void PopulateImages(List<RemoteImageInfo> list,
|
private void PopulateImages(List<RemoteImageInfo> list,
|
||||||
List<FanartArtistImage> images,
|
List<ArtistImage> images,
|
||||||
ImageType type,
|
ImageType type,
|
||||||
int width,
|
int width,
|
||||||
int height)
|
int height)
|
||||||
@ -224,9 +222,9 @@ namespace MediaBrowser.Providers.Music
|
|||||||
{
|
{
|
||||||
cancellationToken.ThrowIfCancellationRequested();
|
cancellationToken.ThrowIfCancellationRequested();
|
||||||
|
|
||||||
var url = string.Format(FanArtBaseUrl, ApiKey, musicBrainzId);
|
var url = string.Format(BaseUrl, ApiKey, musicBrainzId);
|
||||||
|
|
||||||
var clientKey = FanartSeriesProvider.Current.GetFanartOptions().UserApiKey;
|
var clientKey = SeriesProvider.Current.GetOptions().ApiKey;
|
||||||
if (!string.IsNullOrWhiteSpace(clientKey))
|
if (!string.IsNullOrWhiteSpace(clientKey))
|
||||||
{
|
{
|
||||||
url += "&client_key=" + clientKey;
|
url += "&client_key=" + clientKey;
|
||||||
@ -259,7 +257,7 @@ namespace MediaBrowser.Providers.Music
|
|||||||
{
|
{
|
||||||
if (ex.StatusCode.HasValue && ex.StatusCode.Value == HttpStatusCode.NotFound)
|
if (ex.StatusCode.HasValue && ex.StatusCode.Value == HttpStatusCode.NotFound)
|
||||||
{
|
{
|
||||||
_jsonSerializer.SerializeToFile(new FanartArtistResponse(), jsonPath);
|
_jsonSerializer.SerializeToFile(new ArtistResponse(), jsonPath);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -301,7 +299,7 @@ namespace MediaBrowser.Providers.Music
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public class FanartArtistImage
|
public class ArtistImage
|
||||||
{
|
{
|
||||||
public string id { get; set; }
|
public string id { get; set; }
|
||||||
public string url { get; set; }
|
public string url { get; set; }
|
||||||
@ -314,21 +312,21 @@ namespace MediaBrowser.Providers.Music
|
|||||||
public class Album
|
public class Album
|
||||||
{
|
{
|
||||||
public string release_group_id { get; set; }
|
public string release_group_id { get; set; }
|
||||||
public List<FanartArtistImage> cdart { get; set; }
|
public List<ArtistImage> cdart { get; set; }
|
||||||
public List<FanartArtistImage> albumcover { get; set; }
|
public List<ArtistImage> albumcover { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class FanartArtistResponse
|
public class ArtistResponse
|
||||||
{
|
{
|
||||||
public string name { get; set; }
|
public string name { get; set; }
|
||||||
public string mbid_id { get; set; }
|
public string mbid_id { get; set; }
|
||||||
public List<FanartArtistImage> artistthumb { get; set; }
|
public List<ArtistImage> artistthumb { get; set; }
|
||||||
public List<FanartArtistImage> artistbackground { get; set; }
|
public List<ArtistImage> artistbackground { get; set; }
|
||||||
public List<FanartArtistImage> hdmusiclogo { get; set; }
|
public List<ArtistImage> hdmusiclogo { get; set; }
|
||||||
public List<FanartArtistImage> musicbanner { get; set; }
|
public List<ArtistImage> musicbanner { get; set; }
|
||||||
public List<FanartArtistImage> musiclogo { get; set; }
|
public List<ArtistImage> musiclogo { get; set; }
|
||||||
public List<FanartArtistImage> musicarts { get; set; }
|
public List<ArtistImage> musicarts { get; set; }
|
||||||
public List<FanartArtistImage> hdmusicarts { get; set; }
|
public List<ArtistImage> hdmusicarts { get; set; }
|
||||||
public List<Album> albums { get; set; }
|
public List<Album> albums { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -18,13 +18,10 @@ using MediaBrowser.Model.IO;
|
|||||||
using MediaBrowser.Model.Net;
|
using MediaBrowser.Model.Net;
|
||||||
using MediaBrowser.Model.Providers;
|
using MediaBrowser.Model.Providers;
|
||||||
using MediaBrowser.Model.Serialization;
|
using MediaBrowser.Model.Serialization;
|
||||||
using MediaBrowser.Providers.Music;
|
|
||||||
using MediaBrowser.Providers.TV;
|
|
||||||
using MediaBrowser.Providers.TV.FanArt;
|
|
||||||
|
|
||||||
namespace MediaBrowser.Providers.Movies
|
namespace Jellyfin.Plugin.Fanart.Providers
|
||||||
{
|
{
|
||||||
public class FanartMovieImageProvider : IRemoteImageProvider, IHasOrder
|
public class MovieProvider : IRemoteImageProvider, IHasOrder
|
||||||
{
|
{
|
||||||
private readonly CultureInfo _usCulture = new CultureInfo("en-US");
|
private readonly CultureInfo _usCulture = new CultureInfo("en-US");
|
||||||
private readonly IServerConfigurationManager _config;
|
private readonly IServerConfigurationManager _config;
|
||||||
@ -32,11 +29,11 @@ namespace MediaBrowser.Providers.Movies
|
|||||||
private readonly IFileSystem _fileSystem;
|
private readonly IFileSystem _fileSystem;
|
||||||
private readonly IJsonSerializer _json;
|
private readonly IJsonSerializer _json;
|
||||||
|
|
||||||
private const string FanArtBaseUrl = "https://webservice.fanart.tv/v3/movies/{1}?api_key={0}";
|
private const string BaseUrl = "https://webservice.fanart.tv/v3/movies/{1}?api_key={0}";
|
||||||
|
|
||||||
internal static FanartMovieImageProvider Current;
|
internal static MovieProvider Current;
|
||||||
|
|
||||||
public FanartMovieImageProvider(IServerConfigurationManager config, IHttpClient httpClient, IFileSystem fileSystem, IJsonSerializer json)
|
public MovieProvider(IServerConfigurationManager config, IHttpClient httpClient, IFileSystem fileSystem, IJsonSerializer json)
|
||||||
{
|
{
|
||||||
_config = config;
|
_config = config;
|
||||||
_httpClient = httpClient;
|
_httpClient = httpClient;
|
||||||
@ -48,7 +45,7 @@ namespace MediaBrowser.Providers.Movies
|
|||||||
|
|
||||||
public string Name => ProviderName;
|
public string Name => ProviderName;
|
||||||
|
|
||||||
public static string ProviderName => "FanArt";
|
public static string ProviderName => "Fanart";
|
||||||
|
|
||||||
public bool Supports(BaseItem item)
|
public bool Supports(BaseItem item)
|
||||||
{
|
{
|
||||||
@ -91,7 +88,7 @@ namespace MediaBrowser.Providers.Movies
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var path = GetFanartJsonPath(movieId);
|
var path = GetJsonPath(movieId);
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@ -229,7 +226,7 @@ namespace MediaBrowser.Providers.Movies
|
|||||||
return dataPath;
|
return dataPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
public string GetFanartJsonPath(string id)
|
public string GetJsonPath(string id)
|
||||||
{
|
{
|
||||||
var movieDataPath = GetMovieDataPath(_config.ApplicationPaths, id);
|
var movieDataPath = GetMovieDataPath(_config.ApplicationPaths, id);
|
||||||
return Path.Combine(movieDataPath, "fanart.json");
|
return Path.Combine(movieDataPath, "fanart.json");
|
||||||
@ -245,15 +242,15 @@ namespace MediaBrowser.Providers.Movies
|
|||||||
{
|
{
|
||||||
cancellationToken.ThrowIfCancellationRequested();
|
cancellationToken.ThrowIfCancellationRequested();
|
||||||
|
|
||||||
var url = string.Format(FanArtBaseUrl, FanartArtistProvider.ApiKey, id);
|
var url = string.Format(BaseUrl, ArtistProvider.ApiKey, id);
|
||||||
|
|
||||||
var clientKey = FanartSeriesProvider.Current.GetFanartOptions().UserApiKey;
|
var clientKey = SeriesProvider.Current.GetOptions().ApiKey;
|
||||||
if (!string.IsNullOrWhiteSpace(clientKey))
|
if (!string.IsNullOrWhiteSpace(clientKey))
|
||||||
{
|
{
|
||||||
url += "&client_key=" + clientKey;
|
url += "&client_key=" + clientKey;
|
||||||
}
|
}
|
||||||
|
|
||||||
var path = GetFanartJsonPath(id);
|
var path = GetJsonPath(id);
|
||||||
|
|
||||||
Directory.CreateDirectory(Path.GetDirectoryName(path));
|
Directory.CreateDirectory(Path.GetDirectoryName(path));
|
||||||
|
|
||||||
@ -292,7 +289,7 @@ namespace MediaBrowser.Providers.Movies
|
|||||||
|
|
||||||
internal Task EnsureMovieJson(string id, CancellationToken cancellationToken)
|
internal Task EnsureMovieJson(string id, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
var path = GetFanartJsonPath(id);
|
var path = GetJsonPath(id);
|
||||||
|
|
||||||
var fileInfo = _fileSystem.GetFileSystemInfo(path);
|
var fileInfo = _fileSystem.GetFileSystemInfo(path);
|
||||||
|
|
@ -19,9 +19,9 @@ using MediaBrowser.Model.Net;
|
|||||||
using MediaBrowser.Model.Providers;
|
using MediaBrowser.Model.Providers;
|
||||||
using MediaBrowser.Model.Serialization;
|
using MediaBrowser.Model.Serialization;
|
||||||
|
|
||||||
namespace MediaBrowser.Providers.TV.FanArt
|
namespace Jellyfin.Plugin.Fanart.Providers
|
||||||
{
|
{
|
||||||
public class FanArtSeasonProvider : IRemoteImageProvider, IHasOrder
|
public class SeasonProvider : IRemoteImageProvider, IHasOrder
|
||||||
{
|
{
|
||||||
private readonly CultureInfo _usCulture = new CultureInfo("en-US");
|
private readonly CultureInfo _usCulture = new CultureInfo("en-US");
|
||||||
private readonly IServerConfigurationManager _config;
|
private readonly IServerConfigurationManager _config;
|
||||||
@ -29,7 +29,7 @@ namespace MediaBrowser.Providers.TV.FanArt
|
|||||||
private readonly IFileSystem _fileSystem;
|
private readonly IFileSystem _fileSystem;
|
||||||
private readonly IJsonSerializer _json;
|
private readonly IJsonSerializer _json;
|
||||||
|
|
||||||
public FanArtSeasonProvider(IServerConfigurationManager config, IHttpClient httpClient, IFileSystem fileSystem, IJsonSerializer json)
|
public SeasonProvider(IServerConfigurationManager config, IHttpClient httpClient, IFileSystem fileSystem, IJsonSerializer json)
|
||||||
{
|
{
|
||||||
_config = config;
|
_config = config;
|
||||||
_httpClient = httpClient;
|
_httpClient = httpClient;
|
||||||
@ -39,7 +39,7 @@ namespace MediaBrowser.Providers.TV.FanArt
|
|||||||
|
|
||||||
public string Name => ProviderName;
|
public string Name => ProviderName;
|
||||||
|
|
||||||
public static string ProviderName => "FanArt";
|
public static string ProviderName => "Fanart";
|
||||||
|
|
||||||
public bool Supports(BaseItem item)
|
public bool Supports(BaseItem item)
|
||||||
{
|
{
|
||||||
@ -73,7 +73,7 @@ namespace MediaBrowser.Providers.TV.FanArt
|
|||||||
// Bad id entered
|
// Bad id entered
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
await FanartSeriesProvider.Current.EnsureSeriesJson(id, cancellationToken).ConfigureAwait(false);
|
await SeriesProvider.Current.EnsureSeriesJson(id, cancellationToken).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
catch (HttpException ex)
|
catch (HttpException ex)
|
||||||
{
|
{
|
||||||
@ -83,7 +83,7 @@ namespace MediaBrowser.Providers.TV.FanArt
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var path = FanartSeriesProvider.Current.GetFanartJsonPath(id);
|
var path = SeriesProvider.Current.GetJsonPath(id);
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@ -131,12 +131,12 @@ namespace MediaBrowser.Providers.TV.FanArt
|
|||||||
|
|
||||||
private void AddImages(List<RemoteImageInfo> list, int seasonNumber, string path, CancellationToken cancellationToken)
|
private void AddImages(List<RemoteImageInfo> list, int seasonNumber, string path, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
var root = _json.DeserializeFromFile<FanartSeriesProvider.RootObject>(path);
|
var root = _json.DeserializeFromFile<SeriesProvider.RootObject>(path);
|
||||||
|
|
||||||
AddImages(list, root, seasonNumber, cancellationToken);
|
AddImages(list, root, seasonNumber, cancellationToken);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void AddImages(List<RemoteImageInfo> list, FanartSeriesProvider.RootObject obj, int seasonNumber, CancellationToken cancellationToken)
|
private void AddImages(List<RemoteImageInfo> list, SeriesProvider.RootObject obj, int seasonNumber, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
PopulateImages(list, obj.seasonposter, ImageType.Primary, 1000, 1426, seasonNumber);
|
PopulateImages(list, obj.seasonposter, ImageType.Primary, 1000, 1426, seasonNumber);
|
||||||
PopulateImages(list, obj.seasonbanner, ImageType.Banner, 1000, 185, seasonNumber);
|
PopulateImages(list, obj.seasonbanner, ImageType.Banner, 1000, 185, seasonNumber);
|
||||||
@ -145,7 +145,7 @@ namespace MediaBrowser.Providers.TV.FanArt
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void PopulateImages(List<RemoteImageInfo> list,
|
private void PopulateImages(List<RemoteImageInfo> list,
|
||||||
List<FanartSeriesProvider.Image> images,
|
List<SeriesProvider.Image> images,
|
||||||
ImageType type,
|
ImageType type,
|
||||||
int width,
|
int width,
|
||||||
int height,
|
int height,
|
@ -6,6 +6,7 @@ using System.Linq;
|
|||||||
using System.Net;
|
using System.Net;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using Jellyfin.Plugin.Fanart.Configuration;
|
||||||
using MediaBrowser.Common.Configuration;
|
using MediaBrowser.Common.Configuration;
|
||||||
using MediaBrowser.Common.Net;
|
using MediaBrowser.Common.Net;
|
||||||
using MediaBrowser.Controller.Configuration;
|
using MediaBrowser.Controller.Configuration;
|
||||||
@ -20,11 +21,10 @@ using MediaBrowser.Model.IO;
|
|||||||
using MediaBrowser.Model.Net;
|
using MediaBrowser.Model.Net;
|
||||||
using MediaBrowser.Model.Providers;
|
using MediaBrowser.Model.Providers;
|
||||||
using MediaBrowser.Model.Serialization;
|
using MediaBrowser.Model.Serialization;
|
||||||
using MediaBrowser.Providers.Music;
|
|
||||||
|
|
||||||
namespace MediaBrowser.Providers.TV.FanArt
|
namespace Jellyfin.Plugin.Fanart.Providers
|
||||||
{
|
{
|
||||||
public class FanartSeriesProvider : IRemoteImageProvider, IHasOrder
|
public class SeriesProvider : IRemoteImageProvider, IHasOrder
|
||||||
{
|
{
|
||||||
private readonly CultureInfo _usCulture = new CultureInfo("en-US");
|
private readonly CultureInfo _usCulture = new CultureInfo("en-US");
|
||||||
private readonly IServerConfigurationManager _config;
|
private readonly IServerConfigurationManager _config;
|
||||||
@ -32,11 +32,11 @@ namespace MediaBrowser.Providers.TV.FanArt
|
|||||||
private readonly IFileSystem _fileSystem;
|
private readonly IFileSystem _fileSystem;
|
||||||
private readonly IJsonSerializer _json;
|
private readonly IJsonSerializer _json;
|
||||||
|
|
||||||
private const string FanArtBaseUrl = "https://webservice.fanart.tv/v3/tv/{1}?api_key={0}";
|
private const string BaseUrl = "https://webservice.fanart.tv/v3/tv/{1}?api_key={0}";
|
||||||
|
|
||||||
internal static FanartSeriesProvider Current { get; private set; }
|
internal static SeriesProvider Current { get; private set; }
|
||||||
|
|
||||||
public FanartSeriesProvider(IServerConfigurationManager config, IHttpClient httpClient, IFileSystem fileSystem, IJsonSerializer json)
|
public SeriesProvider(IServerConfigurationManager config, IHttpClient httpClient, IFileSystem fileSystem, IJsonSerializer json)
|
||||||
{
|
{
|
||||||
_config = config;
|
_config = config;
|
||||||
_httpClient = httpClient;
|
_httpClient = httpClient;
|
||||||
@ -48,7 +48,10 @@ namespace MediaBrowser.Providers.TV.FanArt
|
|||||||
|
|
||||||
public string Name => ProviderName;
|
public string Name => ProviderName;
|
||||||
|
|
||||||
public static string ProviderName => "FanArt";
|
public static string ProviderName => "Fanart";
|
||||||
|
|
||||||
|
public PluginConfiguration GetOptions()
|
||||||
|
=> Plugin.Instance.Configuration;
|
||||||
|
|
||||||
public bool Supports(BaseItem item)
|
public bool Supports(BaseItem item)
|
||||||
{
|
{
|
||||||
@ -91,7 +94,7 @@ namespace MediaBrowser.Providers.TV.FanArt
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var path = GetFanartJsonPath(id);
|
var path = GetJsonPath(id);
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@ -239,7 +242,7 @@ namespace MediaBrowser.Providers.TV.FanArt
|
|||||||
return dataPath;
|
return dataPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
public string GetFanartJsonPath(string tvdbId)
|
public string GetJsonPath(string tvdbId)
|
||||||
{
|
{
|
||||||
var dataPath = GetSeriesDataPath(_config.ApplicationPaths, tvdbId);
|
var dataPath = GetSeriesDataPath(_config.ApplicationPaths, tvdbId);
|
||||||
return Path.Combine(dataPath, "fanart.json");
|
return Path.Combine(dataPath, "fanart.json");
|
||||||
@ -248,7 +251,7 @@ namespace MediaBrowser.Providers.TV.FanArt
|
|||||||
private readonly SemaphoreSlim _ensureSemaphore = new SemaphoreSlim(1, 1);
|
private readonly SemaphoreSlim _ensureSemaphore = new SemaphoreSlim(1, 1);
|
||||||
internal async Task EnsureSeriesJson(string tvdbId, CancellationToken cancellationToken)
|
internal async Task EnsureSeriesJson(string tvdbId, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
var path = GetFanartJsonPath(tvdbId);
|
var path = GetJsonPath(tvdbId);
|
||||||
|
|
||||||
// Only allow one thread in here at a time since every season will be calling this method, possibly concurrently
|
// Only allow one thread in here at a time since every season will be calling this method, possibly concurrently
|
||||||
await _ensureSemaphore.WaitAsync(cancellationToken).ConfigureAwait(false);
|
await _ensureSemaphore.WaitAsync(cancellationToken).ConfigureAwait(false);
|
||||||
@ -273,11 +276,6 @@ namespace MediaBrowser.Providers.TV.FanArt
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public FanartOptions GetFanartOptions()
|
|
||||||
{
|
|
||||||
return _config.GetConfiguration<FanartOptions>("fanart");
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Downloads the series json.
|
/// Downloads the series json.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -288,15 +286,15 @@ namespace MediaBrowser.Providers.TV.FanArt
|
|||||||
{
|
{
|
||||||
cancellationToken.ThrowIfCancellationRequested();
|
cancellationToken.ThrowIfCancellationRequested();
|
||||||
|
|
||||||
var url = string.Format(FanArtBaseUrl, FanartArtistProvider.ApiKey, tvdbId);
|
var url = string.Format(BaseUrl, ArtistProvider.ApiKey, tvdbId);
|
||||||
|
|
||||||
var clientKey = GetFanartOptions().UserApiKey;
|
var clientKey = GetOptions().ApiKey;
|
||||||
if (!string.IsNullOrWhiteSpace(clientKey))
|
if (!string.IsNullOrWhiteSpace(clientKey))
|
||||||
{
|
{
|
||||||
url += "&client_key=" + clientKey;
|
url += "&client_key=" + clientKey;
|
||||||
}
|
}
|
||||||
|
|
||||||
var path = GetFanartJsonPath(tvdbId);
|
var path = GetJsonPath(tvdbId);
|
||||||
|
|
||||||
Directory.CreateDirectory(Path.GetDirectoryName(path));
|
Directory.CreateDirectory(Path.GetDirectoryName(path));
|
||||||
|
|
||||||
@ -360,19 +358,4 @@ namespace MediaBrowser.Providers.TV.FanArt
|
|||||||
public List<Image> seasonbanner { get; set; }
|
public List<Image> seasonbanner { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class FanartConfigStore : IConfigurationFactory
|
|
||||||
{
|
|
||||||
public IEnumerable<ConfigurationStore> GetConfigurations()
|
|
||||||
{
|
|
||||||
return new ConfigurationStore[]
|
|
||||||
{
|
|
||||||
new ConfigurationStore
|
|
||||||
{
|
|
||||||
Key = "fanart",
|
|
||||||
ConfigurationType = typeof(FanartOptions)
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user