From b42843be1f4323e57c19bb400360b81b654c6723 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Dzi=C4=99giel?= Date: Fri, 19 Mar 2021 11:43:37 +0100 Subject: [PATCH] YT: do not check playability of saved temp data Saved video info is always playable, otherwise its not saved in first place. --- src/youtube.js | 33 ++++++++++++++++++++------------- 1 file changed, 20 insertions(+), 13 deletions(-) diff --git a/src/youtube.js b/src/youtube.js index 69c23e3e..0f13feae 100644 --- a/src/youtube.js +++ b/src/youtube.js @@ -119,7 +119,6 @@ var YouTubeClient = GObject.registerClass({ if(!result) result = await this._getPlayerInfoPromise(videoId).catch(debug); - if(!result || !result.data) { if(result && result.isAborted) { debug(new Error('download aborted')); @@ -129,7 +128,6 @@ var YouTubeClient = GObject.registerClass({ if(!result) result = await this._getInfoPromise(videoId).catch(debug); - if(!result || !result.data) { if(result && result.isAborted) debug(new Error('download aborted')); @@ -137,18 +135,13 @@ var YouTubeClient = GObject.registerClass({ break; } - const invalidInfoMsg = ( - !result.data.playabilityStatus - || !result.data.playabilityStatus.status === 'OK' - ) - ? 'video is not playable' - : (!result.data.streamingData) - ? 'video response data is missing streaming data' - : null; + if(!isFoundInTemp) { + const [isPlayable, reason] = this._getPlayabilityStatus(result.data); - if(invalidInfoMsg) { - debug(new Error(invalidInfoMsg)); - break; + if(!isPlayable) { + debug(new Error(reason)); + break; + } } const info = this._getReducedInfo(result.data); @@ -352,6 +345,20 @@ var YouTubeClient = GObject.registerClass({ }); } + _getPlayabilityStatus(info) + { + if( + !info.playabilityStatus + || !info.playabilityStatus.status === 'OK' + ) + return [false, 'video is not playable']; + + if(!info.streamingData) + return [false, 'video response data is missing streaming data']; + + return [true, null]; + } + _getReducedInfo(info) { const reduced = {