YT: do not check playability of saved temp data

Saved video info is always playable, otherwise its not saved in first place.
This commit is contained in:
Rafał Dzięgiel
2021-03-19 11:43:37 +01:00
parent 6dc825dfb3
commit b42843be1f

View File

@@ -119,7 +119,6 @@ var YouTubeClient = GObject.registerClass({
if(!result) if(!result)
result = await this._getPlayerInfoPromise(videoId).catch(debug); result = await this._getPlayerInfoPromise(videoId).catch(debug);
if(!result || !result.data) { if(!result || !result.data) {
if(result && result.isAborted) { if(result && result.isAborted) {
debug(new Error('download aborted')); debug(new Error('download aborted'));
@@ -129,7 +128,6 @@ var YouTubeClient = GObject.registerClass({
if(!result) if(!result)
result = await this._getInfoPromise(videoId).catch(debug); result = await this._getInfoPromise(videoId).catch(debug);
if(!result || !result.data) { if(!result || !result.data) {
if(result && result.isAborted) if(result && result.isAborted)
debug(new Error('download aborted')); debug(new Error('download aborted'));
@@ -137,19 +135,14 @@ var YouTubeClient = GObject.registerClass({
break; break;
} }
const invalidInfoMsg = ( if(!isFoundInTemp) {
!result.data.playabilityStatus const [isPlayable, reason] = this._getPlayabilityStatus(result.data);
|| !result.data.playabilityStatus.status === 'OK'
)
? 'video is not playable'
: (!result.data.streamingData)
? 'video response data is missing streaming data'
: null;
if(invalidInfoMsg) { if(!isPlayable) {
debug(new Error(invalidInfoMsg)); debug(new Error(reason));
break; break;
} }
}
const info = this._getReducedInfo(result.data); 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) _getReducedInfo(info)
{ {
const reduced = { const reduced = {