From 50d5f39e7263cf7742ec2abaabc6e784cfc2b525 Mon Sep 17 00:00:00 2001 From: Ivan Paramonau Date: Fri, 19 Jul 2024 17:48:39 -0400 Subject: [PATCH 1/6] oembed: add bitchute.com to known endpoints --- lib/plugins/system/oembed/providers.json | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/plugins/system/oembed/providers.json b/lib/plugins/system/oembed/providers.json index 830702844..47c4f5a0a 100644 --- a/lib/plugins/system/oembed/providers.json +++ b/lib/plugins/system/oembed/providers.json @@ -1094,5 +1094,12 @@ ], "endpoint": "https://display.apester.com/oembed/", "url": "https://renderer.apester.com/v2/{1}" - } + }, + { + "name": "Bitchute", + "templates": [ + "bitchute.com/video/*" + ], + "endpoint": "https://api.bitchute.com/oembed/" + } ] From f70cdb7e5748b2c16ec5a45b5ed712d5425733c0 Mon Sep 17 00:00:00 2001 From: Ivan Paramonau Date: Mon, 22 Jul 2024 21:16:04 -0400 Subject: [PATCH 2/6] domains: handle FB reels through a plugin --- plugins/domains/facebook.com/facebook.video.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/plugins/domains/facebook.com/facebook.video.js b/plugins/domains/facebook.com/facebook.video.js index 8127ba3bd..657c75ae7 100644 --- a/plugins/domains/facebook.com/facebook.video.js +++ b/plugins/domains/facebook.com/facebook.video.js @@ -9,13 +9,20 @@ export default { /^https?:\/\/(?:www|business)\.facebook\.com\/video\.php.*[\?&]v=(\d+)(?:$|&)/i, /^https?:\/\/(?:www|business)\.facebook\.com\/video\.php.*[\?&]id=(\d+)(?:$|&)/i, /^https?:\/\/(?:www|business)\.facebook\.com\/[a-zA-Z0-9\.]+\/videos\/(?:[a-zA-Z0-9\-]+\/)?(\d+)/i, - /^https?:\/\/(?:www|business)\.facebook\.com\/watch\/?\?(?:.+&)?v=(\d+)/i + /^https?:\/\/(?:www|business)\.facebook\.com\/watch\/?\?(?:.+&)?v=(\d+)/i, + /^https?:\/\/(?:www|business)\.facebook\.com\/reel\/(\d+)/i ], mixins: ["fb-error"], getLink: function(url, oembed, options) { + if (/^https:\/\/(?:www\.)?instagram\.com/i.test(oembed.author_url)) { + return { + message: "This video can't be embedded because it may contain content owned by someone else." + } + } + var html = oembed.html.replace(/connect\.facebook\.net\/\w{2}_\w{2}\/sdk\.js/i, 'connect.facebook.net/' + options.getProviderOptions('locale', 'en_US').replace('-', '_') + '/sdk.js'); From 7c84b7856adb36b275a72790c2161a98c150a87c Mon Sep 17 00:00:00 2001 From: Ivan Paramonau Date: Mon, 22 Jul 2024 21:27:55 -0400 Subject: [PATCH 3/6] remove debug --- plugins/domains/facebook.com/facebook.video.js | 6 ------ 1 file changed, 6 deletions(-) diff --git a/plugins/domains/facebook.com/facebook.video.js b/plugins/domains/facebook.com/facebook.video.js index 657c75ae7..6f78265d0 100644 --- a/plugins/domains/facebook.com/facebook.video.js +++ b/plugins/domains/facebook.com/facebook.video.js @@ -17,12 +17,6 @@ export default { getLink: function(url, oembed, options) { - if (/^https:\/\/(?:www\.)?instagram\.com/i.test(oembed.author_url)) { - return { - message: "This video can't be embedded because it may contain content owned by someone else." - } - } - var html = oembed.html.replace(/connect\.facebook\.net\/\w{2}_\w{2}\/sdk\.js/i, 'connect.facebook.net/' + options.getProviderOptions('locale', 'en_US').replace('-', '_') + '/sdk.js'); From b925fa76867f5c42560282f1c8a57a3ee3a2bc5b Mon Sep 17 00:00:00 2001 From: Ivan Paramonau Date: Mon, 22 Jul 2024 21:41:11 -0400 Subject: [PATCH 4/6] tests: remove fb n/a link --- plugins/domains/facebook.com/facebook.video.js | 1 - 1 file changed, 1 deletion(-) diff --git a/plugins/domains/facebook.com/facebook.video.js b/plugins/domains/facebook.com/facebook.video.js index 6f78265d0..e7c14a68d 100644 --- a/plugins/domains/facebook.com/facebook.video.js +++ b/plugins/domains/facebook.com/facebook.video.js @@ -52,7 +52,6 @@ export default { tests: [ "http://www.facebook.com/video/video.php?v=4253262701205&set=vb.1574932468&type=2", - "http://www.facebook.com/photo.php?v=4253262701205&set=vb.1574932468&type=2&theater", "https://business.facebook.com/KMPHFOX26/videos/10154356403004012/", "https://www.facebook.com/sugarandsoulco/videos/1484037581637646/?pnref=story", "https://www.facebook.com/watch/?v=235613163792499", From 63d490cf4180744e669edb2438fd6d5528eba480 Mon Sep 17 00:00:00 2001 From: Ivan Paramonau Date: Tue, 23 Jul 2024 08:54:35 -0400 Subject: [PATCH 5/6] html: fix `too_many_redirects` handler and use it for FB --- lib/plugins/system/htmlparser/htmlparser.js | 2 +- plugins/custom/meta-fallback.js | 18 ++++++++++++++++++ .../domains/facebook.com/facebook.thumbnail.js | 7 ++++++- 3 files changed, 25 insertions(+), 2 deletions(-) create mode 100644 plugins/custom/meta-fallback.js diff --git a/lib/plugins/system/htmlparser/htmlparser.js b/lib/plugins/system/htmlparser/htmlparser.js index 0c60d7c94..980350728 100644 --- a/lib/plugins/system/htmlparser/htmlparser.js +++ b/lib/plugins/system/htmlparser/htmlparser.js @@ -43,7 +43,7 @@ export default { headers: {} }); } else if (!!options.exposeStatusCode - && error.message === 'too_many_redirects') { + && error === 'too_many_redirects') { cb(null, { __statusCode: 508, // Hello Instagram, see #503 diff --git a/plugins/custom/meta-fallback.js b/plugins/custom/meta-fallback.js new file mode 100644 index 000000000..56aee1333 --- /dev/null +++ b/plugins/custom/meta-fallback.js @@ -0,0 +1,18 @@ +export default { + + provides: 'meta', + + getData: function(url, __statusCode, options, cb) { + + return __statusCode !== 429 && __statusCode !== 403 &&__statusCode !== 508 + + ? cb({ + responseStatusCode: __statusCode, + }) + + : cb(null, { + meta: {}, + message: `${options.provider || 'Publisher'} is rate-limiting. Meta disabled.` + }) + } +}; \ No newline at end of file diff --git a/plugins/domains/facebook.com/facebook.thumbnail.js b/plugins/domains/facebook.com/facebook.thumbnail.js index e05234d44..03fd2f83d 100644 --- a/plugins/domains/facebook.com/facebook.thumbnail.js +++ b/plugins/domains/facebook.com/facebook.thumbnail.js @@ -12,6 +12,8 @@ export default { 'facebook.video' ], + mixins: ['meta-fallback'], + getLink: function(url, __allowFBThumbnail, options, meta) { var thumbnail = meta.twitter?.image @@ -58,6 +60,8 @@ export default { && options.getProviderOptions('facebook.thumbnail', true) && !/comment_id=/.test(oembed.html)) { options.followHTTPRedirect = true; // avoid security re-directs of URLs if any + options.exposeStatusCode = true; + options.provider = 'Facebook'; return { __allowFBThumbnail: true @@ -67,6 +71,7 @@ export default { tests: [{ noFeeds: true, - skipMethods: ['getData', 'getLink'] + skipMethods: ['getData', 'getLink'], + skipMixins: ['meta-fallback'] }] }; \ No newline at end of file From c29ce0f1957b0eb1247038b693c8741a95a4faac Mon Sep 17 00:00:00 2001 From: Ivan Paramonau Date: Tue, 23 Jul 2024 10:08:35 -0400 Subject: [PATCH 6/6] fix too_many_redirects on error message --- lib/plugins/system/htmlparser/htmlparser.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/plugins/system/htmlparser/htmlparser.js b/lib/plugins/system/htmlparser/htmlparser.js index 980350728..5331371c1 100644 --- a/lib/plugins/system/htmlparser/htmlparser.js +++ b/lib/plugins/system/htmlparser/htmlparser.js @@ -43,7 +43,7 @@ export default { headers: {} }); } else if (!!options.exposeStatusCode - && error === 'too_many_redirects') { + && (error.message === 'too_many_redirects' || error === 'too_many_redirects')) { cb(null, { __statusCode: 508, // Hello Instagram, see #503