Fix issue with live videos causing errors in search results

This commit is contained in:
Preston 2021-04-11 18:49:56 -04:00
parent 73f827444e
commit 519128a99a
1 changed files with 9 additions and 8 deletions

View File

@ -136,17 +136,18 @@ export default Vue.extend({
return null return null
}) })
const returnDataInvidious = [] const dataToShow = []
returnData.forEach((video) => { returnData.forEach((video) => {
if (video.type === 'video') { if (video.type === 'video') {
console.log(video)
const authId = video.author.channelID const authId = video.author.channelID
const publishDate = video.uploadedAt const publishDate = video.uploadedAt
let videoDuration = video.duration let videoDuration = video.duration
const videoId = video.id const videoId = video.id
if (video.duration !== null && video.duration !== '') { if (videoDuration !== null && videoDuration !== '' && videoDuration !== 'LIVE') {
videoDuration = ytTrendScraper.calculate_length_in_seconds(video.duration) videoDuration = ytTrendScraper.calculate_length_in_seconds(video.duration)
} }
returnDataInvidious.push( dataToShow.push(
{ {
videoId: videoId, videoId: videoId,
title: video.title, title: video.title,
@ -160,22 +161,22 @@ export default Vue.extend({
published: publishDate, published: publishDate,
publishedText: publishDate, publishedText: publishDate,
lengthSeconds: videoDuration, lengthSeconds: videoDuration,
liveNow: video.isLive, liveNow: video.isLive || videoDuration === 'LIVE',
paid: false, paid: false,
premium: false, premium: false,
isUpcoming: false, isUpcoming: false,
timeText: video.duration timeText: videoDuration
} }
) )
} else { } else {
returnDataInvidious.push(video) dataToShow.push(video)
} }
}) })
if (payload.nextPage) { if (payload.nextPage) {
this.shownResults = this.shownResults.concat(returnDataInvidious) this.shownResults = this.shownResults.concat(dataToShow)
} else { } else {
this.shownResults = returnDataInvidious this.shownResults = dataToShow
} }
this.nextPageRef = result.continuation this.nextPageRef = result.continuation