Migrate DTOs to JsonPropertyName and PascalCase

This commit is contained in:
Shadowghost 2022-03-29 20:28:23 +02:00
parent 1889257beb
commit 39f0d2b6a8
12 changed files with 169 additions and 107 deletions

View File

@ -1,11 +1,14 @@
using System.Collections.Generic;
using System.Text.Json.Serialization;
namespace Jellyfin.Plugin.Fanart.Dtos
{
public class Album
{
public List<ArtistImage> cdart { get; set; }
[JsonPropertyName("cdart")]
public List<ArtistImage> CdArts { get; set; }
public List<ArtistImage> albumcover { get; set; }
[JsonPropertyName("albumcover")]
public List<ArtistImage> AlbumCovers { get; set; }
}
}

View File

@ -1,17 +1,25 @@
using System.Text.Json.Serialization;
namespace Jellyfin.Plugin.Fanart.Dtos
{
public class ArtistImage
{
public string id { get; set; }
[JsonPropertyName("id")]
public string Id { get; set; }
public string url { get; set; }
[JsonPropertyName("url")]
public string Url { get; set; }
public string likes { get; set; }
[JsonPropertyName("likes")]
public string Likes { get; set; }
public string disc { get; set; }
[JsonPropertyName("disc")]
public string Disc { get; set; }
public string size { get; set; }
[JsonPropertyName("size")]
public string Size { get; set; }
public string lang { get; set; }
[JsonPropertyName("lang")]
public string Language { get; set; }
}
}

View File

@ -1,27 +1,38 @@
using System.Collections.Generic;
using System.Text.Json.Serialization;
namespace Jellyfin.Plugin.Fanart.Dtos
{
public class ArtistResponse
{
public string name { get; set; }
[JsonPropertyName("name")]
public string Name { get; set; }
public string mbid_id { get; set; }
[JsonPropertyName("mbid_id")]
public string MusicBrainzId { get; set; }
public List<ArtistImage> artistthumb { get; set; }
[JsonPropertyName("artistthumb")]
public List<ArtistImage> ArtistThumbs { get; set; }
public List<ArtistImage> artistbackground { get; set; }
[JsonPropertyName("artistbackground")]
public List<ArtistImage> ArtistBackgrounds { get; set; }
public List<ArtistImage> hdmusiclogo { get; set; }
[JsonPropertyName("hdmusiclogo")]
public List<ArtistImage> HdMusicLogos { get; set; }
public List<ArtistImage> musicbanner { get; set; }
[JsonPropertyName("musicbanner")]
public List<ArtistImage> MusicBanners { get; set; }
public List<ArtistImage> musiclogo { get; set; }
[JsonPropertyName("musiclogo")]
public List<ArtistImage> MusicLogos { get; set; }
public List<ArtistImage> musicarts { get; set; }
[JsonPropertyName("musicarts")]
public List<ArtistImage> MusicArts { get; set; }
public List<ArtistImage> hdmusicarts { get; set; }
[JsonPropertyName("hdmusicarts")]
public List<ArtistImage> HdmusicArts { get; set; }
public Dictionary<string, Album> albums { get; set; }
[JsonPropertyName("albums")]
public Dictionary<string, Album> Albums { get; set; }
}
}

View File

@ -1,13 +1,19 @@
using System.Text.Json.Serialization;
namespace Jellyfin.Plugin.Fanart.Dtos
{
public class MovieImage
{
public string id { get; set; }
[JsonPropertyName("id")]
public string Id { get; set; }
public string url { get; set; }
[JsonPropertyName("url")]
public string Url { get; set; }
public string lang { get; set; }
[JsonPropertyName("lang")]
public string Language { get; set; }
public string likes { get; set; }
[JsonPropertyName("likes")]
public string Likes { get; set; }
}
}

View File

@ -1,31 +1,44 @@
using System.Collections.Generic;
using System.Text.Json.Serialization;
namespace Jellyfin.Plugin.Fanart.Dtos
{
public class MovieRootObject
{
public string name { get; set; }
[JsonPropertyName("name")]
public string Name { get; set; }
public string tmdb_id { get; set; }
[JsonPropertyName("tmdb_id")]
public string TmbdId { get; set; }
public string imdb_id { get; set; }
[JsonPropertyName("imdb_id")]
public string ImdbId { get; set; }
public List<MovieImage> hdmovielogo { get; set; }
[JsonPropertyName("hdmovielogo")]
public List<MovieImage> HdMovieLogos { get; set; }
public List<MovieImage> moviedisc { get; set; }
[JsonPropertyName("moviedisc")]
public List<MovieImage> MovieDiscImages { get; set; }
public List<MovieImage> movielogo { get; set; }
[JsonPropertyName("movielogo")]
public List<MovieImage> MovieLogos { get; set; }
public List<MovieImage> movieposter { get; set; }
[JsonPropertyName("movieposter")]
public List<MovieImage> MoviePosters { get; set; }
public List<MovieImage> hdmovieclearart { get; set; }
[JsonPropertyName("hdmovieclearart")]
public List<MovieImage> HdMovieClearArts { get; set; }
public List<MovieImage> movieart { get; set; }
[JsonPropertyName("movieart")]
public List<MovieImage> MovieArts { get; set; }
public List<MovieImage> moviebackground { get; set; }
[JsonPropertyName("moviebackground")]
public List<MovieImage> MovieBackgrounds { get; set; }
public List<MovieImage> moviebanner { get; set; }
[JsonPropertyName("moviebanner")]
public List<MovieImage> MovieBanners { get; set; }
public List<MovieImage> moviethumb { get; set; }
[JsonPropertyName("moviethumb")]
public List<MovieImage> MovieThumbs { get; set; }
}
}

