From 571edae115968ec06ce2662a035043dde9d01aff Mon Sep 17 00:00:00 2001 From: Ivan Paramonau Date: Tue, 29 Oct 2024 11:45:22 -0400 Subject: [PATCH 1/5] domains: remove gifv flag from Dribble shots to avoid double-click in click-to-play --- plugins/domains/dribbble.com.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/domains/dribbble.com.js b/plugins/domains/dribbble.com.js index 77ade2ec2..14f4285a9 100644 --- a/plugins/domains/dribbble.com.js +++ b/plugins/domains/dribbble.com.js @@ -45,7 +45,7 @@ export default { links.push({ href: twitter.player.value, type: CONFIG.T.text_html, - rel: [CONFIG.R.player, CONFIG.R.gifv], + rel: CONFIG.R.player, 'aspect-ratio': twitter.player.width / twitter.player.height, }) } From 0c99934d876494fc8cffd12e2ed68c7c627d8915 Mon Sep 17 00:00:00 2001 From: Ivan Paramonau Date: Wed, 30 Oct 2024 20:56:44 -0400 Subject: [PATCH 2/5] youtube: handler for age-restricted videos --- plugins/domains/youtube.com/youtube.video.js | 40 +++++++++++--------- 1 file changed, 22 insertions(+), 18 deletions(-) diff --git a/plugins/domains/youtube.com/youtube.video.js b/plugins/domains/youtube.com/youtube.video.js index e60c23068..59d4f3feb 100644 --- a/plugins/domains/youtube.com/youtube.video.js +++ b/plugins/domains/youtube.com/youtube.video.js @@ -68,12 +68,11 @@ export default { return cb(error); } - if (data && data.items && data.items.length > 0) { - + if (data?.items?.length > 0) { var entry = data.items[0]; var duration = 0; - var durationStr = entry.contentDetails && entry.contentDetails.duration; + var durationStr = entry.contentDetails?.duration; if (durationStr) { var m = durationStr.match(/(\d+)S/); if (m) { @@ -91,22 +90,24 @@ export default { var gdata = { id: urlMatch[1], - title: entry.snippet && entry.snippet.title, - uploaded: entry.snippet && entry.snippet.publishedAt, - uploader: entry.snippet && entry.snippet.channelTitle, - channelId: entry.snippet && entry.snippet.channelId, - description: entry.snippet && entry.snippet.description, - likeCount: entry.statistics && entry.statistics.likeCount, - dislikeCount: entry.statistics && entry.statistics.dislikeCount, - viewCount: entry.statistics && entry.statistics.viewCount, - - hd: entry.contentDetails && entry.contentDetails.definition === "hd", - playerHtml: entry.player && entry.player.embedHtml, + title: entry.snippet?.title, + uploaded: entry.snippet?.publishedAt, + uploader: entry.snippet?.channelTitle, + channelId: entry.snippet?.channelId, + description: entry.snippet?.description, + likeCount: entry.statistics?.likeCount, + dislikeCount: entry.statistics?.dislikeCount, + viewCount: entry.statistics?.viewCount, + + hd: entry.contentDetails?.definition === "hd", + playerHtml: entry.player?.embedHtml, embeddable: entry.status ? entry.status.embeddable : true, - uploadStatus: entry.status && entry.status.uploadStatus + uploadStatus: entry.status?.uploadStatus, + status: entry.status, + ytRating: entry.contentDetails?.contentRating?.ytRating }; - if (entry.snippet && entry.snippet.thumbnails) { + if (entry.snippet?.thumbnails) { gdata.thumbnails = entry.snippet.thumbnails; } @@ -117,7 +118,7 @@ export default { if (gdata.uploadStatus === "rejected") { cb({ responseStatusCode: 410, - message: "The video has been removed. Reason: " + (entry.status && entry.status.rejectionReason || 'not given') + message: "The video has been removed. Reason: " + (entry.status?.rejectionReason || 'not given') }); } else { cb(null, { @@ -146,6 +147,7 @@ export default { likes: youtube_video_gdata.likeCount, dislikes: youtube_video_gdata.dislikeCount, views: youtube_video_gdata.viewCount, + rating: youtube_video_gdata.ytRating === 'ytAgeRestricted' ? 'age-restricted': null, site: "YouTube", canonical: "https://www.youtube.com/watch?v=" + youtube_video_gdata.id, author_url: "https://www.youtube.com/" + (youtube_video_gdata.channelId ? "channel/" + youtube_video_gdata.channelId : "user/" + youtube_video_gdata.uploader) @@ -254,7 +256,7 @@ export default { var links = []; var aspect = widescreen ? 16 / 9 : 4 / 3; - if (youtube_video_gdata.embeddable) { + if (youtube_video_gdata.embeddable && youtube_video_gdata.ytRating !== 'ytAgeRestricted') { var qs = querystring.stringify(params); if (qs !== '') {qs = '?' + qs} @@ -284,6 +286,8 @@ export default { } } }); + } else if (youtube_video_gdata.ytRating === 'ytAgeRestricted') { + links.push({message: "This video is age-restricted and only available on YouTube"}); } else { links.push({message: (youtube_video_gdata.uploader || "Uploader of this video") + " disabled embedding on other sites."}); } From c42334e15453665d30c6e09a420b6a205adbf0b0 Mon Sep 17 00:00:00 2001 From: Ivan Paramonau Date: Thu, 31 Oct 2024 10:23:19 -0400 Subject: [PATCH 3/5] meta: rename the field for ratings and age-restrictions into "warning" --- plugins/domains/youtube.com/youtube.video.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/domains/youtube.com/youtube.video.js b/plugins/domains/youtube.com/youtube.video.js index 59d4f3feb..f6342e93d 100644 --- a/plugins/domains/youtube.com/youtube.video.js +++ b/plugins/domains/youtube.com/youtube.video.js @@ -147,7 +147,7 @@ export default { likes: youtube_video_gdata.likeCount, dislikes: youtube_video_gdata.dislikeCount, views: youtube_video_gdata.viewCount, - rating: youtube_video_gdata.ytRating === 'ytAgeRestricted' ? 'age-restricted': null, + warning: youtube_video_gdata.ytRating === 'ytAgeRestricted' ? 'age': null, site: "YouTube", canonical: "https://www.youtube.com/watch?v=" + youtube_video_gdata.id, author_url: "https://www.youtube.com/" + (youtube_video_gdata.channelId ? "channel/" + youtube_video_gdata.channelId : "user/" + youtube_video_gdata.uploader) From 0b71da8a8cc8c42f75c279643307cb9ece8f6a34 Mon Sep 17 00:00:00 2001 From: Ivan Paramonau Date: Fri, 1 Nov 2024 10:27:22 -0400 Subject: [PATCH 4/5] youtube: support loop parameter --- plugins/domains/youtube.com/youtube.video.js | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/plugins/domains/youtube.com/youtube.video.js b/plugins/domains/youtube.com/youtube.video.js index f6342e93d..2c9167dfd 100644 --- a/plugins/domains/youtube.com/youtube.video.js +++ b/plugins/domains/youtube.com/youtube.video.js @@ -204,7 +204,7 @@ export default { // https://developers.google.com/youtube/player_parameters#cc_load_policy var cc_load_policy = options.getRequestOptions('youtube.cc_load_policy', params.cc_load_policy); if (cc_load_policy) { - params.cc_load_policy = '1'; + params.cc_load_policy = 1; } else if (params.cc_load_policy) { delete params.cc_load_policy; } @@ -212,11 +212,23 @@ export default { // https://developers.google.com/youtube/player_parameters#controls var controls = options.getRequestOptions('youtube.controls', params.controls); if (controls == 0) { - params.controls = '0'; + params.controls = 0; } else if (params.controls) { delete params.controls; } + // https://developers.google.com/youtube/player_parameters#loop + var loop = options.getRequestOptions('youtube.loop', params.loop); + if (loop) { + params.loop = 1; + // 'To loop a single video, set the loop parameter value to 1 and set the playlist parameter value to the same video ID' + if (!params.playlist) { + params.playlist = youtube_video_gdata.id; + } + } else if (params.loop) { + delete params.loop; + } + // Support for direct links to YouTube clip embeds if (/\/embed\/[^\?]+\?.*clip=.+clipt=.+/i.test(url)) { var uri = url; From f93d596439c0d6deb48e9221513e913c0ad0f89d Mon Sep 17 00:00:00 2001 From: Ivan Paramonau Date: Fri, 1 Nov 2024 12:28:57 -0400 Subject: [PATCH 5/5] fb: remove redundant mixin reference --- plugins/domains/facebook.com/facebook.thumbnail.js | 3 --- 1 file changed, 3 deletions(-) diff --git a/plugins/domains/facebook.com/facebook.thumbnail.js b/plugins/domains/facebook.com/facebook.thumbnail.js index d97c99f87..a8e18318a 100644 --- a/plugins/domains/facebook.com/facebook.thumbnail.js +++ b/plugins/domains/facebook.com/facebook.thumbnail.js @@ -12,8 +12,6 @@ export default { 'facebook.video' ], - mixins: ['facebook.meta-fallback'], - getLink: function(url, __allowFBThumbnail, options, meta) { var thumbnail = meta.twitter?.image @@ -77,6 +75,5 @@ export default { tests: [{ noFeeds: true, skipMethods: ['getData', 'getLink'], - skipMixins: ['facebook.meta-fallback'] }] }; \ No newline at end of file