Do not keep invalid YT video info

This commit is contained in:
Rafał Dzięgiel
2021-03-12 15:10:18 +01:00
parent c89d488c30
commit 46d24536c0

View File

@@ -56,23 +56,21 @@ var YouTubeClient = GObject.registerClass({
continue; continue;
} }
/* Check if video is playable */ const invalidInfoMsg = (
if(
!info.playabilityStatus !info.playabilityStatus
|| !info.playabilityStatus.status === 'OK' || !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.emit('info-resolved', false);
this.downloadingVideoId = null; this.downloadingVideoId = null;
return reject(new Error('video is not playable')); return reject(new Error(invalidInfoMsg));
}
/* 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'));
} }
this.lastInfo = info; this.lastInfo = info;
@@ -82,6 +80,8 @@ var YouTubeClient = GObject.registerClass({
return resolve(info); 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.emit('info-resolved', false);
this.downloadingVideoId = null; this.downloadingVideoId = null;