Update search module and add error handling for more videos

This commit is contained in:
Preston 2020-12-02 13:36:08 -05:00
parent 460934752c
commit 47a493e368
4 changed files with 36 additions and 4 deletions

6
package-lock.json generated
View File

@ -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"

View File

@ -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": {

View File

@ -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]))

View File

@ -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(/<a.*>/)) {
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) {