fix: slightly less duplication
This commit is contained in:
parent
1a61089783
commit
014256f3fc
1 changed files with 7 additions and 4 deletions
|
@ -17,6 +17,9 @@ module.exports = async function () {
|
||||||
const data = await res
|
const data = await res
|
||||||
const episodes = []
|
const episodes = []
|
||||||
data.reverse().forEach((episode) => {
|
data.reverse().forEach((episode) => {
|
||||||
|
const episodeNumber = episode['episode']['number']
|
||||||
|
const seasonNumber = episode['episode']['season']
|
||||||
|
|
||||||
if (episodes.find((e) => e.name === episode?.['show']?.['title'])) {
|
if (episodes.find((e) => e.name === episode?.['show']?.['title'])) {
|
||||||
// cache the matched episode reference
|
// cache the matched episode reference
|
||||||
const matchedEpisode = episodes.find((e) => e.name === episode?.['show']?.['title'])
|
const matchedEpisode = episodes.find((e) => e.name === episode?.['show']?.['title'])
|
||||||
|
@ -51,8 +54,8 @@ module.exports = async function () {
|
||||||
.toLowerCase()}.jpg` || 'https://cdn.coryd.dev/tv/missing-tv.jpg',
|
.toLowerCase()}.jpg` || 'https://cdn.coryd.dev/tv/missing-tv.jpg',
|
||||||
startingEpisode: matchedEpisode['episode'],
|
startingEpisode: matchedEpisode['episode'],
|
||||||
startingSeason: matchedEpisode['season'],
|
startingSeason: matchedEpisode['season'],
|
||||||
episode: episode['episode']['number'],
|
episode: episodeNumber,
|
||||||
season: episode['episode']['season'],
|
season: seasonNumber,
|
||||||
type: 'tv-range',
|
type: 'tv-range',
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
|
@ -67,8 +70,8 @@ module.exports = async function () {
|
||||||
.replace(':', '')
|
.replace(':', '')
|
||||||
.replace(/\s+/g, '-')
|
.replace(/\s+/g, '-')
|
||||||
.toLowerCase()}.jpg` || 'https://cdn.coryd.dev/tv/missing-tv.jpg',
|
.toLowerCase()}.jpg` || 'https://cdn.coryd.dev/tv/missing-tv.jpg',
|
||||||
episode: episode['episode']['number'],
|
episode: episodeNumber,
|
||||||
season: episode['episode']['season'],
|
season: seasonNumber,
|
||||||
type: 'tv',
|
type: 'tv',
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
Reference in a new issue