mirror of
https://github.com/4gray/iptvnator.git
synced 2026-10-09 09:26:14 -08:00
fix(downloads): distinguish stalker metadata seeds
This commit is contained in:
1 parent
05a625e474
commit
00a12d8b2a
3 files changed
+58
-22
No files matched your search
+18
-15
@@ -62,21 +62,24 @@ export function seriesSeed(
|
||||
};
|
||||
}
|
||||
|
||||
export function stalkerSeed(
|
||||
snapshot: DownloadMetadataSnapshot
|
||||
): StalkerVodInfo {
|
||||
export function stalkerSeed(snapshot: DownloadMetadataSnapshot): {
|
||||
info: StalkerVodInfo;
|
||||
} {
|
||||
return {
|
||||
movie_image: snapshot.posterUrl ?? '',
|
||||
description: snapshot.plot ?? '',
|
||||
name: snapshot.title,
|
||||
o_name: snapshot.originalTitle,
|
||||
actors: snapshot.cast?.map(({ name }) => name).join(', ') ?? '',
|
||||
director: snapshot.creators?.map(({ name }) => name).join(', ') ?? '',
|
||||
releasedate: snapshot.releaseDate ?? '',
|
||||
genre: snapshot.genres?.join(', ') ?? '',
|
||||
rating_imdb:
|
||||
snapshot.rating === undefined ? '' : String(snapshot.rating),
|
||||
rating_kinopoisk: '',
|
||||
tmdb_id: snapshot.tmdbId,
|
||||
info: {
|
||||
movie_image: snapshot.posterUrl ?? '',
|
||||
description: snapshot.plot ?? '',
|
||||
name: snapshot.title,
|
||||
o_name: snapshot.originalTitle,
|
||||
actors: snapshot.cast?.map(({ name }) => name).join(', ') ?? '',
|
||||
director:
|
||||
snapshot.creators?.map(({ name }) => name).join(', ') ?? '',
|
||||
releasedate: snapshot.releaseDate ?? '',
|
||||
genre: snapshot.genres?.join(', ') ?? '',
|
||||
rating_imdb:
|
||||
snapshot.rating === undefined ? '' : String(snapshot.rating),
|
||||
rating_kinopoisk: '',
|
||||
tmdb_id: snapshot.tmdbId,
|
||||
},
|
||||
};
|
||||
}
|
||||
@@ -137,6 +137,37 @@ describe('download metadata mapper', () => {
|
||||
expect(mapped).not.toHaveProperty('cmd');
|
||||
});
|
||||
|
||||
it('prefers a flat Stalker recent title over its generic name', () => {
|
||||
const mapped = mapProviderToDownloadSnapshot({
|
||||
source: 'stalker',
|
||||
language: 'en',
|
||||
mediaKind: 'movie',
|
||||
fallback: providerSnapshot,
|
||||
provider: {
|
||||
title: 'Canonical recent title',
|
||||
name: 'video_name_format',
|
||||
},
|
||||
});
|
||||
|
||||
expect(mapped.title).toBe('Canonical recent title');
|
||||
});
|
||||
|
||||
it('prefers a flat Stalker recent original title over its generic name', () => {
|
||||
const mapped = mapProviderToDownloadSnapshot({
|
||||
source: 'stalker',
|
||||
language: 'en',
|
||||
mediaKind: 'movie',
|
||||
fallback: providerSnapshot,
|
||||
provider: {
|
||||
o_name: 'Canonical recent original title',
|
||||
name: 'video_name_format',
|
||||
},
|
||||
});
|
||||
|
||||
expect(mapped.title).toBe('Canonical recent original title');
|
||||
expect(mapped.originalTitle).toBe('Canonical recent original title');
|
||||
});
|
||||
|
||||
it('normalizes nested Stalker series identity and legacy editorial fallbacks', () => {
|
||||
const fallback: DownloadMetadataSnapshot = {
|
||||
version: 1,
|
||||
|
||||
@@ -148,9 +148,9 @@ export function mapProviderToDownloadSnapshot({
|
||||
string(root['o_name']) ??
|
||||
string(root['name']) ??
|
||||
string(root['title']))
|
||||
: (string(root['name']) ??
|
||||
: (string(root['title']) ??
|
||||
string(root['o_name']) ??
|
||||
string(root['title']))
|
||||
string(root['name']))
|
||||
: string(first(identity, ['title', 'name']))) ?? fallback.title;
|
||||
const originalTitle =
|
||||
string(first(editorial, ['o_name', 'originalTitle'])) ??
|
||||
@@ -252,11 +252,13 @@ export function mergeSnapshotWithTmdb(
|
||||
): DownloadMetadataSnapshot {
|
||||
const provider =
|
||||
source === 'stalker'
|
||||
? mergeStalkerInfoWithTmdb(
|
||||
stalkerSeed(snapshot),
|
||||
details,
|
||||
snapshot.mediaKind === 'movie' ? 'movie' : 'tv'
|
||||
)
|
||||
? {
|
||||
info: mergeStalkerInfoWithTmdb(
|
||||
stalkerSeed(snapshot).info,
|
||||
details,
|
||||
snapshot.mediaKind === 'movie' ? 'movie' : 'tv'
|
||||
),
|
||||
}
|
||||
: snapshot.mediaKind === 'movie'
|
||||
? mergeVodInfoWithTmdb(
|
||||
movieSeed(snapshot),
|
||||
|
||||
Reference in new issue
Block a user