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