Fail-Safe fix when author data of video is missing (#825)

* Fail-Safe fix when author data of video is missing

* Fixed linter issues by replacing hasownproperty with in

* Implemented Prestons addition for the user thumbnail
This commit is contained in:
Luca Hohmann 2020-12-02 19:35:03 +01:00 committed by GitHub
parent 2c71dedb06
commit 460934752c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 11 additions and 6 deletions

View File

@ -200,9 +200,16 @@ export default Vue.extend({
result.player_response.videoDetails.viewCount,
10
)
this.channelId = result.videoDetails.author.id
this.channelName = result.videoDetails.author.name
this.channelThumbnail = result.videoDetails.author.thumbnails[0].url
if ('id' in result.videoDetails.author) {
this.channelId = result.videoDetails.author.id
this.channelName = result.videoDetails.author.name
console.log(result)
this.channelThumbnail = result.videoDetails.author.thumbnails[0].url
} else {
this.channelId = result.player_response.videoDetails.channelId
this.channelName = result.player_response.videoDetails.author
this.channelThumbnail = result.player_response.embedPreview.thumbnailPreviewRenderer.videoDetails.embeddedPlayerOverlayVideoDetailsRenderer.channelThumbnail.thumbnails[0].url
}
this.videoPublished = new Date(result.videoDetails.publishDate.replace('-', '/')).getTime()
this.videoDescription = result.player_response.videoDetails.shortDescription
@ -337,9 +344,7 @@ export default Vue.extend({
return object
})
let captionLinks = result.playerResponse.captions
let captionLinks = result.player_response.captions
if (typeof captionLinks !== 'undefined') {
captionLinks = captionLinks.playerCaptionsTracklistRenderer.captionTracks.map((caption) => {
const label = `${caption.name.simpleText} (${caption.languageCode}) - text/vtt`