From 46d24536c0972acbce4380257fafaa288cfa9a18 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Dzi=C4=99giel?= Date: Fri, 12 Mar 2021 15:10:18 +0100 Subject: [PATCH] Do not keep invalid YT video info --- src/youtube.js | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/youtube.js b/src/youtube.js index ff6ee95f..aed15e9d 100644 --- a/src/youtube.js +++ b/src/youtube.js @@ -56,23 +56,21 @@ var YouTubeClient = GObject.registerClass({ continue; } - /* Check if video is playable */ - if( + const invalidInfoMsg = ( !info.playabilityStatus || !info.playabilityStatus.status === 'OK' - ) { + ) + ? 'video is not playable' + : (!info.streamingData) + ? 'video response data is missing URIs' + : null; + + if(invalidInfoMsg) { + this.lastInfo = null; this.emit('info-resolved', false); this.downloadingVideoId = null; - return reject(new Error('video is not playable')); - } - - /* Check if data contains streaming URIs */ - if(!info.streamingData) { - this.emit('info-resolved', false); - this.downloadingVideoId = null; - - return reject(new Error('video response data is missing URIs')); + return reject(new Error(invalidInfoMsg)); } this.lastInfo = info; @@ -82,6 +80,8 @@ var YouTubeClient = GObject.registerClass({ return resolve(info); } + /* Do not clear video info here, as we still have + * valid info from last video that can be reused */ this.emit('info-resolved', false); this.downloadingVideoId = null;