-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(eztv-api): Added possibility for multiple shows to be in one id
This will add the second show and format the episodes correctly for that one. This is in case EZTV maps episode / shows incorrectly
- Loading branch information
Showing
5 changed files
with
207 additions
and
119 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import { ShowWithEpisodes, Torrent } from './interfaces' | ||
|
||
const addTorrentToShow = (show: ShowWithEpisodes, season: string, episode: string, torrent: Torrent) => { | ||
if (!show.torrents[season]) { | ||
show.torrents[season] = {} | ||
} | ||
|
||
if (!show.torrents[season][episode]) { | ||
show.torrents[season][episode] = [] | ||
} | ||
|
||
show.torrents[season][episode].push(torrent) | ||
|
||
return show | ||
} | ||
|
||
export default { | ||
'what-if-2021': { | ||
id: 6179, | ||
slug: 'what-if', | ||
formatShow: (show: ShowWithEpisodes): ShowWithEpisodes => { | ||
const marvelsWhatIfShow = { | ||
...show, | ||
id: 0, | ||
slug: 'what-if-2021', | ||
imdb: 'tt10168312', | ||
torrents: {} | ||
} | ||
|
||
Object.keys(show.torrents) | ||
.forEach((season) => { | ||
Object.keys(show.torrents[season]) | ||
.forEach((episode) => { | ||
show.torrents[season][episode].forEach((torrent: Torrent) => { | ||
if (torrent.title.includes('What If')) { | ||
addTorrentToShow(marvelsWhatIfShow, season, episode, torrent) | ||
} | ||
}) | ||
}) | ||
}) | ||
|
||
return marvelsWhatIfShow | ||
} | ||
}, | ||
|
||
'what-if': { | ||
additionalShow: { | ||
id: 0, | ||
slug: 'what-if-2021', | ||
title: 'What If...' | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.