From d20f3067034abeb3c3fabb56e3ba1c8d32bbff63 Mon Sep 17 00:00:00 2001 From: PikachuEXE Date: Fri, 17 Mar 2023 15:50:46 +0800 Subject: [PATCH 1/3] ! Fix YT comment loading for video with comment disabled --- .../watch-video-comments.js | 28 ++++++++++++++++--- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/src/renderer/components/watch-video-comments/watch-video-comments.js b/src/renderer/components/watch-video-comments/watch-video-comments.js index 42560289a855b..22e9d33d5beb7 100644 --- a/src/renderer/components/watch-video-comments/watch-video-comments.js +++ b/src/renderer/components/watch-video-comments/watch-video-comments.js @@ -191,6 +191,16 @@ export default defineComponent({ this.isLoading = false this.showComments = true } catch (err) { + if (err.message.includes('Comments page did not have any content')) { + // For videos without any comment (comment disabled?) + // e.g. https://youtu.be/8NBSwDEf8a8 + this.commentData = [] + this.nextPageToken = null + this.isLoading = false + this.showComments = true + return + } + console.error(err) const errorMessage = this.$t('Local API Error (Click to copy)') showToast(`${errorMessage}: ${err}`, 10000, () => { @@ -248,11 +258,21 @@ export default defineComponent({ this.nextPageToken = response.continuation this.isLoading = false this.showComments = true - }).catch((xhr) => { - console.error(xhr) + }).catch((err) => { + if (err.message.includes('Comments not found')) { + // For videos without any comment (comment disabled?) + // e.g. https://youtu.be/8NBSwDEf8a8 + this.commentData = [] + this.nextPageToken = null + this.isLoading = false + this.showComments = true + return + } + + console.error(err) const errorMessage = this.$t('Invidious API Error (Click to copy)') - showToast(`${errorMessage}: ${xhr.responseText}`, 10000, () => { - copyToClipboard(xhr.responseText) + showToast(`${errorMessage}: ${err}`, 10000, () => { + copyToClipboard(err) }) if (process.env.IS_ELECTRON && this.backendFallback && this.backendPreference === 'invidious') { showToast(this.$t('Falling back to local API')) From 51441d66148d383548d86f15f3550ad684a88d67 Mon Sep 17 00:00:00 2001 From: PikachuEXE Date: Mon, 20 Mar 2023 11:13:25 +0800 Subject: [PATCH 2/3] * Update video view w/ Local API to render video comment disabled as no comment --- .../watch-video-comments.js | 32 ++++++++++++------- src/renderer/views/Watch/Watch.js | 12 +++++++ src/renderer/views/Watch/Watch.vue | 1 + 3 files changed, 34 insertions(+), 11 deletions(-) diff --git a/src/renderer/components/watch-video-comments/watch-video-comments.js b/src/renderer/components/watch-video-comments/watch-video-comments.js index 22e9d33d5beb7..b51d7c1673344 100644 --- a/src/renderer/components/watch-video-comments/watch-video-comments.js +++ b/src/renderer/components/watch-video-comments/watch-video-comments.js @@ -32,6 +32,10 @@ export default defineComponent({ type: Boolean, required: true }, + forceState: { + type: String, + default: null, + }, }, data: function () { return { @@ -110,7 +114,20 @@ export default defineComponent({ return this.commentData.length > 0 && !this.isLoading && this.showComments && this.nextPageToken }, }, - + mounted: function () { + // region No comment detection + // For videos without any comment (comment disabled?) + // e.g. https://youtu.be/8NBSwDEf8a8 + // + // `comments_entry_point_header` is null probably when comment disabled + if (this.forceState === 'noComment') { + this.commentData = [] + this.nextPageToken = null + this.isLoading = false + this.showComments = true + } + // endregion No comment detection + }, methods: { onTimestamp: function (timestamp) { this.$emit('timestamp-event', timestamp) @@ -191,16 +208,6 @@ export default defineComponent({ this.isLoading = false this.showComments = true } catch (err) { - if (err.message.includes('Comments page did not have any content')) { - // For videos without any comment (comment disabled?) - // e.g. https://youtu.be/8NBSwDEf8a8 - this.commentData = [] - this.nextPageToken = null - this.isLoading = false - this.showComments = true - return - } - console.error(err) const errorMessage = this.$t('Local API Error (Click to copy)') showToast(`${errorMessage}: ${err}`, 10000, () => { @@ -259,6 +266,8 @@ export default defineComponent({ this.isLoading = false this.showComments = true }).catch((err) => { + // region No comment detection + // No comment related info when video info requested earlier in parent component if (err.message.includes('Comments not found')) { // For videos without any comment (comment disabled?) // e.g. https://youtu.be/8NBSwDEf8a8 @@ -268,6 +277,7 @@ export default defineComponent({ this.showComments = true return } + // endregion No comment detection console.error(err) const errorMessage = this.$t('Invidious API Error (Click to copy)') diff --git a/src/renderer/views/Watch/Watch.js b/src/renderer/views/Watch/Watch.js index 260a2ec997744..61efb98057719 100644 --- a/src/renderer/views/Watch/Watch.js +++ b/src/renderer/views/Watch/Watch.js @@ -98,6 +98,7 @@ export default defineComponent({ playNextTimeout: null, playNextCountDownIntervalId: null, infoAreaSticky: true, + commentsEnabled: true, } }, computed: { @@ -617,6 +618,17 @@ export default defineComponent({ } } + // region No comment detection + // For videos without any comment (comment disabled?) + // e.g. https://youtu.be/8NBSwDEf8a8 + // + // `comments_entry_point_header` is null probably when comment disabled + // e.g. https://youtu.be/8NBSwDEf8a8 + // However videos with comments enabled but have no comment + // are different (which is not detected here) + this.commentsEnabled = result.comments_entry_point_header != null + // endregion No comment detection + this.isLoading = false this.updateTitle() } catch (err) { diff --git a/src/renderer/views/Watch/Watch.vue b/src/renderer/views/Watch/Watch.vue index ceb0086ac1985..9fb25d0950142 100644 --- a/src/renderer/views/Watch/Watch.vue +++ b/src/renderer/views/Watch/Watch.vue @@ -143,6 +143,7 @@ :channel-thumbnail="channelThumbnail" :channel-name="channelName" :video-player-ready="videoPlayerReady" + :force-state="commentsEnabled ? null : 'noComment'" @timestamp-event="changeTimestamp" /> From 8d9274b31f30b8d24998ca38c71ccc584a2e16e8 Mon Sep 17 00:00:00 2001 From: PikachuEXE Date: Wed, 19 Apr 2023 09:12:16 +0800 Subject: [PATCH 3/3] ! Fix style with less side effects --- .../watch-video-comments.css | 18 +++++++++--------- .../watch-video-comments.vue | 2 +- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/renderer/components/watch-video-comments/watch-video-comments.css b/src/renderer/components/watch-video-comments/watch-video-comments.css index 6a8aa47647f71..9da563ac891ef 100644 --- a/src/renderer/components/watch-video-comments/watch-video-comments.css +++ b/src/renderer/components/watch-video-comments/watch-video-comments.css @@ -17,16 +17,18 @@ color: var(--title-color); } -.commentsTitle, -.getMoreComments { - padding-bottom: 1em; +.noCommentMsg { padding-top: 1em; -} + padding-bottom: 1em; -.center { text-align: center; } +.commentsTitle { + padding-bottom: 1em; + padding-top: 1em; +} + .commentSort { float: right; } @@ -36,10 +38,6 @@ position: relative; } -.comment:last-child { - padding-bottom: 0; -} - .hideComments { font-size: 13px; text-decoration: underline; @@ -166,6 +164,8 @@ } .getMoreComments { + padding-bottom: 1em; + text-align: center; text-decoration: underline; cursor: pointer; diff --git a/src/renderer/components/watch-video-comments/watch-video-comments.vue b/src/renderer/components/watch-video-comments/watch-video-comments.vue index c718683d58377..172bf3e73bee9 100644 --- a/src/renderer/components/watch-video-comments/watch-video-comments.vue +++ b/src/renderer/components/watch-video-comments/watch-video-comments.vue @@ -233,7 +233,7 @@
-

+

{{ $t("There are no comments available for this video") }}