mirror of
https://github.com/jellyfin/jellyfin-plugin-fanart.git
synced 2024-11-26 23:20:31 +00:00
Merge pull request #37 from Shadowghost/album-fix
This commit is contained in:
commit
8a3385a29e
14
Jellyfin.Plugin.Fanart/Dtos/Album.cs
Normal file
14
Jellyfin.Plugin.Fanart/Dtos/Album.cs
Normal file
@ -0,0 +1,14 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace Jellyfin.Plugin.Fanart.Dtos
|
||||
{
|
||||
public class Album
|
||||
{
|
||||
[JsonPropertyName("cdart")]
|
||||
public List<ArtistImage> CdArts { get; set; }
|
||||
|
||||
[JsonPropertyName("albumcover")]
|
||||
public List<ArtistImage> AlbumCovers { get; set; }
|
||||
}
|
||||
}
|
25
Jellyfin.Plugin.Fanart/Dtos/ArtistImage.cs
Normal file
25
Jellyfin.Plugin.Fanart/Dtos/ArtistImage.cs
Normal file
@ -0,0 +1,25 @@
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace Jellyfin.Plugin.Fanart.Dtos
|
||||
{
|
||||
public class ArtistImage
|
||||
{
|
||||
[JsonPropertyName("id")]
|
||||
public string Id { get; set; }
|
||||
|
||||
[JsonPropertyName("url")]
|
||||
public string Url { get; set; }
|
||||
|
||||
[JsonPropertyName("likes")]
|
||||
public string Likes { get; set; }
|
||||
|
||||
[JsonPropertyName("disc")]
|
||||
public string Disc { get; set; }
|
||||
|
||||
[JsonPropertyName("size")]
|
||||
public string Size { get; set; }
|
||||
|
||||
[JsonPropertyName("lang")]
|
||||
public string Language { get; set; }
|
||||
}
|
||||
}
|
38
Jellyfin.Plugin.Fanart/Dtos/ArtistResponse.cs
Normal file
38
Jellyfin.Plugin.Fanart/Dtos/ArtistResponse.cs
Normal file
@ -0,0 +1,38 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace Jellyfin.Plugin.Fanart.Dtos
|
||||
{
|
||||
public class ArtistResponse
|
||||
{
|
||||
[JsonPropertyName("name")]
|
||||
public string Name { get; set; }
|
||||
|
||||
[JsonPropertyName("mbid_id")]
|
||||
public string MusicBrainzId { get; set; }
|
||||
|
||||
[JsonPropertyName("artistthumb")]
|
||||
public List<ArtistImage> ArtistThumbs { get; set; }
|
||||
|
||||
[JsonPropertyName("artistbackground")]
|
||||
public List<ArtistImage> ArtistBackgrounds { get; set; }
|
||||
|
||||
[JsonPropertyName("hdmusiclogo")]
|
||||
public List<ArtistImage> HdMusicLogos { get; set; }
|
||||
|
||||
[JsonPropertyName("musicbanner")]
|
||||
public List<ArtistImage> MusicBanners { get; set; }
|
||||
|
||||
[JsonPropertyName("musiclogo")]
|
||||
public List<ArtistImage> MusicLogos { get; set; }
|
||||
|
||||
[JsonPropertyName("musicarts")]
|
||||
public List<ArtistImage> MusicArts { get; set; }
|
||||
|
||||
[JsonPropertyName("hdmusicarts")]
|
||||
public List<ArtistImage> HdmusicArts { get; set; }
|
||||
|
||||
[JsonPropertyName("albums")]
|
||||
public Dictionary<string, Album> Albums { get; set; }
|
||||
}
|
||||
}
|
19
Jellyfin.Plugin.Fanart/Dtos/MovieImage.cs
Normal file
19
Jellyfin.Plugin.Fanart/Dtos/MovieImage.cs
Normal file
@ -0,0 +1,19 @@
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace Jellyfin.Plugin.Fanart.Dtos
|
||||
{
|
||||
public class MovieImage
|
||||
{
|
||||
[JsonPropertyName("id")]
|
||||
public string Id { get; set; }
|
||||
|
||||
[JsonPropertyName("url")]
|
||||
public string Url { get; set; }
|
||||
|
||||
[JsonPropertyName("lang")]
|
||||
public string Language { get; set; }
|
||||
|
||||
[JsonPropertyName("likes")]
|
||||
public string Likes { get; set; }
|
||||
}
|
||||
}
|
44
Jellyfin.Plugin.Fanart/Dtos/MovieRootObject.cs
Normal file
44
Jellyfin.Plugin.Fanart/Dtos/MovieRootObject.cs
Normal file
@ -0,0 +1,44 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace Jellyfin.Plugin.Fanart.Dtos
|
||||
{
|
||||
public class MovieRootObject
|
||||
{
|
||||
[JsonPropertyName("name")]
|
||||
public string Name { get; set; }
|
||||
|
||||
[JsonPropertyName("tmdb_id")]
|
||||
public string TmbdId { get; set; }
|
||||
|
||||
[JsonPropertyName("imdb_id")]
|
||||
public string ImdbId { get; set; }
|
||||
|
||||
[JsonPropertyName("hdmovielogo")]
|
||||
public List<MovieImage> HdMovieLogos { get; set; }
|
||||
|
||||
[JsonPropertyName("moviedisc")]
|
||||
public List<MovieImage> MovieDiscImages { get; set; }
|
||||
|
||||
[JsonPropertyName("movielogo")]
|
||||
public List<MovieImage> MovieLogos { get; set; }
|
||||
|
||||
[JsonPropertyName("movieposter")]
|
||||
public List<MovieImage> MoviePosters { get; set; }
|
||||
|
||||
[JsonPropertyName("hdmovieclearart")]
|
||||
public List<MovieImage> HdMovieClearArts { get; set; }
|
||||
|
||||
[JsonPropertyName("movieart")]
|
||||
public List<MovieImage> MovieArts { get; set; }
|
||||
|
||||
[JsonPropertyName("moviebackground")]
|
||||
public List<MovieImage> MovieBackgrounds { get; set; }
|
||||
|
||||
[JsonPropertyName("moviebanner")]
|
||||
public List<MovieImage> MovieBanners { get; set; }
|
||||
|
||||
[JsonPropertyName("moviethumb")]
|
||||
public List<MovieImage> MovieThumbs { get; set; }
|
||||
}
|
||||
}
|
23
Jellyfin.Plugin.Fanart/Dtos/SeriesImage.cs
Normal file
23
Jellyfin.Plugin.Fanart/Dtos/SeriesImage.cs
Normal file
@ -0,0 +1,23 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace Jellyfin.Plugin.Fanart.Dtos
|
||||
{
|
||||
public class SeriesImage
|
||||
{
|
||||
[JsonPropertyName("id")]
|
||||
public string Id { get; set; }
|
||||
|
||||
[JsonPropertyName("url")]
|
||||
public string Url { get; set; }
|
||||
|
||||
[JsonPropertyName("lang")]
|
||||
public string Language { get; set; }
|
||||
|
||||
[JsonPropertyName("likes")]
|
||||
public string Likes { get; set; }
|
||||
|
||||
[JsonPropertyName("season")]
|
||||
public string Season { get; set; }
|
||||
}
|
||||
}
|
50
Jellyfin.Plugin.Fanart/Dtos/SeriesRootObject.cs
Normal file
50
Jellyfin.Plugin.Fanart/Dtos/SeriesRootObject.cs
Normal file
@ -0,0 +1,50 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace Jellyfin.Plugin.Fanart.Dtos
|
||||
{
|
||||
public class SeriesRootObject
|
||||
{
|
||||
[JsonPropertyName("name")]
|
||||
public string Name { get; set; }
|
||||
|
||||
[JsonPropertyName("thetvdb_id")]
|
||||
public string TheTvDbId { get; set; }
|
||||
|
||||
[JsonPropertyName("clearlogo")]
|
||||
public List<SeriesImage> ClearLogos { get; set; }
|
||||
|
||||
[JsonPropertyName("hdtvlogo")]
|
||||
public List<SeriesImage> HdTvLogos { get; set; }
|
||||
|
||||
[JsonPropertyName("clearart")]
|
||||
public List<SeriesImage> ClearArts { get; set; }
|
||||
|
||||
[JsonPropertyName("showbackground")]
|
||||
public List<SeriesImage> Showbackgrounds { get; set; }
|
||||
|
||||
[JsonPropertyName("tvthumb")]
|
||||
public List<SeriesImage> TvThumbs { get; set; }
|
||||
|
||||
[JsonPropertyName("seasonposter")]
|
||||
public List<SeriesImage> SeasonPosters { get; set; }
|
||||
|
||||
[JsonPropertyName("seasonthumb")]
|
||||
public List<SeriesImage> SeasonThumbs { get; set; }
|
||||
|
||||
[JsonPropertyName("hdclearart")]
|
||||
public List<SeriesImage> HdClearArts { get; set; }
|
||||
|
||||
[JsonPropertyName("tvbanner")]
|
||||
public List<SeriesImage> TvBanners { get; set; }
|
||||
|
||||
[JsonPropertyName("characterart")]
|
||||
public List<SeriesImage> CharacterArts { get; set; }
|
||||
|
||||
[JsonPropertyName("tvposter")]
|
||||
public List<SeriesImage> TvPosters { get; set; }
|
||||
|
||||
[JsonPropertyName("seasonbanner")]
|
||||
public List<SeriesImage> SeasonBanners { get; set; }
|
||||
}
|
||||
}
|
@ -8,6 +8,7 @@ using System.Text.Json;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Jellyfin.Extensions.Json;
|
||||
using Jellyfin.Plugin.Fanart.Dtos;
|
||||
using MediaBrowser.Common.Net;
|
||||
using MediaBrowser.Controller.Configuration;
|
||||
using MediaBrowser.Controller.Entities;
|
||||
@ -57,28 +58,26 @@ namespace Jellyfin.Plugin.Fanart.Providers
|
||||
|
||||
var list = new List<RemoteImageInfo>();
|
||||
|
||||
var musicArtist = album.MusicArtist;
|
||||
var musicBrainzAlbumArtist = album.GetProviderId(MetadataProvider.MusicBrainzAlbumArtist);
|
||||
|
||||
if (musicArtist == null)
|
||||
if (musicBrainzAlbumArtist == null)
|
||||
{
|
||||
return list;
|
||||
}
|
||||
|
||||
var artistMusicBrainzId = musicArtist.GetProviderId(MetadataProvider.MusicBrainzArtist);
|
||||
|
||||
if (!string.IsNullOrEmpty(artistMusicBrainzId))
|
||||
if (!string.IsNullOrEmpty(musicBrainzAlbumArtist))
|
||||
{
|
||||
await ArtistProvider.Current.EnsureArtistJson(artistMusicBrainzId, cancellationToken).ConfigureAwait(false);
|
||||
await ArtistProvider.Current.EnsureArtistJson(musicBrainzAlbumArtist, cancellationToken).ConfigureAwait(false);
|
||||
|
||||
var artistJsonPath = ArtistProvider.GetArtistJsonPath(_config.CommonApplicationPaths, artistMusicBrainzId);
|
||||
var artistJsonPath = ArtistProvider.GetArtistJsonPath(_config.CommonApplicationPaths, musicBrainzAlbumArtist);
|
||||
|
||||
var musicBrainzReleaseGroupId = album.GetProviderId(MetadataProvider.MusicBrainzReleaseGroup);
|
||||
var musicBrainzReleaseGroup = album.GetProviderId(MetadataProvider.MusicBrainzReleaseGroup);
|
||||
|
||||
var musicBrainzId = album.GetProviderId(MetadataProvider.MusicBrainzAlbum);
|
||||
var musicBrainzAlbum = album.GetProviderId(MetadataProvider.MusicBrainzAlbum);
|
||||
|
||||
try
|
||||
{
|
||||
await AddImages(list, artistJsonPath, musicBrainzId, musicBrainzReleaseGroupId, cancellationToken).ConfigureAwait(false);
|
||||
await AddImages(list, artistJsonPath, musicBrainzAlbum, musicBrainzReleaseGroup, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
catch (FileNotFoundException)
|
||||
{
|
||||
@ -133,23 +132,29 @@ namespace Jellyfin.Plugin.Fanart.Providers
|
||||
private async Task AddImages(List<RemoteImageInfo> list, string path, string releaseId, string releaseGroupId, CancellationToken cancellationToken)
|
||||
{
|
||||
Stream fileStream = File.OpenRead(path);
|
||||
var obj = await JsonSerializer.DeserializeAsync<ArtistProvider.ArtistResponse>(fileStream, JsonDefaults.Options).ConfigureAwait(false);
|
||||
var obj = await JsonSerializer.DeserializeAsync<ArtistResponse>(fileStream, JsonDefaults.Options).ConfigureAwait(false);
|
||||
|
||||
if (obj.albums != null)
|
||||
if (obj.Albums != null)
|
||||
{
|
||||
var album = obj.albums.FirstOrDefault(i => string.Equals(i.release_group_id, releaseGroupId, StringComparison.OrdinalIgnoreCase));
|
||||
var album = obj.Albums.FirstOrDefault(i => string.Equals(i.Key, releaseId, StringComparison.OrdinalIgnoreCase) || string.Equals(i.Key, releaseGroupId, StringComparison.OrdinalIgnoreCase));
|
||||
var albumcovers = album.Value.AlbumCovers;
|
||||
var cdarts = album.Value.CdArts;
|
||||
|
||||
if (album != null)
|
||||
if (albumcovers != null)
|
||||
{
|
||||
PopulateImages(list, album.albumcover, ImageType.Primary, 1000, 1000);
|
||||
PopulateImages(list, album.cdart, ImageType.Disc, 1000, 1000);
|
||||
PopulateImages(list, albumcovers, ImageType.Primary, 1000, 1000);
|
||||
}
|
||||
|
||||
if (cdarts != null)
|
||||
{
|
||||
PopulateImages(list, cdarts, ImageType.Disc, 1000, 1000);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void PopulateImages(
|
||||
List<RemoteImageInfo> list,
|
||||
List<ArtistProvider.ArtistImage> images,
|
||||
List<ArtistImage> images,
|
||||
ImageType type,
|
||||
int width,
|
||||
int height)
|
||||
@ -161,11 +166,11 @@ namespace Jellyfin.Plugin.Fanart.Providers
|
||||
|
||||
list.AddRange(images.Select(i =>
|
||||
{
|
||||
var url = i.url;
|
||||
var url = i.Url;
|
||||
|
||||
if (!string.IsNullOrEmpty(url))
|
||||
{
|
||||
var likesString = i.likes;
|
||||
var likesString = i.Likes;
|
||||
|
||||
var info = new RemoteImageInfo
|
||||
{
|
||||
@ -175,7 +180,7 @@ namespace Jellyfin.Plugin.Fanart.Providers
|
||||
Height = height,
|
||||
ProviderName = Name,
|
||||
Url = url.Replace("http://", "https://", StringComparison.OrdinalIgnoreCase),
|
||||
Language = i.lang
|
||||
Language = i.Language
|
||||
};
|
||||
|
||||
if (!string.IsNullOrEmpty(likesString)
|
||||
|
@ -9,6 +9,7 @@ using System.Text.Json;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Jellyfin.Extensions.Json;
|
||||
using Jellyfin.Plugin.Fanart.Dtos;
|
||||
using MediaBrowser.Common.Configuration;
|
||||
using MediaBrowser.Common.Net;
|
||||
using MediaBrowser.Controller.Configuration;
|
||||
@ -134,13 +135,13 @@ namespace Jellyfin.Plugin.Fanart.Providers
|
||||
Stream fileStream = File.OpenRead(path);
|
||||
var obj = await JsonSerializer.DeserializeAsync<ArtistResponse>(fileStream, JsonDefaults.Options).ConfigureAwait(false);
|
||||
|
||||
PopulateImages(list, obj.artistbackground, ImageType.Backdrop, 1920, 1080);
|
||||
PopulateImages(list, obj.artistthumb, ImageType.Primary, 500, 281);
|
||||
PopulateImages(list, obj.hdmusiclogo, ImageType.Logo, 800, 310);
|
||||
PopulateImages(list, obj.musicbanner, ImageType.Banner, 1000, 185);
|
||||
PopulateImages(list, obj.musiclogo, ImageType.Logo, 400, 155);
|
||||
PopulateImages(list, obj.hdmusicarts, ImageType.Art, 1000, 562);
|
||||
PopulateImages(list, obj.musicarts, ImageType.Art, 500, 281);
|
||||
PopulateImages(list, obj.ArtistBackgrounds, ImageType.Backdrop, 1920, 1080);
|
||||
PopulateImages(list, obj.ArtistThumbs, ImageType.Primary, 500, 281);
|
||||
PopulateImages(list, obj.HdMusicLogos, ImageType.Logo, 800, 310);
|
||||
PopulateImages(list, obj.MusicBanners, ImageType.Banner, 1000, 185);
|
||||
PopulateImages(list, obj.MusicLogos, ImageType.Logo, 400, 155);
|
||||
PopulateImages(list, obj.HdmusicArts, ImageType.Art, 1000, 562);
|
||||
PopulateImages(list, obj.MusicArts, ImageType.Art, 500, 281);
|
||||
}
|
||||
|
||||
private void PopulateImages(
|
||||
@ -157,11 +158,11 @@ namespace Jellyfin.Plugin.Fanart.Providers
|
||||
|
||||
list.AddRange(images.Select(i =>
|
||||
{
|
||||
var url = i.url;
|
||||
var url = i.Url;
|
||||
|
||||
if (!string.IsNullOrEmpty(url))
|
||||
{
|
||||
var likesString = i.likes;
|
||||
var likesString = i.Likes;
|
||||
|
||||
var info = new RemoteImageInfo
|
||||
{
|
||||
@ -171,7 +172,7 @@ namespace Jellyfin.Plugin.Fanart.Providers
|
||||
Height = height,
|
||||
ProviderName = Name,
|
||||
Url = url.Replace("http://", "https://", StringComparison.OrdinalIgnoreCase),
|
||||
Language = i.lang
|
||||
Language = i.Language
|
||||
};
|
||||
|
||||
if (!string.IsNullOrEmpty(likesString)
|
||||
@ -290,52 +291,5 @@ namespace Jellyfin.Plugin.Fanart.Providers
|
||||
|
||||
return Path.Combine(dataPath, "fanart.json");
|
||||
}
|
||||
|
||||
public class ArtistImage
|
||||
{
|
||||
public string id { get; set; }
|
||||
|
||||
public string url { get; set; }
|
||||
|
||||
public string likes { get; set; }
|
||||
|
||||
public string disc { get; set; }
|
||||
|
||||
public string size { get; set; }
|
||||
|
||||
public string lang { get; set; }
|
||||
}
|
||||
|
||||
public class Album
|
||||
{
|
||||
public string release_group_id { get; set; }
|
||||
|
||||
public List<ArtistImage> cdart { get; set; }
|
||||
|
||||
public List<ArtistImage> albumcover { get; set; }
|
||||
}
|
||||
|
||||
public class ArtistResponse
|
||||
{
|
||||
public string name { get; set; }
|
||||
|
||||
public string mbid_id { get; set; }
|
||||
|
||||
public List<ArtistImage> artistthumb { get; set; }
|
||||
|
||||
public List<ArtistImage> artistbackground { get; set; }
|
||||
|
||||
public List<ArtistImage> hdmusiclogo { get; set; }
|
||||
|
||||
public List<ArtistImage> musicbanner { get; set; }
|
||||
|
||||
public List<ArtistImage> musiclogo { get; set; }
|
||||
|
||||
public List<ArtistImage> musicarts { get; set; }
|
||||
|
||||
public List<ArtistImage> hdmusicarts { get; set; }
|
||||
|
||||
public List<Album> albums { get; set; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -9,6 +9,7 @@ using System.Text.Json;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Jellyfin.Extensions.Json;
|
||||
using Jellyfin.Plugin.Fanart.Dtos;
|
||||
using MediaBrowser.Common.Configuration;
|
||||
using MediaBrowser.Common.Net;
|
||||
using MediaBrowser.Controller.Configuration;
|
||||
@ -66,7 +67,7 @@ namespace Jellyfin.Plugin.Fanart.Providers
|
||||
var baseItem = item;
|
||||
var list = new List<RemoteImageInfo>();
|
||||
|
||||
var movieId = baseItem.GetProviderId(MetadataProvider.Tmdb);
|
||||
var movieId = baseItem.GetProviderId(MetadataProvider.Tmdb) ?? baseItem.GetProviderId(MetadataProvider.Imdb);
|
||||
|
||||
if (!string.IsNullOrEmpty(movieId))
|
||||
{
|
||||
@ -133,25 +134,25 @@ namespace Jellyfin.Plugin.Fanart.Providers
|
||||
private async Task AddImages(List<RemoteImageInfo> list, string path)
|
||||
{
|
||||
Stream fileStream = File.OpenRead(path);
|
||||
var root = await JsonSerializer.DeserializeAsync<RootObject>(fileStream, JsonDefaults.Options).ConfigureAwait(false);
|
||||
var root = await JsonSerializer.DeserializeAsync<MovieRootObject>(fileStream, JsonDefaults.Options).ConfigureAwait(false);
|
||||
|
||||
AddImages(list, root);
|
||||
}
|
||||
|
||||
private void AddImages(List<RemoteImageInfo> list, RootObject obj)
|
||||
private void AddImages(List<RemoteImageInfo> list, MovieRootObject obj)
|
||||
{
|
||||
PopulateImages(list, obj.hdmovieclearart, ImageType.Art, 1000, 562);
|
||||
PopulateImages(list, obj.hdmovielogo, ImageType.Logo, 800, 310);
|
||||
PopulateImages(list, obj.moviedisc, ImageType.Disc, 1000, 1000);
|
||||
PopulateImages(list, obj.movieposter, ImageType.Primary, 1000, 1426);
|
||||
PopulateImages(list, obj.movielogo, ImageType.Logo, 400, 155);
|
||||
PopulateImages(list, obj.movieart, ImageType.Art, 500, 281);
|
||||
PopulateImages(list, obj.moviethumb, ImageType.Thumb, 1000, 562);
|
||||
PopulateImages(list, obj.moviebanner, ImageType.Banner, 1000, 185);
|
||||
PopulateImages(list, obj.moviebackground, ImageType.Backdrop, 1920, 1080);
|
||||
PopulateImages(list, obj.HdMovieClearArts, ImageType.Art, 1000, 562);
|
||||
PopulateImages(list, obj.HdMovieLogos, ImageType.Logo, 800, 310);
|
||||
PopulateImages(list, obj.MovieDiscImages, ImageType.Disc, 1000, 1000);
|
||||
PopulateImages(list, obj.MoviePosters, ImageType.Primary, 1000, 1426);
|
||||
PopulateImages(list, obj.MovieLogos, ImageType.Logo, 400, 155);
|
||||
PopulateImages(list, obj.MovieArts, ImageType.Art, 500, 281);
|
||||
PopulateImages(list, obj.MovieThumbs, ImageType.Thumb, 1000, 562);
|
||||
PopulateImages(list, obj.MovieBanners, ImageType.Banner, 1000, 185);
|
||||
PopulateImages(list, obj.MovieBackgrounds, ImageType.Backdrop, 1920, 1080);
|
||||
}
|
||||
|
||||
private void PopulateImages(List<RemoteImageInfo> list, List<Image> images, ImageType type, int width, int height)
|
||||
private void PopulateImages(List<RemoteImageInfo> list, List<MovieImage> images, ImageType type, int width, int height)
|
||||
{
|
||||
if (images == null)
|
||||
{
|
||||
@ -160,11 +161,11 @@ namespace Jellyfin.Plugin.Fanart.Providers
|
||||
|
||||
list.AddRange(images.Select(i =>
|
||||
{
|
||||
var url = i.url;
|
||||
var url = i.Url;
|
||||
|
||||
if (!string.IsNullOrEmpty(url))
|
||||
{
|
||||
var likesString = i.likes;
|
||||
var likesString = i.Likes;
|
||||
|
||||
var info = new RemoteImageInfo
|
||||
{
|
||||
@ -174,7 +175,7 @@ namespace Jellyfin.Plugin.Fanart.Providers
|
||||
Height = height,
|
||||
ProviderName = Name,
|
||||
Url = url,
|
||||
Language = i.lang
|
||||
Language = i.Language
|
||||
};
|
||||
|
||||
if (!string.IsNullOrEmpty(likesString)
|
||||
@ -270,7 +271,7 @@ namespace Jellyfin.Plugin.Fanart.Providers
|
||||
{
|
||||
// If the user has automatic updates enabled, save a dummy object to prevent repeated download attempts
|
||||
Stream fileStream = File.OpenWrite(path);
|
||||
await JsonSerializer.SerializeAsync(fileStream, new RootObject(), JsonDefaults.Options).ConfigureAwait(false);
|
||||
await JsonSerializer.SerializeAsync(fileStream, new MovieRootObject(), JsonDefaults.Options).ConfigureAwait(false);
|
||||
|
||||
return;
|
||||
}
|
||||
@ -293,43 +294,5 @@ namespace Jellyfin.Plugin.Fanart.Providers
|
||||
|
||||
return DownloadMovieJson(id, cancellationToken);
|
||||
}
|
||||
|
||||
public class Image
|
||||
{
|
||||
public string id { get; set; }
|
||||
|
||||
public string url { get; set; }
|
||||
|
||||
public string lang { get; set; }
|
||||
|
||||
public string likes { get; set; }
|
||||
}
|
||||
|
||||
public class RootObject
|
||||
{
|
||||
public string name { get; set; }
|
||||
|
||||
public string tmdb_id { get; set; }
|
||||
|
||||
public string imdb_id { get; set; }
|
||||
|
||||
public List<Image> hdmovielogo { get; set; }
|
||||
|
||||
public List<Image> moviedisc { get; set; }
|
||||
|
||||
public List<Image> movielogo { get; set; }
|
||||
|
||||
public List<Image> movieposter { get; set; }
|
||||
|
||||
public List<Image> hdmovieclearart { get; set; }
|
||||
|
||||
public List<Image> movieart { get; set; }
|
||||
|
||||
public List<Image> moviebackground { get; set; }
|
||||
|
||||
public List<Image> moviebanner { get; set; }
|
||||
|
||||
public List<Image> moviethumb { get; set; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -9,6 +9,7 @@ using System.Text.Json;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Jellyfin.Extensions.Json;
|
||||
using Jellyfin.Plugin.Fanart.Dtos;
|
||||
using MediaBrowser.Common.Net;
|
||||
using MediaBrowser.Controller.Entities;
|
||||
using MediaBrowser.Controller.Entities.TV;
|
||||
@ -56,11 +57,10 @@ namespace Jellyfin.Plugin.Fanart.Providers
|
||||
var list = new List<RemoteImageInfo>();
|
||||
|
||||
var season = (Season)item;
|
||||
var series = season.Series;
|
||||
|
||||
if (series != null)
|
||||
if (season != null)
|
||||
{
|
||||
var id = series.GetProviderId(MetadataProvider.Tvdb);
|
||||
var id = season.GetProviderId(MetadataProvider.Tmdb) ?? season.GetProviderId(MetadataProvider.Tvdb);
|
||||
|
||||
if (!string.IsNullOrEmpty(id) && season.IndexNumber.HasValue)
|
||||
{
|
||||
@ -129,22 +129,22 @@ namespace Jellyfin.Plugin.Fanart.Providers
|
||||
private async Task AddImages(List<RemoteImageInfo> list, int seasonNumber, string path, CancellationToken cancellationToken)
|
||||
{
|
||||
Stream fileStream = File.OpenRead(path);
|
||||
var root = await JsonSerializer.DeserializeAsync<SeriesProvider.RootObject>(fileStream, JsonDefaults.Options).ConfigureAwait(false);
|
||||
var root = await JsonSerializer.DeserializeAsync<SeriesRootObject>(fileStream, JsonDefaults.Options).ConfigureAwait(false);
|
||||
|
||||
AddImages(list, root, seasonNumber, cancellationToken);
|
||||
}
|
||||
|
||||
private void AddImages(List<RemoteImageInfo> list, SeriesProvider.RootObject obj, int seasonNumber, CancellationToken cancellationToken)
|
||||
private void AddImages(List<RemoteImageInfo> list, SeriesRootObject obj, int seasonNumber, CancellationToken cancellationToken)
|
||||
{
|
||||
PopulateImages(list, obj.seasonposter, ImageType.Primary, 1000, 1426, seasonNumber);
|
||||
PopulateImages(list, obj.seasonbanner, ImageType.Banner, 1000, 185, seasonNumber);
|
||||
PopulateImages(list, obj.seasonthumb, ImageType.Thumb, 500, 281, seasonNumber);
|
||||
PopulateImages(list, obj.showbackground, ImageType.Backdrop, 1920, 1080, seasonNumber);
|
||||
PopulateImages(list, obj.SeasonPosters, ImageType.Primary, 1000, 1426, seasonNumber);
|
||||
PopulateImages(list, obj.SeasonBanners, ImageType.Banner, 1000, 185, seasonNumber);
|
||||
PopulateImages(list, obj.SeasonThumbs, ImageType.Thumb, 500, 281, seasonNumber);
|
||||
PopulateImages(list, obj.Showbackgrounds, ImageType.Backdrop, 1920, 1080, seasonNumber);
|
||||
}
|
||||
|
||||
private void PopulateImages(
|
||||
List<RemoteImageInfo> list,
|
||||
List<SeriesProvider.Image> images,
|
||||
List<SeriesImage> images,
|
||||
ImageType type,
|
||||
int width,
|
||||
int height,
|
||||
@ -157,15 +157,15 @@ namespace Jellyfin.Plugin.Fanart.Providers
|
||||
|
||||
list.AddRange(images.Select(i =>
|
||||
{
|
||||
var url = i.url;
|
||||
var season = i.season;
|
||||
var url = i.Url;
|
||||
var season = i.Season;
|
||||
|
||||
if (!string.IsNullOrEmpty(url)
|
||||
&& !string.IsNullOrEmpty(season)
|
||||
&& int.TryParse(season, NumberStyles.Integer, CultureInfo.InvariantCulture, out var imageSeasonNumber)
|
||||
&& seasonNumber == imageSeasonNumber)
|
||||
{
|
||||
var likesString = i.likes;
|
||||
var likesString = i.Likes;
|
||||
|
||||
var info = new RemoteImageInfo
|
||||
{
|
||||
@ -175,7 +175,7 @@ namespace Jellyfin.Plugin.Fanart.Providers
|
||||
Height = height,
|
||||
ProviderName = Name,
|
||||
Url = url.Replace("http://", "https://", StringComparison.OrdinalIgnoreCase),
|
||||
Language = i.lang
|
||||
Language = i.Language
|
||||
};
|
||||
|
||||
if (!string.IsNullOrEmpty(likesString)
|
||||
|
@ -9,6 +9,7 @@ using System.Text.Json;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Jellyfin.Extensions.Json;
|
||||
using Jellyfin.Plugin.Fanart.Dtos;
|
||||
using MediaBrowser.Common.Configuration;
|
||||
using MediaBrowser.Common.Net;
|
||||
using MediaBrowser.Controller.Configuration;
|
||||
@ -72,7 +73,7 @@ namespace Jellyfin.Plugin.Fanart.Providers
|
||||
|
||||
var series = (Series)item;
|
||||
|
||||
var id = series.GetProviderId(MetadataProvider.Tvdb);
|
||||
var id = series.GetProviderId(MetadataProvider.Tmdb) ?? series.GetProviderId(MetadataProvider.Tvdb);
|
||||
|
||||
if (!string.IsNullOrEmpty(id))
|
||||
{
|
||||
@ -140,27 +141,27 @@ namespace Jellyfin.Plugin.Fanart.Providers
|
||||
private async Task AddImages(List<RemoteImageInfo> list, string path)
|
||||
{
|
||||
Stream fileStream = File.OpenRead(path);
|
||||
var root = await JsonSerializer.DeserializeAsync<RootObject>(fileStream, JsonDefaults.Options).ConfigureAwait(false);
|
||||
var root = await JsonSerializer.DeserializeAsync<SeriesRootObject>(fileStream, JsonDefaults.Options).ConfigureAwait(false);
|
||||
|
||||
AddImages(list, root);
|
||||
}
|
||||
|
||||
private void AddImages(List<RemoteImageInfo> list, RootObject obj)
|
||||
private void AddImages(List<RemoteImageInfo> list, SeriesRootObject obj)
|
||||
{
|
||||
PopulateImages(list, obj.hdtvlogo, ImageType.Logo, 800, 310);
|
||||
PopulateImages(list, obj.hdclearart, ImageType.Art, 1000, 562);
|
||||
PopulateImages(list, obj.clearlogo, ImageType.Logo, 400, 155);
|
||||
PopulateImages(list, obj.clearart, ImageType.Art, 500, 281);
|
||||
PopulateImages(list, obj.showbackground, ImageType.Backdrop, 1920, 1080, true);
|
||||
PopulateImages(list, obj.seasonthumb, ImageType.Thumb, 500, 281);
|
||||
PopulateImages(list, obj.tvthumb, ImageType.Thumb, 500, 281);
|
||||
PopulateImages(list, obj.tvbanner, ImageType.Banner, 1000, 185);
|
||||
PopulateImages(list, obj.tvposter, ImageType.Primary, 1000, 1426);
|
||||
PopulateImages(list, obj.HdTvLogos, ImageType.Logo, 800, 310);
|
||||
PopulateImages(list, obj.HdClearArts, ImageType.Art, 1000, 562);
|
||||
PopulateImages(list, obj.ClearLogos, ImageType.Logo, 400, 155);
|
||||
PopulateImages(list, obj.ClearArts, ImageType.Art, 500, 281);
|
||||
PopulateImages(list, obj.Showbackgrounds, ImageType.Backdrop, 1920, 1080, true);
|
||||
PopulateImages(list, obj.SeasonThumbs, ImageType.Thumb, 500, 281);
|
||||
PopulateImages(list, obj.TvThumbs, ImageType.Thumb, 500, 281);
|
||||
PopulateImages(list, obj.TvBanners, ImageType.Banner, 1000, 185);
|
||||
PopulateImages(list, obj.TvPosters, ImageType.Primary, 1000, 1426);
|
||||
}
|
||||
|
||||
private void PopulateImages(
|
||||
List<RemoteImageInfo> list,
|
||||
List<Image> images,
|
||||
List<SeriesImage> images,
|
||||
ImageType type,
|
||||
int width,
|
||||
int height,
|
||||
@ -173,15 +174,15 @@ namespace Jellyfin.Plugin.Fanart.Providers
|
||||
|
||||
list.AddRange(images.Select(i =>
|
||||
{
|
||||
var url = i.url;
|
||||
var season = i.season;
|
||||
var url = i.Url;
|
||||
var season = i.Season;
|
||||
|
||||
var isSeasonValid = string.IsNullOrEmpty(season) ||
|
||||
(allowSeasonAll && string.Equals(season, "all", StringComparison.OrdinalIgnoreCase));
|
||||
|
||||
if (!string.IsNullOrEmpty(url) && isSeasonValid)
|
||||
{
|
||||
var likesString = i.likes;
|
||||
var likesString = i.Likes;
|
||||
|
||||
var info = new RemoteImageInfo
|
||||
{
|
||||
@ -191,7 +192,7 @@ namespace Jellyfin.Plugin.Fanart.Providers
|
||||
Height = height,
|
||||
ProviderName = Name,
|
||||
Url = url.Replace("http://", "https://", StringComparison.OrdinalIgnoreCase),
|
||||
Language = i.lang
|
||||
Language = i.Language
|
||||
};
|
||||
|
||||
if (!string.IsNullOrEmpty(likesString)
|
||||
@ -314,7 +315,7 @@ namespace Jellyfin.Plugin.Fanart.Providers
|
||||
{
|
||||
// If the user has automatic updates enabled, save a dummy object to prevent repeated download attempts
|
||||
Stream fileStream = File.OpenWrite(path);
|
||||
await JsonSerializer.SerializeAsync(fileStream, new RootObject(), JsonDefaults.Options).ConfigureAwait(false);
|
||||
await JsonSerializer.SerializeAsync(fileStream, new SeriesRootObject(), JsonDefaults.Options).ConfigureAwait(false);
|
||||
|
||||
return;
|
||||
}
|
||||
@ -322,49 +323,5 @@ namespace Jellyfin.Plugin.Fanart.Providers
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
public class Image
|
||||
{
|
||||
public string id { get; set; }
|
||||
|
||||
public string url { get; set; }
|
||||
|
||||
public string lang { get; set; }
|
||||
|
||||
public string likes { get; set; }
|
||||
|
||||
public string season { get; set; }
|
||||
}
|
||||
|
||||
public class RootObject
|
||||
{
|
||||
public string name { get; set; }
|
||||
|
||||
public string thetvdb_id { get; set; }
|
||||
|
||||
public List<Image> clearlogo { get; set; }
|
||||
|
||||
public List<Image> hdtvlogo { get; set; }
|
||||
|
||||
public List<Image> clearart { get; set; }
|
||||
|
||||
public List<Image> showbackground { get; set; }
|
||||
|
||||
public List<Image> tvthumb { get; set; }
|
||||
|
||||
public List<Image> seasonposter { get; set; }
|
||||
|
||||
public List<Image> seasonthumb { get; set; }
|
||||
|
||||
public List<Image> hdclearart { get; set; }
|
||||
|
||||
public List<Image> tvbanner { get; set; }
|
||||
|
||||
public List<Image> characterart { get; set; }
|
||||
|
||||
public List<Image> tvposter { get; set; }
|
||||
|
||||
public List<Image> seasonbanner { get; set; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user