fix(title): fix title page crash
due to upstream change in data, title page was broken. this commit fixes thate BREAKING CHANGE: older versions won't work, at least for title route
This commit is contained in:
parent
cbce2cac34
commit
8ce02d0236
2 changed files with 17 additions and 33 deletions
|
@ -516,9 +516,11 @@ export default interface RawTitle {
|
||||||
canRate: {
|
canRate: {
|
||||||
isRatable: boolean;
|
isRatable: boolean;
|
||||||
};
|
};
|
||||||
titleCardGenres: {
|
titleGenres: {
|
||||||
genres: Array<{
|
genres: Array<{
|
||||||
text: string;
|
genre: {
|
||||||
|
text: string;
|
||||||
|
};
|
||||||
}>;
|
}>;
|
||||||
};
|
};
|
||||||
canHaveEpisodes: boolean;
|
canHaveEpisodes: boolean;
|
||||||
|
|
|
@ -18,11 +18,7 @@ const cleanTitle = (rawData: RawTitle) => {
|
||||||
// originalTitle: main.originalTitleText.text,
|
// originalTitle: main.originalTitleText.text,
|
||||||
// }),
|
// }),
|
||||||
type: {
|
type: {
|
||||||
id: main.titleType.id as
|
id: main.titleType.id as 'movie' | 'tvSeries' | 'tvEpisode' | 'videoGame',
|
||||||
| 'movie'
|
|
||||||
| 'tvSeries'
|
|
||||||
| 'tvEpisode'
|
|
||||||
| 'videoGame',
|
|
||||||
name: main.titleType.text,
|
name: main.titleType.text,
|
||||||
},
|
},
|
||||||
...(main.productionStatus && {
|
...(main.productionStatus && {
|
||||||
|
@ -47,10 +43,7 @@ const cleanTitle = (rawData: RawTitle) => {
|
||||||
ranking: {
|
ranking: {
|
||||||
position: main.meterRanking.currentRank,
|
position: main.meterRanking.currentRank,
|
||||||
change: main.meterRanking.rankChange.difference,
|
change: main.meterRanking.rankChange.difference,
|
||||||
direction: main.meterRanking.rankChange.changeDirection as
|
direction: main.meterRanking.rankChange.changeDirection as 'UP' | 'DOWN' | 'FLAT',
|
||||||
| 'UP'
|
|
||||||
| 'DOWN'
|
|
||||||
| 'FLAT',
|
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
genres: main.genres.genres.map(genre => ({
|
genres: main.genres.genres.map(genre => ({
|
||||||
|
@ -151,8 +144,7 @@ const cleanTitle = (rawData: RawTitle) => {
|
||||||
totalEpisodes: misc.episodes.episodes.total,
|
totalEpisodes: misc.episodes.episodes.total,
|
||||||
seasons: misc.episodes.seasons.map(season => season.number),
|
seasons: misc.episodes.seasons.map(season => season.number),
|
||||||
years: misc.episodes.years.map(year => year.year),
|
years: misc.episodes.years.map(year => year.year),
|
||||||
topRatedEpisode:
|
topRatedEpisode: misc.episodes.topRated.edges[0].node.ratingsSummary.aggregateRating,
|
||||||
misc.episodes.topRated.edges[0].node.ratingsSummary.aggregateRating,
|
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
|
@ -200,8 +192,7 @@ const cleanTitle = (rawData: RawTitle) => {
|
||||||
startText: misc.connections.edges[0].node.category.text,
|
startText: misc.connections.edges[0].node.category.text,
|
||||||
title: {
|
title: {
|
||||||
id: misc.connections.edges[0].node.associatedTitle.id,
|
id: misc.connections.edges[0].node.associatedTitle.id,
|
||||||
year: misc.connections.edges[0].node.associatedTitle.releaseYear
|
year: misc.connections.edges[0].node.associatedTitle.releaseYear.year,
|
||||||
.year,
|
|
||||||
text: misc.connections.edges[0].node.associatedTitle.titleText.text,
|
text: misc.connections.edges[0].node.associatedTitle.titleText.text,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -209,10 +200,7 @@ const cleanTitle = (rawData: RawTitle) => {
|
||||||
...(misc.soundtrack.edges.length && {
|
...(misc.soundtrack.edges.length && {
|
||||||
soundTrack: {
|
soundTrack: {
|
||||||
title: misc.soundtrack.edges[0].node.text,
|
title: misc.soundtrack.edges[0].node.text,
|
||||||
htmls:
|
htmls: misc.soundtrack.edges[0].node.comments?.map(html => html.plaidHtml) || null,
|
||||||
misc.soundtrack.edges[0].node.comments?.map(
|
|
||||||
html => html.plaidHtml
|
|
||||||
) || null,
|
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
|
@ -235,8 +223,7 @@ const cleanTitle = (rawData: RawTitle) => {
|
||||||
},
|
},
|
||||||
review: {
|
review: {
|
||||||
summary: misc.featuredReviews.edges[0].node.summary.originalText,
|
summary: misc.featuredReviews.edges[0].node.summary.originalText,
|
||||||
html: misc.featuredReviews.edges[0].node.text.originalText
|
html: misc.featuredReviews.edges[0].node.text.originalText.plaidHtml,
|
||||||
.plaidHtml,
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
|
@ -329,14 +316,13 @@ const cleanTitle = (rawData: RawTitle) => {
|
||||||
})),
|
})),
|
||||||
}),
|
}),
|
||||||
...(misc.technicalSpecifications.aspectRatios.items.length && {
|
...(misc.technicalSpecifications.aspectRatios.items.length && {
|
||||||
aspectRatios: misc.technicalSpecifications.aspectRatios.items.map(
|
aspectRatios: misc.technicalSpecifications.aspectRatios.items.map(item => item.aspectRatio),
|
||||||
item => item.aspectRatio
|
|
||||||
),
|
|
||||||
}),
|
}),
|
||||||
...(misc.technicalSpecifications.colorations.items.length && {
|
...(misc.technicalSpecifications.colorations.items.length && {
|
||||||
colorations: misc.technicalSpecifications.colorations.items.map(
|
colorations: misc.technicalSpecifications.colorations.items.map(item => ({
|
||||||
item => ({ id: item.conceptId, name: item.text })
|
id: item.conceptId,
|
||||||
),
|
name: item.text,
|
||||||
|
})),
|
||||||
}),
|
}),
|
||||||
...(main.runtime && { runtime: main.runtime?.seconds }),
|
...(main.runtime && { runtime: main.runtime?.seconds }),
|
||||||
},
|
},
|
||||||
|
@ -350,11 +336,7 @@ const cleanTitle = (rawData: RawTitle) => {
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
type: {
|
type: {
|
||||||
id: title.node.titleType.id as
|
id: title.node.titleType.id as 'movie' | 'tvSeries' | 'tvEpisode' | 'videoGame',
|
||||||
| 'movie'
|
|
||||||
| 'tvSeries'
|
|
||||||
| 'tvEpisode'
|
|
||||||
| 'videoGame',
|
|
||||||
text: title.node.titleType.text,
|
text: title.node.titleType.text,
|
||||||
},
|
},
|
||||||
certificate: title.node.certificate?.rating || null,
|
certificate: title.node.certificate?.rating || null,
|
||||||
|
@ -369,7 +351,7 @@ const cleanTitle = (rawData: RawTitle) => {
|
||||||
avg: title.node.ratingsSummary.aggregateRating || null,
|
avg: title.node.ratingsSummary.aggregateRating || null,
|
||||||
numVotes: title.node.ratingsSummary.voteCount,
|
numVotes: title.node.ratingsSummary.voteCount,
|
||||||
},
|
},
|
||||||
genres: title.node.titleCardGenres.genres.map(genre => genre.text),
|
genres: title.node.titleGenres.genres.map(genre => genre.genre.text),
|
||||||
})),
|
})),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue