Skip to content
This repository was archived by the owner on Mar 16, 2025. It is now read-only.

Commit eb62bd0

Browse files
[v2] Add show images (#674)
1 parent d44eabd commit eb62bd0

File tree

10 files changed

+396
-2
lines changed

10 files changed

+396
-2
lines changed

src/libs/Trakt.NET/Internal/Json/SerializerContexts/JsonSerializerContextFactory.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,7 @@ internal static JsonSerializerContext GetContext<TJsonObjectType>()
215215
typeof(TraktShow),
216216
typeof(TraktShowAirs),
217217
typeof(TraktShowIDs),
218+
typeof(TraktShowImages),
218219
typeof(TraktShowMinimal)
219220
});
220221

@@ -324,6 +325,7 @@ internal static JsonSerializerContext GetContext<TJsonObjectType>()
324325
typeof(TraktShow),
325326
typeof(TraktShowAirs),
326327
typeof(TraktShowIDs),
328+
typeof(TraktShowImages),
327329
typeof(TraktShowMinimal)
328330
];
329331

src/libs/Trakt.NET/Internal/Json/SerializerContexts/ShowsJsonSerializerContext.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,15 @@ namespace TraktNET
66
{
77
[ExcludeFromCodeCoverage]
88
[JsonSerializable(typeof(TraktShow))]
9+
[JsonSerializable(typeof(IReadOnlyList<TraktShow>))]
910
[JsonSerializable(typeof(TraktShowAirs))]
11+
[JsonSerializable(typeof(IReadOnlyList<TraktShowAirs>))]
1012
[JsonSerializable(typeof(TraktShowIDs))]
13+
[JsonSerializable(typeof(IReadOnlyList<TraktShowIDs>))]
14+
[JsonSerializable(typeof(TraktShowImages))]
15+
[JsonSerializable(typeof(IReadOnlyList<TraktShowImages>))]
1116
[JsonSerializable(typeof(TraktShowMinimal))]
17+
[JsonSerializable(typeof(IReadOnlyList<TraktShowMinimal>))]
1218
public sealed partial class ShowsJsonSerializerContext : JsonSerializerContext
1319
{
1420
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
namespace TraktNET
2+
{
3+
/// <summary>A collection of Trakt show image URLs.</summary>
4+
public record class TraktShowImages
5+
{
6+
/// <summary>A List of Fanart image URLs.</summary>
7+
public List<string>? Fanart { get; set; }
8+
9+
/// <summary>A List of Poster image URLs.</summary>
10+
public List<string>? Poster { get; set; }
11+
12+
/// <summary>A List of Logo image URLs.</summary>
13+
public List<string>? Logo { get; set; }
14+
15+
/// <summary>A List of Clearart image URLs.</summary>
16+
public List<string>? Clearart { get; set; }
17+
18+
/// <summary>A List of Banner image URLs.</summary>
19+
public List<string>? Banner { get; set; }
20+
21+
/// <summary>A List of Thumbnail image URLs.</summary>
22+
public List<string>? Thumb { get; set; }
23+
}
24+
}

src/libs/Trakt.NET/Json/Shows/TraktShowMinimal.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,12 @@ public record class TraktShowMinimal
1818
[JsonPropertyName("ids")]
1919
public TraktShowIDs? IDs { get; set; }
2020

21+
/// <summary>
22+
/// The collection of image URLs for the show.
23+
/// See also <seealso cref="TraktShowImages" />.
24+
/// </summary>
25+
public TraktShowImages? Images { get; set; }
26+
2127
/// <summary>Gets a string representation of the show.</summary>
2228
/// <returns>A string representation of the show.</returns>
2329
public override string ToString()
File renamed without changes.
Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
{
2+
"title": "Game of Thrones",
3+
"year": 2011,
4+
"ids": {
5+
"trakt": 1390,
6+
"slug": "game-of-thrones",
7+
"tvdb": 121361,
8+
"imdb": "tt0944947",
9+
"tmdb": 1399,
10+
"tvrage": null
11+
},
12+
"tagline": "Winter is coming.",
13+
"overview": "Seven noble families fight for control of the mythical land of Westeros.",
14+
"first_aired": "2011-04-18T01:00:00.000Z",
15+
"airs": {
16+
"day": "Sunday",
17+
"time": "21:00",
18+
"timezone": "America/New_York"
19+
},
20+
"runtime": 57,
21+
"certification": "TV-MA",
22+
"network": "HBO",
23+
"country": "us",
24+
"trailer": "https://youtube.com/watch?v=KPLWWIOCOOQ",
25+
"homepage": "http://www.hbo.com/game-of-thrones",
26+
"status": "ended",
27+
"rating": 8.933884809616755,
28+
"votes": 129108,
29+
"comment_count": 414,
30+
"updated_at": "2024-03-23T06:26:48.000Z",
31+
"language": "en",
32+
"languages": [
33+
"en"
34+
],
35+
"available_translations": [
36+
"ar",
37+
"be",
38+
"bg",
39+
"bs",
40+
"ca",
41+
"cs",
42+
"da",
43+
"de",
44+
"el",
45+
"en",
46+
"eo",
47+
"es",
48+
"et",
49+
"fa",
50+
"fi",
51+
"fr",
52+
"he",
53+
"hr",
54+
"hu",
55+
"id",
56+
"is",
57+
"it",
58+
"ja",
59+
"ka",
60+
"ko",
61+
"lb",
62+
"lt",
63+
"lv",
64+
"ml",
65+
"nl",
66+
"no",
67+
"pl",
68+
"pt",
69+
"ro",
70+
"ru",
71+
"sk",
72+
"sl",
73+
"so",
74+
"sr",
75+
"sv",
76+
"ta",
77+
"th",
78+
"tr",
79+
"tw",
80+
"uk",
81+
"uz",
82+
"vi",
83+
"zh"
84+
],
85+
"genres": [
86+
"fantasy",
87+
"drama",
88+
"action",
89+
"adventure"
90+
],
91+
"aired_episodes": 73,
92+
"images": {
93+
"fanart": [
94+
"walter-r2.trakt.tv/images/shows/000/001/390/fanarts/medium/76d5df8aed.jpg.webp"
95+
],
96+
"poster": [
97+
"walter-r2.trakt.tv/images/shows/000/001/390/posters/thumb/93df9cd612.jpg.webp"
98+
],
99+
"logo": [
100+
"walter-r2.trakt.tv/images/shows/000/001/390/logos/medium/13b614ad43.png.webp"
101+
],
102+
"clearart": [
103+
"walter-r2.trakt.tv/images/shows/000/001/390/cleararts/medium/5cbde9e647.png.webp"
104+
],
105+
"banner": [
106+
"walter-r2.trakt.tv/images/shows/000/001/390/banners/medium/9fefff703d.jpg.webp"
107+
],
108+
"thumb": [
109+
"walter-r2.trakt.tv/images/shows/000/001/390/thumbs/medium/7beccbd5a1.jpg.webp"
110+
]
111+
}
112+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
{
2+
"title": "Game of Thrones",
3+
"year": 2011,
4+
"ids": {
5+
"trakt": 1390,
6+
"slug": "game-of-thrones",
7+
"tvdb": 121361,
8+
"imdb": "tt0944947",
9+
"tmdb": 1399,
10+
"tvrage": null
11+
},
12+
"images": {
13+
"fanart": [
14+
"walter-r2.trakt.tv/images/shows/000/001/390/fanarts/medium/76d5df8aed.jpg.webp"
15+
],
16+
"poster": [
17+
"walter-r2.trakt.tv/images/shows/000/001/390/posters/thumb/93df9cd612.jpg.webp"
18+
],
19+
"logo": [
20+
"walter-r2.trakt.tv/images/shows/000/001/390/logos/medium/13b614ad43.png.webp"
21+
],
22+
"clearart": [
23+
"walter-r2.trakt.tv/images/shows/000/001/390/cleararts/medium/5cbde9e647.png.webp"
24+
],
25+
"banner": [
26+
"walter-r2.trakt.tv/images/shows/000/001/390/banners/medium/9fefff703d.jpg.webp"
27+
],
28+
"thumb": [
29+
"walter-r2.trakt.tv/images/shows/000/001/390/thumbs/medium/7beccbd5a1.jpg.webp"
30+
]
31+
}
32+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"fanart": [
3+
"walter-r2.trakt.tv/images/shows/000/001/390/fanarts/medium/76d5df8aed.jpg.webp"
4+
],
5+
"poster": [
6+
"walter-r2.trakt.tv/images/shows/000/001/390/posters/thumb/93df9cd612.jpg.webp"
7+
],
8+
"logo": [
9+
"walter-r2.trakt.tv/images/shows/000/001/390/logos/medium/13b614ad43.png.webp"
10+
],
11+
"clearart": [
12+
"walter-r2.trakt.tv/images/shows/000/001/390/cleararts/medium/5cbde9e647.png.webp"
13+
],
14+
"banner": [
15+
"walter-r2.trakt.tv/images/shows/000/001/390/banners/medium/9fefff703d.jpg.webp"
16+
],
17+
"thumb": [
18+
"walter-r2.trakt.tv/images/shows/000/001/390/thumbs/medium/7beccbd5a1.jpg.webp"
19+
]
20+
}
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
namespace TraktNET.Json.Shows
2+
{
3+
public sealed class TraktShowImagesTests
4+
{
5+
[Fact]
6+
public void TestTraktShowImagesConstructor()
7+
{
8+
var showImages = new TraktShowImages();
9+
10+
showImages.Fanart.ShouldBeNull();
11+
showImages.Poster.ShouldBeNull();
12+
showImages.Logo.ShouldBeNull();
13+
showImages.Clearart.ShouldBeNull();
14+
showImages.Banner.ShouldBeNull();
15+
showImages.Thumb.ShouldBeNull();
16+
}
17+
18+
[Fact]
19+
public async Task TestTraktShowImagesFromJson()
20+
{
21+
TraktShowImages? showImages = await TestUtility.DeserializeJsonAsync<TraktShowImages>("Shows\\showimages.json");
22+
23+
showImages.ShouldNotBeNull();
24+
25+
showImages!.Fanart.ShouldNotBeNull();
26+
showImages!.Fanart!.Count.ShouldBe(1);
27+
showImages!.Fanart!.ShouldBe([ "walter-r2.trakt.tv/images/shows/000/001/390/fanarts/medium/76d5df8aed.jpg.webp" ]);
28+
29+
showImages!.Poster.ShouldNotBeNull();
30+
showImages!.Poster!.Count.ShouldBe(1);
31+
showImages!.Poster!.ShouldBe([ "walter-r2.trakt.tv/images/shows/000/001/390/posters/thumb/93df9cd612.jpg.webp" ]);
32+
33+
showImages!.Logo.ShouldNotBeNull();
34+
showImages!.Logo!.Count.ShouldBe(1);
35+
showImages!.Logo!.ShouldBe([ "walter-r2.trakt.tv/images/shows/000/001/390/logos/medium/13b614ad43.png.webp" ]);
36+
37+
showImages!.Clearart.ShouldNotBeNull();
38+
showImages!.Clearart!.Count.ShouldBe(1);
39+
showImages!.Clearart!.ShouldBe([ "walter-r2.trakt.tv/images/shows/000/001/390/cleararts/medium/5cbde9e647.png.webp" ]);
40+
41+
showImages!.Banner.ShouldNotBeNull();
42+
showImages!.Banner!.Count.ShouldBe(1);
43+
showImages!.Banner!.ShouldBe([ "walter-r2.trakt.tv/images/shows/000/001/390/banners/medium/9fefff703d.jpg.webp" ]);
44+
45+
showImages!.Thumb.ShouldNotBeNull();
46+
showImages!.Thumb!.Count.ShouldBe(1);
47+
showImages!.Thumb!.ShouldBe([ "walter-r2.trakt.tv/images/shows/000/001/390/thumbs/medium/7beccbd5a1.jpg.webp" ]);
48+
}
49+
}
50+
}

0 commit comments

Comments
 (0)