Skip to content

Commit

Permalink
fix(tmdb): Allow a broader range of totalSeasons values (#524)
Browse files Browse the repository at this point in the history
* fix(tmdb): issue #523 allows a broader range of totalSeasons values

* refactor(test): fix test file

* chore(package): remove unused test scripts
  • Loading branch information
ICEPrey authored May 20, 2024
1 parent 440cde1 commit 69dda77
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 13 deletions.
2 changes: 1 addition & 1 deletion dist/providers/anime/gogoanime.js.map

Large diffs are not rendered by default.

7 changes: 3 additions & 4 deletions dist/providers/meta/tmdb.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/providers/meta/tmdb.js.map

Large diffs are not rendered by default.

9 changes: 3 additions & 6 deletions src/providers/meta/tmdb.ts
Original file line number Diff line number Diff line change
Expand Up @@ -407,16 +407,13 @@ class TMDB extends MovieParser {

// console.log({ test1: findMedia.results });

// check if the result contains the total number of seasons and compare it to the extraData by 1 up or down and make sure that its a number
// Check if the result contains the total number of seasons and compare it to the extraData.
// Allow for a range of ±2 seasons and ensure that the seasons value is a number.
if (extraData && extraData.totalSeasons && extraData.type === TvType.TVSERIES) {
findMedia.results = findMedia.results.filter(result => {
const totalSeasons = (result.seasons as number) || 0;
const extraDataSeasons = (extraData.totalSeasons as number) || 0;
return (
totalSeasons === extraDataSeasons ||
totalSeasons === extraDataSeasons + 1 ||
totalSeasons === extraDataSeasons - 1
);
return totalSeasons >= extraDataSeasons - 2 && totalSeasons <= extraDataSeasons + 2;
});
}

Expand Down
2 changes: 1 addition & 1 deletion test/meta/tmdb.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ test('returns a filled array of all trending list', async () => {
});

test('returns a filled object of anime data', async () => {
const data = await tmdb.fetchMediaInfo('60735', 'tv');
const data = await tmdb.fetchMediaInfo('85937', 'tv');
expect(data).not.toBeNull();
expect(data.episodes).not.toEqual([]);
expect(data.description).not.toBeNull();
Expand Down

0 comments on commit 69dda77

Please sign in to comment.