Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 30 additions & 13 deletions src/renderer/views/Watch/Watch.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@ export default defineComponent({
videoDescriptionHtml: '',
videoViewCount: 0,
videoLikeCount: 0,
videoDislikeCount: 0,
videoLengthSeconds: 0,
videoChapters: [],
videoCurrentChapterIndex: 0,
Expand Down Expand Up @@ -355,16 +354,6 @@ export default defineComponent({
break
}

if (this.hideVideoLikesAndDislikes) {
this.videoLikeCount = null
this.videoDislikeCount = null
} else {
this.videoLikeCount = isNaN(result.basic_info.like_count) ? 0 : result.basic_info.like_count

// YouTube doesn't return dislikes anymore
this.videoDislikeCount = 0
}

this.isLive = !!result.basic_info.is_live
this.isUpcoming = !!result.basic_info.is_upcoming
this.isLiveContent = !!result.basic_info.is_live_content
Expand Down Expand Up @@ -648,6 +637,22 @@ export default defineComponent({

this.isLoading = false
this.updateTitle()

if (this.hideVideoLikesAndDislikes) {
this.videoLikeCount = null
} else {
try {
if (!isNaN(result.basic_info.like_count)) {
this.videoLikeCount = result.basic_info.like_count
} else {
console.warn('Had to fallback to invidious to get video likes')
this.getLikesInvidious()
}
} catch {
this.videoLikeCount = 0
console.error('Could not load video likes')
}
}
} catch (err) {
const errorMessage = this.$t('Local API Error (Click to copy)')
showToast(`${errorMessage}: ${err}`, 10000, () => {
Expand All @@ -665,6 +670,20 @@ export default defineComponent({
}
},

getLikesInvidious: function() {
invidiousGetVideoInformation(this.videoId).then(async result => {
if (result.error) {
throw new Error(result.error)
}

if (this.hideVideoLikesAndDislikes) {
this.videoLikeCount = null
} else {
this.videoLikeCount = result.likeCount
}
})
},

getVideoInformationInvidious: function () {
if (this.firstLoad) {
this.isLoading = true
Expand All @@ -683,10 +702,8 @@ export default defineComponent({
this.channelSubscriptionCountText = isNaN(result.subCountText) ? '' : result.subCountText
if (this.hideVideoLikesAndDislikes) {
this.videoLikeCount = null
this.videoDislikeCount = null
} else {
this.videoLikeCount = result.likeCount
this.videoDislikeCount = result.dislikeCount
}

this.channelId = result.authorId
Expand Down
1 change: 0 additions & 1 deletion src/renderer/views/Watch/Watch.vue
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,6 @@
:published="videoPublished"
:subscription-count-text="channelSubscriptionCountText"
:like-count="videoLikeCount"
:dislike-count="videoDislikeCount"
:view-count="videoViewCount"
:get-timestamp="getTimestamp"
:is-live-content="isLiveContent"
Expand Down