From a2ec742ad67167293f9728a2111b1da106932678 Mon Sep 17 00:00:00 2001 From: absidue <48293849+absidue@users.noreply.github.com> Date: Mon, 30 Dec 2024 00:29:19 +0100 Subject: [PATCH 1/2] Detect and properly error on DRM protected videos --- src/renderer/views/Watch/Watch.js | 13 +++++++++++-- static/locales/en-US.yaml | 1 + 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/renderer/views/Watch/Watch.js b/src/renderer/views/Watch/Watch.js index 6b6252c1eeb71..2db619e79022b 100644 --- a/src/renderer/views/Watch/Watch.js +++ b/src/renderer/views/Watch/Watch.js @@ -376,7 +376,7 @@ export default defineComponent({ // extract localised title first and fall back to the not localised one this.videoTitle = result.primary_info?.title.text ?? result.basic_info.title - this.videoViewCount = result.basic_info.view_count ?? extractNumberFromString(result.primary_info.view_count.text) + this.videoViewCount = result.basic_info.view_count ?? (result.primary_info.view_count ? extractNumberFromString(result.primary_info.view_count.text) : 0) this.channelId = result.basic_info.channel_id ?? result.secondary_info.owner?.author.id this.channelName = result.basic_info.author ?? result.secondary_info.owner?.author.name @@ -509,7 +509,9 @@ export default defineComponent({ // The apostrophe is intentionally that one (char code 8217), because that is the one YouTube uses const BOT_MESSAGE = 'Sign in to confirm you’re not a bot' - if (playabilityStatus.status === 'UNPLAYABLE' || playabilityStatus.status === 'LOGIN_REQUIRED') { + const isDrmProtected = result.streaming_data?.adaptive_formats.some(format => format.drm_families || format.drm_track_type) + + if (playabilityStatus.status === 'UNPLAYABLE' || playabilityStatus.status === 'LOGIN_REQUIRED' || isDrmProtected) { if (playabilityStatus.error_screen?.offer_id === 'sponsors_only_video') { // Members-only videos can only be watched while logged into a Google account that is a paid channel member // so there is no point trying any other backends as it will always fail @@ -525,6 +527,13 @@ export default defineComponent({ this.isLoading = false this.updateTitle() return + } else if (isDrmProtected) { + // DRM protected videos (e.g. movies) cannot be played in FreeTube, + // as they require the proprietary and closed source Wideview CDM which is understandably not included in standard Electron builds + this.errorMessage = this.$t('Video.DRMProtected') + this.isLoading = false + this.updateTitle() + return } let errorText diff --git a/static/locales/en-US.yaml b/static/locales/en-US.yaml index b3aaa45826c91..ce8a21da08f82 100644 --- a/static/locales/en-US.yaml +++ b/static/locales/en-US.yaml @@ -806,6 +806,7 @@ Video: IP block: 'YouTube has blocked your IP address from watching videos. Please try switching to a different VPN or proxy.' MembersOnly: Members-only videos cannot be watched with FreeTube as they require Google login and paid membership to the uploader's channel. AgeRestricted: Age-restricted videos cannot be watched with FreeTube as they require Google login and using an age-verified YouTube account. + DRMProtected: DRM protected videos cannot be played in FreeTube, as they require proprietary, closed source components. If you want to watch this video please watch it on the official YouTube website in a DRM enabled web browser. More Options: More Options Mark As Watched: Mark As Watched Remove From History: Remove From History From e6f10d9af17081bb84458057b9c592051604482f Mon Sep 17 00:00:00 2001 From: absidue <48293849+absidue@users.noreply.github.com> Date: Mon, 30 Dec 2024 23:49:20 +0100 Subject: [PATCH 2/2] Fix view count handling --- src/renderer/components/watch-video-info/watch-video-info.js | 4 ++-- src/renderer/views/Watch/Watch.js | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) 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 71cdf1346d26a..cf4488f9ba73a 100644 --- a/src/renderer/components/watch-video-info/watch-video-info.js +++ b/src/renderer/components/watch-video-info/watch-video-info.js @@ -45,7 +45,7 @@ export default defineComponent({ }, viewCount: { type: Number, - required: true + default: null }, subscriptionCountText: { type: String, @@ -197,7 +197,7 @@ export default defineComponent({ }, parsedViewCount: function () { - if (this.hideVideoViews) { + if (this.hideVideoViews || this.viewCount == null) { return null } diff --git a/src/renderer/views/Watch/Watch.js b/src/renderer/views/Watch/Watch.js index 2db619e79022b..cf6fe45453b6d 100644 --- a/src/renderer/views/Watch/Watch.js +++ b/src/renderer/views/Watch/Watch.js @@ -376,7 +376,7 @@ export default defineComponent({ // extract localised title first and fall back to the not localised one this.videoTitle = result.primary_info?.title.text ?? result.basic_info.title - this.videoViewCount = result.basic_info.view_count ?? (result.primary_info.view_count ? extractNumberFromString(result.primary_info.view_count.text) : 0) + this.videoViewCount = result.basic_info.view_count ?? (result.primary_info.view_count ? extractNumberFromString(result.primary_info.view_count.text) : null) this.channelId = result.basic_info.channel_id ?? result.secondary_info.owner?.author.id this.channelName = result.basic_info.author ?? result.secondary_info.owner?.author.name