From 47a493e3688deab8510e66ceca1634e72df79c0e Mon Sep 17 00:00:00 2001 From: Preston Date: Wed, 2 Dec 2020 13:36:08 -0500 Subject: [PATCH] Update search module and add error handling for more videos --- package-lock.json | 6 ++-- package.json | 2 +- .../watch-video-info/watch-video-info.js | 4 +++ src/renderer/views/Watch/Watch.js | 28 +++++++++++++++++++ 4 files changed, 36 insertions(+), 4 deletions(-) diff --git a/package-lock.json b/package-lock.json index 07f5cb7f5..1a1d54bfb 100644 --- a/package-lock.json +++ b/package-lock.json @@ -18590,9 +18590,9 @@ } }, "ytsr": { - "version": "2.0.0-alpha.3", - "resolved": "https://registry.npmjs.org/ytsr/-/ytsr-2.0.0-alpha.3.tgz", - "integrity": "sha512-NELl/ubEnBxxU/AofsXu8p6T2BArf/ROLOocblTgeSr7oNPPn6jPv57MCT4cIWJdzxWiHcdl6BqrypoIPejfmw==", + "version": "2.0.0-alpha.4", + "resolved": "https://registry.npmjs.org/ytsr/-/ytsr-2.0.0-alpha.4.tgz", + "integrity": "sha512-iEXOu0kFwxr9O+mpG3tnZa6TovEOZ92N0rNmyZFEv5EdcFg9FWH8MEUJVMExCFhSYu1rSFv5napQCzDCozizdg==", "requires": { "html-entities": "^1.3.1", "miniget": "^4.1.0" diff --git a/package.json b/package.json index 302e108dc..20f797388 100644 --- a/package.json +++ b/package.json @@ -49,7 +49,7 @@ "yt-xml2vtt": "^1.1.3", "ytdl-core": "^4.1.1", "ytpl": "^2.0.0-alpha.3", - "ytsr": "^2.0.0-alpha.3" + "ytsr": "^2.0.0-alpha.4" }, "description": "A private YouTube client", "devDependencies": { diff --git a/src/renderer/components/watch-video-info/watch-video-info.js b/src/renderer/components/watch-video-info/watch-video-info.js index 31f226b63..89c62bcfe 100644 --- a/src/renderer/components/watch-video-info/watch-video-info.js +++ b/src/renderer/components/watch-video-info/watch-video-info.js @@ -197,6 +197,10 @@ export default Vue.extend({ }, handleSubscription: function () { + if (this.channelId === '') { + return + } + const currentProfile = JSON.parse(JSON.stringify(this.profileList[this.activeProfile])) const primaryProfile = JSON.parse(JSON.stringify(this.profileList[0])) diff --git a/src/renderer/views/Watch/Watch.js b/src/renderer/views/Watch/Watch.js index e9ff2a8b3..58957bd5f 100644 --- a/src/renderer/views/Watch/Watch.js +++ b/src/renderer/views/Watch/Watch.js @@ -195,6 +195,30 @@ export default Vue.extend({ .dispatch('ytGetVideoInformation', this.videoId) .then(async result => { console.log(result) + + const playabilityStatus = result.player_response.playabilityStatus + if (playabilityStatus.status !== 'OK') { + const errorScreen = playabilityStatus.errorScreen.playerErrorMessageRenderer + const reason = errorScreen.reason.simpleText + let subReason + let skipIndex + errorScreen.subreason.runs.forEach((message, index) => { + if (index !== skipIndex) { + if (message.text.match(//)) { + skipIndex = index + 1 + } else if (!message.text.match(/<\/a>/)) { + if (typeof subReason === 'undefined') { + subReason = message.text + } else { + subReason = subReason + message.text + } + } + } + }) + + throw new Error(`${reason}: ${subReason}`) + } + this.videoTitle = result.videoDetails.title this.videoViewCount = parseInt( result.player_response.videoDetails.viewCount, @@ -457,6 +481,10 @@ export default Vue.extend({ .then(result => { console.log(result) + if (result.error) { + throw new Error(result.error) + } + this.videoTitle = result.title this.videoViewCount = result.viewCount if (this.hideVideoLikesAndDislikes) {