Compare commits
13
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
47228d99a6 | ||
|
|
976062e6ef | ||
|
|
91555d3872 | ||
|
|
6ab8025c05 | ||
|
|
78b0f03e94 | ||
|
|
aa0c6fea60 | ||
|
|
f1b342ab3f | ||
|
|
194b0315fe | ||
|
|
6461003435 | ||
|
|
ed1836703a | ||
|
|
0743f7d2e7 | ||
|
|
048adc1170 | ||
|
|
096e22156c |
No files matched your search
@@ -9,3 +9,11 @@ updates:
|
||||
directory: "/src" # Location of package manifests
|
||||
schedule:
|
||||
interval: "weekly"
|
||||
ignore:
|
||||
- dependency-name: "Jellyfin.*"
|
||||
update-types:
|
||||
- version-update:semver-major
|
||||
- version-update:semver-minor
|
||||
- dependency-name: "Microsoft.*"
|
||||
update-types:
|
||||
- version-update:semver-major
|
||||
@@ -19,7 +19,15 @@ jobs:
|
||||
dotnet-version: 9.0.x
|
||||
|
||||
- name: Build project
|
||||
run: dotnet build --configuration Release ./src
|
||||
run: dotnet build --configuration Release --property:Version=1.0.0.0 ./src
|
||||
|
||||
- name: Test project
|
||||
run: dotnet test --configuration Release ./src
|
||||
|
||||
- name: Publish artifacts
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: my-artifact
|
||||
path: |
|
||||
./src/Jellyfin.Plugin.Kinopoisk/bin/Release/net9.0/Jellyfin.Plugin.Kinopoisk.dll
|
||||
./src/KinopoiskUnofficialInfo.ApiClient/bin/Release/net9.0/KinopoiskUnofficialInfo.ApiClient.dll
|
||||
@@ -1,5 +1,13 @@
|
||||
# Changelog
|
||||
|
||||
## [10.10.3.0]
|
||||
|
||||
Исправлена совместимость с 10.10.*
|
||||
|
||||
## [10.10.2.0]
|
||||
|
||||
Исправлена совместимость с 10.11.(0-4)
|
||||
|
||||
## [10.10.1.0]
|
||||
|
||||
Реализован IExternalUrlProvider (ссылки на кинопоиск)
|
||||
|
||||
Vendored
+17
@@ -0,0 +1,17 @@
|
||||
# Форк плагина КиноПоиск: больше изображений
|
||||
|
||||
Оригинал: https://github.com/LinFor/jellyfin-plugin-kinopoisk
|
||||
|
||||
Что изменено:
|
||||
- `coverUrl` из карточки фильма отдаётся как `Backdrop` (широкая обложка);
|
||||
- `logoUrl` отдаётся как `Logo`;
|
||||
- кадры из `GET /api/v2.2/films/{id}/images` отдаются как `Thumb` и `Backdrop` (до 12 штук);
|
||||
- проверка доступности URL дедуплицируется, чтобы не дёргать один и тот же адрес дважды.
|
||||
|
||||
Сборка: `10.10.4.0` (net9.0, targetAbi 10.10.0), файл `jellyfin-plugin-kinopoisk_10.10.4.0.zip`.
|
||||
|
||||
Установка:
|
||||
1. Jellyfin → Dashboard → Plugins → Repositories → добавить
|
||||
`https://git.midns.ru/1xDed/jellyfin-plugin-kinopoisk/raw/branch/master/dist/custom/manifest.json`
|
||||
2. Обновить «КиноПоиск» до 10.10.4.0 и перезапустить Jellyfin.
|
||||
3. Для уже существующих фильмов: «Обновить метаданные» → заменить изображения (или дождаться планового обновления).
|
||||
Binary file not shown.
Vendored
+21
@@ -0,0 +1,21 @@
|
||||
[
|
||||
{
|
||||
"category": "Metadata",
|
||||
"guid": "33e6d249-648f-44cd-a9ce-497be06c08df",
|
||||
"name": "КиноПоиск",
|
||||
"overview": "Информация о фильмах и сериалах с КиноПоиска + больше изображений",
|
||||
"owner": "1xDed (fork of LinFor & skrashevich)",
|
||||
"description": "Форк плагина КиноПоиск. Дополнительно забирает из API coverUrl, logoUrl и кадры из /films/{id}/images: широкие обложки (Backdrop), landscape-кадры (Thumb) и логотипы (Logo), а не только один постер.",
|
||||
"imageUrl": "https://kinopoisk.userecho.com/s/attachments/28876/0/1/25f8c0315e6ccb2aa6c2642e48f2c9e9.png",
|
||||
"versions": [
|
||||
{
|
||||
"version": "10.10.4.0",
|
||||
"checksum": "e0c9398382c7220e144d842dd31713c5",
|
||||
"changelog": "Больше изображений: coverUrl как Backdrop, logoUrl как Logo, кадры из /films/{id}/images как Thumb и Backdrop (до 12 кадров). Дедупликация проверки URL.",
|
||||
"targetAbi": "10.10.0",
|
||||
"sourceUrl": "https://git.midns.ru/1xDed/jellyfin-plugin-kinopoisk/releases/download/v10.10.4.0/jellyfin-plugin-kinopoisk_10.10.4.0.zip",
|
||||
"timestamp": "2026-11-27T10:05:00Z"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
Vendored
+24
@@ -8,6 +8,30 @@
|
||||
"description": "Загружает рейтинг, описания, актёров, трейлеры и т.д. с сайта КиноПоиск. Может потребоваться зарегистрировать свой ApiToken, см. информацию в параметрах плагина. Для точного распознавания рекомендуется указывать id фильма с сайта КиноПоиск в имени файла в формате kp-12345 или kp12345. Подробнее см. https://github.com/LinFor/jellyfin-plugin-kinopoisk/blob/master/README.md\n",
|
||||
"imageUrl": "https://kinopoisk.userecho.com/s/attachments/28876/0/1/25f8c0315e6ccb2aa6c2642e48f2c9e9.png",
|
||||
"versions": [
|
||||
{
|
||||
"version": "10.10.3.0",
|
||||
"checksum": "de4cf02e03339d61933a6869bf6be6f4",
|
||||
"changelog": "Исправлена совместимость с 10.10.*",
|
||||
"targetAbi": "10.10.0",
|
||||
"sourceUrl": "https://github.com/LinFor/jellyfin-plugin-kinopoisk/releases/download/v10.10.3.0/jellyfin-plugin-kinopoisk_10.10.3.0.zip",
|
||||
"timestamp": "2026-02-18T07:38:15Z"
|
||||
},
|
||||
{
|
||||
"version": "10.10.2.0",
|
||||
"checksum": "4cd0b8b5fe5db078b74eb472146773ac",
|
||||
"changelog": "Исправлена совместимость с 10.11.(0-4)",
|
||||
"targetAbi": "10.10.0",
|
||||
"sourceUrl": "https://github.com/LinFor/jellyfin-plugin-kinopoisk/releases/download/v10.10.2.0/jellyfin-plugin-kinopoisk_10.10.2.0.zip",
|
||||
"timestamp": "2026-02-04T09:24:27Z"
|
||||
},
|
||||
{
|
||||
"version": "10.10.1.0",
|
||||
"checksum": "6607f466b207e2e980f142e317ffb989",
|
||||
"changelog": "Реализован IExternalUrlProvider (ссылки на кинопоиск)",
|
||||
"targetAbi": "10.10.0",
|
||||
"sourceUrl": "https://github.com/LinFor/jellyfin-plugin-kinopoisk/releases/download/v10.10.1.0/jellyfin-plugin-kinopoisk_10.10.1.0.zip",
|
||||
"timestamp": "2026-01-15T21:37:12Z"
|
||||
},
|
||||
{
|
||||
"version": "10.9.8.0",
|
||||
"checksum": "8ce2e57a7411c393a5ac23d31f50265a",
|
||||
|
||||
Whitespace-only changes.
@@ -0,0 +1,46 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using KinopoiskUnofficialInfo.ApiClient;
|
||||
using Xunit;
|
||||
|
||||
namespace Jellyfin.Plugin.Kinopoisk.Tests
|
||||
{
|
||||
public class ApiModelExtensionsTests
|
||||
{
|
||||
[Fact]
|
||||
public void ToPersonInfosShouldSkipPersonsWithoutNames()
|
||||
{
|
||||
var staff = new List<StaffResponse>
|
||||
{
|
||||
CreateStaff(1, "Иван Иванов", string.Empty),
|
||||
CreateStaff(2, string.Empty, string.Empty),
|
||||
CreateStaff(3, " ", " "),
|
||||
CreateStaff(4, string.Empty, "John Smith")
|
||||
};
|
||||
|
||||
var result = staff.ToPersonInfos().ToArray();
|
||||
|
||||
Assert.Equal(2, result.Length);
|
||||
Assert.Equal("Иван Иванов", result[0].Name);
|
||||
Assert.Equal(1, result[0].SortOrder);
|
||||
Assert.Equal("John Smith", result[1].Name);
|
||||
Assert.Equal(2, result[1].SortOrder);
|
||||
}
|
||||
|
||||
private static StaffResponse CreateStaff(
|
||||
int id,
|
||||
string nameRu,
|
||||
string nameEn)
|
||||
{
|
||||
return new StaffResponse
|
||||
{
|
||||
StaffId = id,
|
||||
NameRu = nameRu,
|
||||
NameEn = nameEn,
|
||||
PosterUrl = string.Empty,
|
||||
ProfessionText = "Актёр",
|
||||
ProfessionKey = StaffResponseProfessionKey.ACTOR
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -11,7 +11,6 @@
|
||||
<PackageReference Include="xunit" Version="2.4.2" />
|
||||
<DotNetCliToolReference Include="dotnet-xunit" Version="2.3.1" />
|
||||
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5" />
|
||||
<PackageReference Include="coverlet.collector" Version="3.2.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
@@ -0,0 +1,76 @@
|
||||
using System.IO;
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Xunit;
|
||||
|
||||
namespace Jellyfin.Plugin.Kinopoisk.Tests
|
||||
{
|
||||
public class RemoteImageUrlSanitizerTests
|
||||
{
|
||||
[Fact]
|
||||
public async Task SanitizeRemoteImageUrlDisposesRequestAndResponse()
|
||||
{
|
||||
using var handler = new TrackingHandler();
|
||||
using var httpClient = new HttpClient(handler);
|
||||
|
||||
var sanitizer = new RemoteImageUrlSanitizer(httpClient);
|
||||
|
||||
var result = await sanitizer.SanitizeRemoteImageUrl(
|
||||
"https://example.com/image.jpg");
|
||||
|
||||
Assert.Equal("https://example.com/image.jpg", result);
|
||||
Assert.True(handler.RequestContent.IsDisposed);
|
||||
Assert.True(handler.ResponseContent.IsDisposed);
|
||||
}
|
||||
|
||||
private sealed class TrackingHandler : HttpMessageHandler
|
||||
{
|
||||
public TrackingContent RequestContent { get; } = new TrackingContent();
|
||||
|
||||
public TrackingContent ResponseContent { get; } = new TrackingContent();
|
||||
|
||||
protected override Task<HttpResponseMessage> SendAsync(
|
||||
HttpRequestMessage request,
|
||||
CancellationToken cancellationToken)
|
||||
{
|
||||
request.Content = RequestContent;
|
||||
|
||||
return Task.FromResult(
|
||||
new HttpResponseMessage(HttpStatusCode.OK)
|
||||
{
|
||||
Content = ResponseContent
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private sealed class TrackingContent : HttpContent
|
||||
{
|
||||
public bool IsDisposed { get; private set; }
|
||||
|
||||
protected override Task SerializeToStreamAsync(
|
||||
Stream stream,
|
||||
TransportContext context)
|
||||
{
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
protected override bool TryComputeLength(out long length)
|
||||
{
|
||||
length = 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing)
|
||||
{
|
||||
IsDisposed = true;
|
||||
}
|
||||
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large.
Load diff
@@ -142,29 +142,69 @@ namespace Jellyfin.Plugin.Kinopoisk
|
||||
}
|
||||
|
||||
public static IEnumerable<RemoteImageInfo> ToRemoteImageInfos(this Film src)
|
||||
=> src.ToRemoteImageInfos(null);
|
||||
|
||||
/// <summary>
|
||||
/// Poster + cover + logo + stills from /films/{id}/images.
|
||||
/// Jellyfin needs more than one Primary/Backdrop to fill the hero and the
|
||||
/// "choose image" dialog, so expose every artwork the API returns.
|
||||
/// </summary>
|
||||
public static IEnumerable<RemoteImageInfo> ToRemoteImageInfos(this Film src, FilmImagesResponse images)
|
||||
{
|
||||
var res = Enumerable.Empty<RemoteImageInfo>();
|
||||
var res = new List<RemoteImageInfo>();
|
||||
if (src is null)
|
||||
return res;
|
||||
|
||||
if (src?.PosterUrl != null)
|
||||
if (!string.IsNullOrEmpty(src.PosterUrl))
|
||||
{
|
||||
var mainPoster = new RemoteImageInfo(){
|
||||
res.Add(new RemoteImageInfo(){
|
||||
Type = ImageType.Primary,
|
||||
Url = src.PosterUrl,
|
||||
Language = Constants.ProviderMetadataLanguage,
|
||||
ProviderName = Constants.ProviderName
|
||||
};
|
||||
res = res.Concat(Enumerable.Repeat(mainPoster, 1));
|
||||
});
|
||||
}
|
||||
|
||||
// if (src.Images != null)
|
||||
// {
|
||||
// if (src.Images.Posters != null)
|
||||
// res = res.Concat(src.Images.Posters.ToRemoteImageInfos(ImageType.Primary));
|
||||
// if (src.Images.Backdrops != null)
|
||||
// res = res.Concat(src.Images.Backdrops.ToRemoteImageInfos(ImageType.Backdrop));
|
||||
// }
|
||||
if (!string.IsNullOrEmpty(src.CoverUrl))
|
||||
{
|
||||
res.Add(new RemoteImageInfo(){
|
||||
Type = ImageType.Backdrop,
|
||||
Url = src.CoverUrl,
|
||||
Language = Constants.ProviderMetadataLanguage,
|
||||
ProviderName = Constants.ProviderName
|
||||
});
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(src.LogoUrl))
|
||||
{
|
||||
res.Add(new RemoteImageInfo(){
|
||||
Type = ImageType.Logo,
|
||||
Url = src.LogoUrl,
|
||||
Language = Constants.ProviderMetadataLanguage,
|
||||
ProviderName = Constants.ProviderName
|
||||
});
|
||||
}
|
||||
|
||||
// Stills are 16:9 frames: useful both as backdrops and landscape thumbs.
|
||||
// Cap the amount to keep remote-image lookups reasonably fast.
|
||||
const int maxStills = 12;
|
||||
var stills = images?.Items?
|
||||
.Where(i => !string.IsNullOrEmpty(i.ImageUrl))
|
||||
.Take(maxStills)
|
||||
?? Enumerable.Empty<FilmImage>();
|
||||
foreach (var still in stills)
|
||||
{
|
||||
foreach (var type in new[] { ImageType.Thumb, ImageType.Backdrop })
|
||||
{
|
||||
res.Add(new RemoteImageInfo(){
|
||||
Type = type,
|
||||
Url = still.ImageUrl,
|
||||
ThumbnailUrl = still.PreviewUrl,
|
||||
Language = Constants.ProviderMetadataLanguage,
|
||||
ProviderName = Constants.ProviderName
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
@@ -257,7 +297,7 @@ namespace Jellyfin.Plugin.Kinopoisk
|
||||
public static IEnumerable<PersonInfo> ToPersonInfos(this ICollection<StaffResponse> src)
|
||||
{
|
||||
var res = src.Select(s => s.ToPersonInfo())
|
||||
.Where(s => s != null)
|
||||
.Where(s => s != null && !string.IsNullOrWhiteSpace(s.Name))
|
||||
.ToArray();
|
||||
|
||||
var i = 0;
|
||||
|
||||
@@ -11,10 +11,10 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Jellyfin.Data" Version="10.*-*" />
|
||||
<PackageReference Include="Jellyfin.Controller" Version="10.*-*" />
|
||||
<PackageReference Include="Jellyfin.Common" Version="10.*-*" />
|
||||
<PackageReference Include="Jellyfin.Model" Version="10.*-*" />
|
||||
<PackageReference Include="Jellyfin.Data" Version="10.10.0.*" />
|
||||
<PackageReference Include="Jellyfin.Controller" Version="10.10.0.*" />
|
||||
<PackageReference Include="Jellyfin.Common" Version="10.10.0.*" />
|
||||
<PackageReference Include="Jellyfin.Model" Version="10.10.0.*" />
|
||||
<PackageReference Include="Microsoft.Extensions.Http" Version="8.0.0" />
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
@@ -38,8 +38,13 @@ namespace Jellyfin.Plugin.Kinopoisk.MetadataProviders
|
||||
{
|
||||
using var httpClient = new HttpClient(new HttpClientHandler() { AllowAutoRedirect = false }, true);
|
||||
var sanitizer = new RemoteImageUrlSanitizer(httpClient);
|
||||
var sanitized = new Dictionary<string, string>(StringComparer.Ordinal);
|
||||
var res = await Task.WhenAll(images.Select(async i => {
|
||||
var sanitizedUrl = await sanitizer.SanitizeRemoteImageUrl(i.Url);
|
||||
if (!sanitized.TryGetValue(i.Url, out var sanitizedUrl))
|
||||
{
|
||||
sanitizedUrl = await sanitizer.SanitizeRemoteImageUrl(i.Url);
|
||||
sanitized[i.Url] = sanitizedUrl;
|
||||
}
|
||||
if (string.IsNullOrEmpty(sanitizedUrl))
|
||||
return null;
|
||||
|
||||
|
||||
@@ -38,7 +38,9 @@ namespace Jellyfin.Plugin.Kinopoisk.MetadataProviders
|
||||
=> new ImageType[]
|
||||
{
|
||||
ImageType.Primary,
|
||||
ImageType.Backdrop
|
||||
ImageType.Backdrop,
|
||||
ImageType.Thumb,
|
||||
ImageType.Logo
|
||||
};
|
||||
|
||||
public override async Task<IEnumerable<RemoteImageInfo>> GetImages(BaseItem item, CancellationToken cancellationToken)
|
||||
@@ -48,8 +50,15 @@ namespace Jellyfin.Plugin.Kinopoisk.MetadataProviders
|
||||
return Enumerable.Empty<RemoteImageInfo>();
|
||||
|
||||
var film = await _apiClient.GetSingleFilm(kinopoiskId, cancellationToken);
|
||||
var images = await _apiClient.GetFilmImages(kinopoiskId, cancellationToken);
|
||||
|
||||
return await FilterEmptyImages(film.ToRemoteImageInfos());
|
||||
var all = film.ToRemoteImageInfos(images).ToArray();
|
||||
var filtered = await FilterEmptyImages(all);
|
||||
_logger.LogInformation(
|
||||
"Kinopoisk returned {Count} images for {Name}",
|
||||
filtered.Count(),
|
||||
item.Name);
|
||||
return filtered;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -21,8 +21,10 @@ namespace Jellyfin.Plugin.Kinopoisk
|
||||
var currentUrl = url;
|
||||
while (!currentUrl.Contains("no-poster"))
|
||||
{
|
||||
var response = await _httpClient.SendAsync(
|
||||
new HttpRequestMessage(HttpMethod.Get, currentUrl), HttpCompletionOption.ResponseHeadersRead);
|
||||
using var request = new HttpRequestMessage(HttpMethod.Get, currentUrl);
|
||||
using var response = await _httpClient.SendAsync(
|
||||
request,
|
||||
HttpCompletionOption.ResponseHeadersRead);
|
||||
|
||||
if ((int)response.StatusCode <= 299)
|
||||
return currentUrl;
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
using Newtonsoft.Json;
|
||||
using Xunit;
|
||||
|
||||
namespace KinopoiskUnofficialInfo.ApiClient.Tests
|
||||
{
|
||||
public class BadSpouseSexConverterTests
|
||||
{
|
||||
[Fact]
|
||||
public void ShouldDeserializeUnknownSpouseSex()
|
||||
{
|
||||
const string json =
|
||||
"{\"personId\":1,\"name\":\"Test\",\"divorced\":false," +
|
||||
"\"divorcedReason\":\"\",\"sex\":\"UNKNOWN\",\"children\":0," +
|
||||
"\"webUrl\":\"\",\"relation\":\"\"}";
|
||||
|
||||
var settings = new JsonSerializerSettings
|
||||
{
|
||||
ContractResolver = new DeclarationPatcherContractResolver()
|
||||
};
|
||||
|
||||
var result = JsonConvert.DeserializeObject<PersonResponse_spouses>(
|
||||
json,
|
||||
settings);
|
||||
|
||||
Assert.NotNull(result);
|
||||
Assert.Equal(
|
||||
(PersonResponse_spousesSex)(-1),
|
||||
result.Sex);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -33,6 +33,9 @@ namespace KinopoiskUnofficialInfo.ApiClient
|
||||
public Task<Film> GetSingleFilm(int filmId, CancellationToken? cancellationToken = null)
|
||||
=> TryGetValue(GenerateKey(nameof(GetSingleFilm), filmId), c => c.GetSingleFilm(filmId, cancellationToken));
|
||||
|
||||
public Task<FilmImagesResponse> GetFilmImages(int filmId, CancellationToken? cancellationToken = null)
|
||||
=> TryGetValue(GenerateKey(nameof(GetFilmImages), filmId), c => c.GetFilmImages(filmId, cancellationToken));
|
||||
|
||||
public Task<ICollection<StaffResponse>> GetStaff(int filmId, CancellationToken? cancellationToken = null)
|
||||
=> TryGetValue(GenerateKey(nameof(GetStaff), filmId), c => c.GetStaff(filmId, cancellationToken));
|
||||
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace KinopoiskUnofficialInfo.ApiClient
|
||||
{
|
||||
/// <summary>
|
||||
/// Extra image fields returned by /api/v2.2/films/{id} which are not part of
|
||||
/// the generated (older) client model.
|
||||
/// </summary>
|
||||
public partial class Film
|
||||
{
|
||||
[JsonProperty("coverUrl")]
|
||||
public string CoverUrl { get; set; }
|
||||
|
||||
[JsonProperty("logoUrl")]
|
||||
public string LogoUrl { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
using System.Collections.Generic;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace KinopoiskUnofficialInfo.ApiClient
|
||||
{
|
||||
/// <summary>
|
||||
/// Stills/backdrops returned by /api/v2.2/films/{id}/images.
|
||||
/// The endpoint does not report dimensions or the image kind, only URLs.
|
||||
/// </summary>
|
||||
public class FilmImagesResponse
|
||||
{
|
||||
[JsonProperty("total")]
|
||||
public int Total { get; set; }
|
||||
|
||||
[JsonProperty("totalPages")]
|
||||
public int TotalPages { get; set; }
|
||||
|
||||
[JsonProperty("items")]
|
||||
public List<FilmImage> Items { get; set; } = new List<FilmImage>();
|
||||
}
|
||||
|
||||
public class FilmImage
|
||||
{
|
||||
[JsonProperty("imageUrl")]
|
||||
public string ImageUrl { get; set; }
|
||||
|
||||
[JsonProperty("previewUrl")]
|
||||
public string PreviewUrl { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -8,6 +8,7 @@ namespace KinopoiskUnofficialInfo.ApiClient
|
||||
{
|
||||
Task<PersonResponse> GetPerson(int personId, CancellationToken? cancellationToken = null);
|
||||
Task<Film> GetSingleFilm(int filmId, CancellationToken? cancellationToken = null);
|
||||
Task<FilmImagesResponse> GetFilmImages(int filmId, CancellationToken? cancellationToken = null);
|
||||
Task<ICollection<StaffResponse>> GetStaff(int filmId, CancellationToken? cancellationToken = null);
|
||||
Task<VideoResponse> GetTrailers(int filmId, CancellationToken? cancellationToken = null);
|
||||
Task<FilmSearchResponse> SearchByKeyword(string keyword, int page = 1, CancellationToken? cancellationToken = null);
|
||||
|
||||
@@ -50,6 +50,40 @@ namespace KinopoiskUnofficialInfo.ApiClient
|
||||
public Task<Film> GetSingleFilm(int filmId, CancellationToken? cancellationToken = null)
|
||||
=> Invoke((ct) => _apiClient.FilmsAsync(filmId, ct), cancellationToken);
|
||||
|
||||
public async Task<FilmImagesResponse> GetFilmImages(int filmId, CancellationToken? cancellationToken = null)
|
||||
{
|
||||
try
|
||||
{
|
||||
using var httpClient = _httpClientFactory.CreateClient();
|
||||
using var request = new HttpRequestMessage(
|
||||
HttpMethod.Get,
|
||||
$"https://kinopoiskapiunofficial.tech/api/v2.2/films/{filmId}/images");
|
||||
request.Headers.Add("X-API-KEY", _apiToken);
|
||||
using var response = await httpClient.SendAsync(
|
||||
request,
|
||||
HttpCompletionOption.ResponseContentRead,
|
||||
cancellationToken ?? CancellationToken.None);
|
||||
if (!response.IsSuccessStatusCode)
|
||||
{
|
||||
_logger.LogWarning(
|
||||
"Kinopoisk images request for film {FilmId} returned {StatusCode}",
|
||||
filmId,
|
||||
(int)response.StatusCode);
|
||||
return new FilmImagesResponse();
|
||||
}
|
||||
|
||||
var json = await response.Content.ReadAsStringAsync();
|
||||
return Newtonsoft.Json.JsonConvert.DeserializeObject<FilmImagesResponse>(json)
|
||||
?? new FilmImagesResponse();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
// Extra artwork must never break metadata updates.
|
||||
_logger.LogWarning(ex, "Failed to load images for film {FilmId}", filmId);
|
||||
return new FilmImagesResponse();
|
||||
}
|
||||
}
|
||||
|
||||
public Task<ICollection<StaffResponse>> GetStaff(int filmId, CancellationToken? cancellationToken = null)
|
||||
=> Invoke((ct) => _apiClient.StaffAllAsync(filmId, ct), cancellationToken);
|
||||
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
using System;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Converters;
|
||||
|
||||
namespace KinopoiskUnofficialInfo.ApiClient
|
||||
{
|
||||
public class BadSpouseSexConverter : StringEnumConverter
|
||||
{
|
||||
public override bool CanConvert(System.Type objectType)
|
||||
=> objectType == typeof(PersonResponse_spousesSex);
|
||||
|
||||
public override object ReadJson(
|
||||
JsonReader reader,
|
||||
System.Type objectType,
|
||||
object existingValue,
|
||||
JsonSerializer serializer)
|
||||
{
|
||||
try
|
||||
{
|
||||
return base.ReadJson(reader, objectType, existingValue, serializer);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
return (PersonResponse_spousesSex)(-1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -12,6 +12,7 @@ namespace KinopoiskUnofficialInfo.ApiClient
|
||||
new BadIntegerConverter(),
|
||||
new BadDoubleConverter(),
|
||||
new BadProfessionKeyConverter(),
|
||||
new BadSpouseSexConverter(),
|
||||
new BadProductionStatusConverter(),
|
||||
new BadFilmSearchResponse_filmsTypeConverter(),
|
||||
};
|
||||
|
||||
Reference in new issue
Block a user