View File

@ -1,17 +1,23 @@
using System.Collections.Generic;
using System.Text.Json.Serialization;
namespace Jellyfin.Plugin.Fanart.Dtos
{
public class SeriesImage
{
public string id { get; set; }
[JsonPropertyName("id")]
public string Id { get; set; }
public string url { get; set; }
[JsonPropertyName("url")]
public string Url { get; set; }
public string lang { get; set; }
[JsonPropertyName("lang")]
public string Language { get; set; }
public string likes { get; set; }
[JsonPropertyName("likes")]
public string Likes { get; set; }
public string season { get; set; }
[JsonPropertyName("season")]
public string Season { get; set; }
}
}

View File

@ -1,35 +1,50 @@
using System.Collections.Generic;
using System.Text.Json.Serialization;
namespace Jellyfin.Plugin.Fanart.Dtos
{
public class SeriesRootObject
{
public string name { get; set; }
[JsonPropertyName("name")]
public string Name { get; set; }
public string thetvdb_id { get; set; }
[JsonPropertyName("thetvdb_id")]
public string TheTvDbId { get; set; }
public List<SeriesImage> clearlogo { get; set; }
[JsonPropertyName("clearlogo")]
public List<SeriesImage> ClearLogos { get; set; }
public List<SeriesImage> hdtvlogo { get; set; }
[JsonPropertyName("hdtvlogo")]
public List<SeriesImage> HdTvLogos { get; set; }
public List<SeriesImage> clearart { get; set; }
[JsonPropertyName("clearart")]
public List<SeriesImage> ClearArts { get; set; }
public List<SeriesImage> showbackground { get; set; }
[JsonPropertyName("showbackground")]
public List<SeriesImage> Showbackgrounds { get; set; }
public List<SeriesImage> tvthumb { get; set; }
[JsonPropertyName("tvthumb")]
public List<SeriesImage> TvThumbs { get; set; }
public List<SeriesImage> seasonposter { get; set; }
[JsonPropertyName("seasonposter")]
public List<SeriesImage> SeasonPosters { get; set; }
public List<SeriesImage> seasonthumb { get; set; }
[JsonPropertyName("seasonthumb")]
public List<SeriesImage> SeasonThumbs { get; set; }
public List<SeriesImage> hdclearart { get; set; }
[JsonPropertyName("hdclearart")]
public List<SeriesImage> HdClearArts { get; set; }
public List<SeriesImage> tvbanner { get; set; }
[JsonPropertyName("tvbanner")]
public List<SeriesImage> TvBanners { get; set; }
public List<SeriesImage> characterart { get; set; }
[JsonPropertyName("characterart")]
public List<SeriesImage> CharacterArts { get; set; }
public List<SeriesImage> tvposter { get; set; }
[JsonPropertyName("tvposter")]
public List<SeriesImage> TvPosters { get; set; }
public List<SeriesImage> seasonbanner { get; set; }
[JsonPropertyName("seasonbanner")]
public List<SeriesImage> SeasonBanners { get; set; }
}
}

View File

@ -134,20 +134,20 @@ namespace Jellyfin.Plugin.Fanart.Providers
Stream fileStream = File.OpenRead(path);
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.Key, releaseId, StringComparison.OrdinalIgnoreCase) || string.Equals(i.Key, releaseGroupId, StringComparison.OrdinalIgnoreCase)));
var albumcover = album.Value.albumcover;
var cdart = album.Value.cdart;
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 ( albumcover != null)
if ( albumcovers != null)
{
PopulateImages(list, albumcover, ImageType.Primary, 1000, 1000);
PopulateImages(list, albumcovers, ImageType.Primary, 1000, 1000);
}
if (cdart != null)
if (cdarts != null)
{
PopulateImages(list, cdart, ImageType.Disc, 1000, 1000);
PopulateImages(list, cdarts, ImageType.Disc, 1000, 1000);
}
}
}
@ -166,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
{
@ -180,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)

View File

@ -135,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(
@ -158,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
{
@ -172,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)

View File

@ -141,15 +141,15 @@ namespace Jellyfin.Plugin.Fanart.Providers
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<MovieImage> images, ImageType type, int width, int height)
@ -161,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
{
@ -175,7 +175,7 @@ namespace Jellyfin.Plugin.Fanart.Providers
Height = height,
ProviderName = Name,
Url = url,
Language = i.lang
Language = i.Language
};
if (!string.IsNullOrEmpty(likesString)

View File

@ -137,10 +137,10 @@ namespace Jellyfin.Plugin.Fanart.Providers
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(
@ -158,15 +158,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
{
@ -176,7 +176,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)

View File

@ -148,15 +148,15 @@ namespace Jellyfin.Plugin.Fanart.Providers
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(
@ -174,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
{
@ -192,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)