mirror of
https://github.com/4gray/iptvnator.git
synced 2026-10-12 20:16:15 -08:00
fix(downloads): distinguish missing Xtream seasons
This commit is contained in:
1 parent
f73ab6b496
commit
ccec830fb3
2 files changed
+28
-6
No files matched your search
+21
@@ -123,6 +123,10 @@ describe('createXtreamSeriesDownloadAdapter', () => {
|
||||
episode({ season: 0, episode_num: 0 }),
|
||||
'4'
|
||||
);
|
||||
const stringSpecials = adapter.createCandidate(
|
||||
episode({ season: '0' as unknown as number }),
|
||||
'4'
|
||||
);
|
||||
const fromSeasonKey = adapter.createCandidate(
|
||||
episode({ season: Number.NaN }),
|
||||
'0'
|
||||
@@ -135,6 +139,9 @@ describe('createXtreamSeriesDownloadAdapter', () => {
|
||||
expect(specials?.identity).toEqual(
|
||||
expect.objectContaining({ seasonNumber: 0, episodeNumber: 1 })
|
||||
);
|
||||
expect(stringSpecials?.identity).toEqual(
|
||||
expect.objectContaining({ seasonNumber: 0, episodeNumber: 3 })
|
||||
);
|
||||
expect(fromSeasonKey?.identity).toEqual(
|
||||
expect.objectContaining({ seasonNumber: 0, episodeNumber: 3 })
|
||||
);
|
||||
@@ -148,6 +155,20 @@ describe('createXtreamSeriesDownloadAdapter', () => {
|
||||
);
|
||||
});
|
||||
|
||||
it.each([null, '', ' '] as const)(
|
||||
'uses the season key for a missing runtime season value %p',
|
||||
(season) => {
|
||||
const adapter = createXtreamSeriesDownloadAdapter(OPTIONS);
|
||||
|
||||
expect(
|
||||
adapter.createCandidate(
|
||||
episode({ season: season as unknown as number }),
|
||||
'2'
|
||||
)?.identity
|
||||
).toEqual(expect.objectContaining({ seasonNumber: 2 }));
|
||||
}
|
||||
);
|
||||
|
||||
it('preserves raw Xtream path concatenation and the mp4 extension fallback', async () => {
|
||||
const adapter = createXtreamSeriesDownloadAdapter({
|
||||
...OPTIONS,
|
||||
|
||||
@@ -35,12 +35,13 @@ function downloadSeasonNumber(
|
||||
value: unknown,
|
||||
fallbackSeasonKey: string | undefined
|
||||
): number | null {
|
||||
const parsed = Number(value);
|
||||
if (Number.isSafeInteger(parsed)) {
|
||||
return parsed >= 0 ? parsed : null;
|
||||
}
|
||||
if (value != null && !(typeof value === 'number' && Number.isNaN(value))) {
|
||||
return null;
|
||||
const isMissing =
|
||||
value == null ||
|
||||
(typeof value === 'string' && value.trim() === '') ||
|
||||
(typeof value === 'number' && Number.isNaN(value));
|
||||
if (!isMissing) {
|
||||
const parsed = Number(value);
|
||||
return Number.isSafeInteger(parsed) && parsed >= 0 ? parsed : null;
|
||||
}
|
||||
|
||||
const normalizedFallback = fallbackSeasonKey?.trim();
|
||||
|
||||
Reference in new issue
Block a user