From 458d478b2c6ced056035889315b5dee73a862b1f Mon Sep 17 00:00:00 2001 From: Nazar Leush Date: Fri, 27 Nov 2015 21:59:39 +0200 Subject: [PATCH 001/320] [promo] parse promo uri from oembed discovery url; discard for=oembed option --- lib/plugins/system/oembed/oembed.js | 29 ++++++++++++++++++++--------- modules/api/views.js | 6 ++---- 2 files changed, 22 insertions(+), 13 deletions(-) diff --git a/lib/plugins/system/oembed/oembed.js b/lib/plugins/system/oembed/oembed.js index 318d0742d..54f2e3e6d 100644 --- a/lib/plugins/system/oembed/oembed.js +++ b/lib/plugins/system/oembed/oembed.js @@ -3,7 +3,7 @@ var urlLib = require('url'); module.exports = { - provides: 'self', + provides: ['self', '__promoUri', '__forcePromo'], getData: function(url, oembedLinks, options, cb) { @@ -25,16 +25,27 @@ module.exports = { } } - if (self_endpoint && !options.forOembed) { + if (self_endpoint) { + var urlObj = urlLib.parse(href, true); - delete urlObj.search; - urlObj.query['for'] = 'oembed'; - href = urlLib.format(urlObj); - skip = false; - } else if (self_endpoint) { - skip = true; + + var promo = urlObj.query.promo; + + if (promo === '1' || promo === 'true') { + + return cb(null, { + __forcePromo: true + }); + + } else if (promo.match(/https?:\/\/.+/i)) { + + return cb(null, { + __promoUri: promo + }); + } } - if (skip) { + + if (skip || self_endpoint) { return cb(null); } diff --git a/modules/api/views.js b/modules/api/views.js index 02f9d4cd6..3e776c02a 100644 --- a/modules/api/views.js +++ b/modules/api/views.js @@ -71,8 +71,7 @@ module.exports = function(app) { getWhitelistRecord: whitelist.findWhitelistRecordFor, maxWidth: getIntParam(req, 'maxwidth') || getIntParam(req, 'max-width'), promoUri: req.query.promoUri, - forcePromo: getBooleanParam(req, 'forcePromo'), - forOembed: req.query['for'] === 'oembed' + forcePromo: getBooleanParam(req, 'forcePromo') }, cb); } @@ -377,8 +376,7 @@ module.exports = function(app) { getWhitelistRecord: whitelist.findWhitelistRecordFor, filterNonSSL: getBooleanParam(req, 'ssl'), filterNonHTML5: getBooleanParam(req, 'html5'), - maxWidth: getIntParam(req, 'maxwidth') || getIntParam(req, 'max-width'), - forOembed: req.query['for'] === 'oembed' + maxWidth: getIntParam(req, 'maxwidth') || getIntParam(req, 'max-width') }, cb); } From 5dea214d41d9f39c9143c937e528818ff122bd15 Mon Sep 17 00:00:00 2001 From: Nazar Leush Date: Tue, 1 Dec 2015 15:48:22 +0200 Subject: [PATCH 002/320] [promo] parse iframe.ly/api/iframe as promo iframe --- lib/plugins/system/promo/promoEmbed.js | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/plugins/system/promo/promoEmbed.js b/lib/plugins/system/promo/promoEmbed.js index 74cbcb40e..68170d83c 100644 --- a/lib/plugins/system/promo/promoEmbed.js +++ b/lib/plugins/system/promo/promoEmbed.js @@ -1,5 +1,6 @@ var res = [ /\/\/iframe\.ly\/\w+/i, + /\/\/iframe\.ly\/api\/iframe/i, /\/\/www\.youtube\.com\/embed\/\w+/i, /\/\/player\.vimeo\.com\/video\/\d+/i, /\/\/w\.soundcloud\.com\/player\//i, From 33c7b3f6a2a18ac07778f796fd4470f96b8a066e Mon Sep 17 00:00:00 2001 From: Nazar Leush Date: Tue, 1 Dec 2015 16:25:30 +0200 Subject: [PATCH 003/320] [promo] parse iframe.ly/api/iframe as promo iframe --- lib/plugins/system/promo/promoEmbed.js | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/lib/plugins/system/promo/promoEmbed.js b/lib/plugins/system/promo/promoEmbed.js index 68170d83c..bea24cea3 100644 --- a/lib/plugins/system/promo/promoEmbed.js +++ b/lib/plugins/system/promo/promoEmbed.js @@ -1,12 +1,25 @@ +var urlLib = require('url'); + +var iframelyApiRe = /iframe\.ly\/api\/iframe.+url=/i; + var res = [ - /\/\/iframe\.ly\/\w+/i, - /\/\/iframe\.ly\/api\/iframe/i, + /iframe\.ly\/\w+/i, + iframelyApiRe, /\/\/www\.youtube\.com\/embed\/\w+/i, /\/\/player\.vimeo\.com\/video\/\d+/i, /\/\/w\.soundcloud\.com\/player\//i, /\/\/vine\.co\/v\/\w+\/embed/i ]; +function extractGetParamUrl(src) { + if (src.match(iframelyApiRe)) { + var urlObj = urlLib.parse(src, true); + return urlObj.query['url']; + } else { + return src; + } +} + module.exports = { provides: '__promoUri', @@ -19,7 +32,7 @@ module.exports = { if (embeds.length) { var href = embeds.attr('href'); return { - __promoUri: href + __promoUri: extractGetParamUrl(href) }; } @@ -39,6 +52,10 @@ module.exports = { } var src = cheerio(this).attr('src'); + if (!src) { + return; + } + var i = 0; while(i < res.length && !src.match(res[i])) { i++; @@ -51,7 +68,7 @@ module.exports = { if (result) { return { - __promoUri: result + __promoUri: extractGetParamUrl(result) }; } } From be7a51a0cc3d88a3caea927bdeac72b5fae1a822 Mon Sep 17 00:00:00 2001 From: Nazar Leush Date: Tue, 1 Dec 2015 17:54:25 +0200 Subject: [PATCH 004/320] [promo] remove soundcloud embed iframe detection, can't recognize canonical --- lib/plugins/system/promo/promoEmbed.js | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/plugins/system/promo/promoEmbed.js b/lib/plugins/system/promo/promoEmbed.js index bea24cea3..1c0a7e4b5 100644 --- a/lib/plugins/system/promo/promoEmbed.js +++ b/lib/plugins/system/promo/promoEmbed.js @@ -7,7 +7,6 @@ var res = [ iframelyApiRe, /\/\/www\.youtube\.com\/embed\/\w+/i, /\/\/player\.vimeo\.com\/video\/\d+/i, - /\/\/w\.soundcloud\.com\/player\//i, /\/\/vine\.co\/v\/\w+\/embed/i ]; From 166f24d07e62fd4387e412ecec02342090b63a40 Mon Sep 17 00:00:00 2001 From: Nazar Leush Date: Wed, 2 Dec 2015 18:47:35 +0200 Subject: [PATCH 005/320] [whitelist] bug fix: add delay to whitelist file reload in case of long writes --- lib/whitelist.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/whitelist.js b/lib/whitelist.js index 5967adc72..0821cda8a 100644 --- a/lib/whitelist.js +++ b/lib/whitelist.js @@ -302,7 +302,10 @@ p = path.resolve('.', p); // Check if newer file added. if (p.match(/iframely-.*\.json/)) { - loadLastWhitelist(); + // Wait sometime to be sure write finished. + setTimeout(function() { + loadLastWhitelist(); + }, 5000); } }); @@ -310,7 +313,10 @@ p = path.resolve('.', p); // Reload last whitelist. if (p == currentWhitelistFilename) { - readWhitelist(p); + // Wait sometime to be sure write finished. + setTimeout(function() { + readWhitelist(p); + }, 5000); } }); From 214872a9cc2f0232661bd76f0def68764d634124 Mon Sep 17 00:00:00 2001 From: Ivan Paramonau Date: Fri, 11 Dec 2015 09:44:11 -0500 Subject: [PATCH 006/320] [domains] move custom domains for BrightCove to domain plugin --- plugins/domains/brightcove.com.js | 23 +++++++++++++++++++++-- plugins/links/brightcove-hosted.js | 15 --------------- 2 files changed, 21 insertions(+), 17 deletions(-) diff --git a/plugins/domains/brightcove.com.js b/plugins/domains/brightcove.com.js index fed8450e5..8e34f9ea5 100644 --- a/plugins/domains/brightcove.com.js +++ b/plugins/domains/brightcove.com.js @@ -1,6 +1,9 @@ module.exports = { - re: /^https?:\/\/link\.brightcove\.com\/services\/player\//i, + re: [ + /^https?:\/\/link\.brightcove\.com\/services\/player\//i, + /^https?:\/\/[a-z\-]+\.\w+\.(com|org|net|co|)\/services\/player\/bcpid\d+\/?\?bc/i + ], mixins: [ "twitter-title", @@ -8,7 +11,7 @@ module.exports = { "twitter-image" ], - getLink: function(twitter) { + getLink: function(twitter) { // Make Brightcove consistently autoplay. It depends on customer settings and we can not make them all NOT to autoplay - so the only way out is to autoplay them all. @@ -30,4 +33,20 @@ module.exports = { "https://link.brightcove.com/services/player/bcpid1638546175001?bckey=AQ~~,AAAAmtVJIFk~,TVGOQ5ZTwJZhmi7steBjnvKikk1S5nut&bctid=2587584769001&secureConnections=true&secureHTMLConnections=true&linkSrc=twitter&autoStart=false&height=100%25&width=100%25", "https://link.brightcove.com/services/player/bcpid616303324001?bckey=AQ~~,AAAAj36EGjE~,w53r2XdUtII0XxxdqYeLp1bOxUXrsIg0&bctid=620166577001&secureConnections=true&secureHTMLConnections=true&linkSrc=twitter&autoStart=false&height=100%25&width=100%25" ] + + /* Sample direct-video URLs: + http://video-embed.masslive.com/services/player/bcpid1949030308001?bctid=3082707357001&bckey=AQ~~,AAAAQBxUOok~,jSZP67EiqBfkIeiCdBewgHg1-uVWQxpS + http://video-embed.cleveland.com/services/player/bcpid1949055968001?bctid=3086114271001&bckey=AQ~~,AAAAQBxUNqE~,xKBGzTdiYSSRqIKPsPdkNW3W_DNtPBTa + http://video.archstl.org/services/player/bcpid1697747652001?bckey=AQ~~,AAABKmWKzxE~,jhq2mLafyYPtb2fDysY2ou3LA4sZBXej&bctid=2766873636001&iframe=true&height=275&width=485 + http://video.popularmechanics.com/services/player/bcpid16382224001?bckey=AQ~~,AAAAAAyqBbs~,3zLG8i7OTQIWSRZG2AhyY0vOQ2Zz32h-&bctid=3087691540001 + http://video.billboard.com/services/player/bcpid3063835940001?bckey=AQ~~,AAAAAEMcC3Y~,NII8yi9nN4ynMSuZMypu6TcjvNjfaYWZ&bclid=3064795148001&bctid=3082031207001 + http://video-embed.nj.com/services/player/bcpid1950981419001?bctid=3092316229001&bckey=AQ~~,AAAAPLMILBk~,Vn8u6tPOf8Us2eD8W1ez5Zw-Ss_6Anfe + http://video.bafta.org/services/player/bcpid601325186001?bckey=AQ~~,AAAABxWZS7k~,uLPjGIDNpTmMdurNjyFkV6rYlN-J6re3&bctid=753252127001 + + http://video-embed.masslive.com/services/player/bcpid1949030308001?bctid=3082707357001&bckey=AQ~~,AAAAQBxUOok~,jSZP67EiqBfkIeiCdBewgHg1-uVWQxpS + http://video.symantec.com/services/player/bcpid975006955001?bckey=AQ%7E%7E%2CAAAABuIiy9k%7E%2CI8BhasVwr9wjJz4AWmdUlYymEtyorXkA&bctid=976391207001 + http://video.elcolombiano.com/services/player/bcpid2115059022001?bckey=AQ~~,AAABMdBKz4k~,kXKBkGGWjAV3BlMLVMYIIJUmR9KeWfwc&bctid=3082494089001 + http://video.scholastic.com/services/player/bcpid2602614477001?bckey=AQ~~,AAAAAFv844g~,BASb5BU03X9zO_bolhfjuH41AJVXYFl_&bctid=3027833348001 + http://trvideo.technologyreview.com/services/player/bcpid1237507476001?bckey=AQ~~,AAAAAAEgZvo~,jStb8wH-jnIlhYFjMUYJttcZynWzN1UG&bctid=1238876339001 + */ }; \ No newline at end of file diff --git a/plugins/links/brightcove-hosted.js b/plugins/links/brightcove-hosted.js index ceac973fe..6a606de17 100644 --- a/plugins/links/brightcove-hosted.js +++ b/plugins/links/brightcove-hosted.js @@ -48,21 +48,6 @@ module.exports = { } } - /* Sample direct-video URLs: - http://video-embed.masslive.com/services/player/bcpid1949030308001?bctid=3082707357001&bckey=AQ~~,AAAAQBxUOok~,jSZP67EiqBfkIeiCdBewgHg1-uVWQxpS - http://video-embed.cleveland.com/services/player/bcpid1949055968001?bctid=3086114271001&bckey=AQ~~,AAAAQBxUNqE~,xKBGzTdiYSSRqIKPsPdkNW3W_DNtPBTa - http://video.archstl.org/services/player/bcpid1697747652001?bckey=AQ~~,AAABKmWKzxE~,jhq2mLafyYPtb2fDysY2ou3LA4sZBXej&bctid=2766873636001&iframe=true&height=275&width=485 - http://video.popularmechanics.com/services/player/bcpid16382224001?bckey=AQ~~,AAAAAAyqBbs~,3zLG8i7OTQIWSRZG2AhyY0vOQ2Zz32h-&bctid=3087691540001 - http://video.billboard.com/services/player/bcpid3063835940001?bckey=AQ~~,AAAAAEMcC3Y~,NII8yi9nN4ynMSuZMypu6TcjvNjfaYWZ&bclid=3064795148001&bctid=3082031207001 - http://video-embed.nj.com/services/player/bcpid1950981419001?bctid=3092316229001&bckey=AQ~~,AAAAPLMILBk~,Vn8u6tPOf8Us2eD8W1ez5Zw-Ss_6Anfe - http://video.bafta.org/services/player/bcpid601325186001?bckey=AQ~~,AAAABxWZS7k~,uLPjGIDNpTmMdurNjyFkV6rYlN-J6re3&bctid=753252127001 - - http://video-embed.masslive.com/services/player/bcpid1949030308001?bctid=3082707357001&bckey=AQ~~,AAAAQBxUOok~,jSZP67EiqBfkIeiCdBewgHg1-uVWQxpS - http://video.symantec.com/services/player/bcpid975006955001?bckey=AQ%7E%7E%2CAAAABuIiy9k%7E%2CI8BhasVwr9wjJz4AWmdUlYymEtyorXkA&bctid=976391207001 - http://video.elcolombiano.com/services/player/bcpid2115059022001?bckey=AQ~~,AAABMdBKz4k~,kXKBkGGWjAV3BlMLVMYIIJUmR9KeWfwc&bctid=3082494089001 - http://video.scholastic.com/services/player/bcpid2602614477001?bckey=AQ~~,AAAAAFv844g~,BASb5BU03X9zO_bolhfjuH41AJVXYFl_&bctid=3027833348001 - http://trvideo.technologyreview.com/services/player/bcpid1237507476001?bckey=AQ~~,AAAAAAEgZvo~,jStb8wH-jnIlhYFjMUYJttcZynWzN1UG&bctid=1238876339001 - */ /* Sample URLs with BrightCove Twitter Players: http://www.channel4.com/programmes/the-mill/videos/all/s1-ep2-the-introduction - unless denied From 13e4773ce1cd3263eaba682278d37907510112d4 Mon Sep 17 00:00:00 2001 From: Nazar Leush Date: Fri, 11 Dec 2015 22:30:10 +0200 Subject: [PATCH 007/320] [core] remove forcePromo option --- lib/core.js | 4 ---- lib/loader/utils.js | 1 - lib/plugins/system/oembed/oembed.js | 10 ++-------- lib/plugins/system/promo/promoEmbed.js | 2 +- lib/plugins/system/promo/promoLink.js | 2 +- modules/api/views.js | 3 +-- 6 files changed, 5 insertions(+), 17 deletions(-) diff --git a/lib/core.js b/lib/core.js index 2f9de2faa..d4b75e244 100644 --- a/lib/core.js +++ b/lib/core.js @@ -1350,10 +1350,6 @@ context.__promoUri = options.promoUri; } - if (options.forcePromo) { - context.__forcePromo = true; - } - if (options.getWhitelistRecord) { var whitelistRecord = options.getWhitelistRecord(uri); if (whitelistRecord) { diff --git a/lib/loader/utils.js b/lib/loader/utils.js index 7cf54aba7..452eb33b3 100644 --- a/lib/loader/utils.js +++ b/lib/loader/utils.js @@ -8,7 +8,6 @@ "options", "request", "whitelistRecord", - "__forcePromo", "__readabilityEnabled" ]; diff --git a/lib/plugins/system/oembed/oembed.js b/lib/plugins/system/oembed/oembed.js index 54f2e3e6d..e660de78d 100644 --- a/lib/plugins/system/oembed/oembed.js +++ b/lib/plugins/system/oembed/oembed.js @@ -3,7 +3,7 @@ var urlLib = require('url'); module.exports = { - provides: ['self', '__promoUri', '__forcePromo'], + provides: ['self', '__promoUri'], getData: function(url, oembedLinks, options, cb) { @@ -31,13 +31,7 @@ module.exports = { var promo = urlObj.query.promo; - if (promo === '1' || promo === 'true') { - - return cb(null, { - __forcePromo: true - }); - - } else if (promo.match(/https?:\/\/.+/i)) { + if (promo.match(/https?:\/\/.+/i)) { return cb(null, { __promoUri: promo diff --git a/lib/plugins/system/promo/promoEmbed.js b/lib/plugins/system/promo/promoEmbed.js index 1c0a7e4b5..ede430868 100644 --- a/lib/plugins/system/promo/promoEmbed.js +++ b/lib/plugins/system/promo/promoEmbed.js @@ -25,7 +25,7 @@ module.exports = { generic: true, - getData: function(__forcePromo, cheerio) { + getData: function(cheerio) { var embeds = cheerio('a[data-iframely-url]'); if (embeds.length) { diff --git a/lib/plugins/system/promo/promoLink.js b/lib/plugins/system/promo/promoLink.js index 2ffea79a2..b516e6c12 100644 --- a/lib/plugins/system/promo/promoLink.js +++ b/lib/plugins/system/promo/promoLink.js @@ -5,7 +5,7 @@ module.exports = { generic: true, getData: function(meta, whitelistRecord, options) { - if (options.forcePromo || meta.promo && whitelistRecord.isAllowed && whitelistRecord.isAllowed('html-meta.promo')) { + if (meta.promo && whitelistRecord.isAllowed && whitelistRecord.isAllowed('html-meta.promo')) { return { __promoUri: meta.promo }; diff --git a/modules/api/views.js b/modules/api/views.js index 3e776c02a..1f9eaae87 100644 --- a/modules/api/views.js +++ b/modules/api/views.js @@ -70,8 +70,7 @@ module.exports = function(app) { readability: getBooleanParam(req, 'readability'), getWhitelistRecord: whitelist.findWhitelistRecordFor, maxWidth: getIntParam(req, 'maxwidth') || getIntParam(req, 'max-width'), - promoUri: req.query.promoUri, - forcePromo: getBooleanParam(req, 'forcePromo') + promoUri: req.query.promoUri }, cb); } From 151951c76965d1e6db087bf7b5bb958c4c210fb5 Mon Sep 17 00:00:00 2001 From: Nazar Leush Date: Fri, 11 Dec 2015 22:32:03 +0200 Subject: [PATCH 008/320] [promo] remove promoEmbed.js plugin --- lib/plugins/system/promo/promoEmbed.js | 74 -------------------------- 1 file changed, 74 deletions(-) delete mode 100644 lib/plugins/system/promo/promoEmbed.js diff --git a/lib/plugins/system/promo/promoEmbed.js b/lib/plugins/system/promo/promoEmbed.js deleted file mode 100644 index ede430868..000000000 --- a/lib/plugins/system/promo/promoEmbed.js +++ /dev/null @@ -1,74 +0,0 @@ -var urlLib = require('url'); - -var iframelyApiRe = /iframe\.ly\/api\/iframe.+url=/i; - -var res = [ - /iframe\.ly\/\w+/i, - iframelyApiRe, - /\/\/www\.youtube\.com\/embed\/\w+/i, - /\/\/player\.vimeo\.com\/video\/\d+/i, - /\/\/vine\.co\/v\/\w+\/embed/i -]; - -function extractGetParamUrl(src) { - if (src.match(iframelyApiRe)) { - var urlObj = urlLib.parse(src, true); - return urlObj.query['url']; - } else { - return src; - } -} - -module.exports = { - - provides: '__promoUri', - - generic: true, - - getData: function(cheerio) { - - var embeds = cheerio('a[data-iframely-url]'); - if (embeds.length) { - var href = embeds.attr('href'); - return { - __promoUri: extractGetParamUrl(href) - }; - } - - embeds = cheerio('[data-embed-canonical]'); - if (embeds.length) { - var href = embeds.attr('data-embed-canonical'); - return { - __promoUri: href - }; - } - - embeds = cheerio('iframe'); - var result; - embeds.each(function() { - if (result) { - return; - } - var src = cheerio(this).attr('src'); - - if (!src) { - return; - } - - var i = 0; - while(i < res.length && !src.match(res[i])) { - i++; - } - - if (i < res.length) { - result = src; - } - }); - - if (result) { - return { - __promoUri: extractGetParamUrl(result) - }; - } - } -}; \ No newline at end of file From 04eed37441826db6ecb21cd54aa384c31e9c0047 Mon Sep 17 00:00:00 2001 From: Ivan Paramonau Date: Fri, 11 Dec 2015 15:35:58 -0500 Subject: [PATCH 009/320] clean up promo meta plugin --- config.local.js.SAMPLE | 3 ++- lib/plugins/system/promo/promoLink.js | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/config.local.js.SAMPLE b/config.local.js.SAMPLE index 29322e65b..f4fc32a54 100644 --- a/config.local.js.SAMPLE +++ b/config.local.js.SAMPLE @@ -191,7 +191,8 @@ "image": "allow" }, "html-meta": { - "video": ["allow", "responsive"] + "video": ["allow", "responsive"], + "promo": "allow" } } */ diff --git a/lib/plugins/system/promo/promoLink.js b/lib/plugins/system/promo/promoLink.js index b516e6c12..bc075a27b 100644 --- a/lib/plugins/system/promo/promoLink.js +++ b/lib/plugins/system/promo/promoLink.js @@ -4,7 +4,7 @@ module.exports = { generic: true, - getData: function(meta, whitelistRecord, options) { + getData: function(meta, whitelistRecord) { if (meta.promo && whitelistRecord.isAllowed && whitelistRecord.isAllowed('html-meta.promo')) { return { __promoUri: meta.promo From 513b8fa97e6540849bc170723b53dd644920b055 Mon Sep 17 00:00:00 2001 From: Ivan Paramonau Date: Fri, 11 Dec 2015 15:46:04 -0500 Subject: [PATCH 010/320] move promo oembedLink to separate plugin --- lib/plugins/system/oembed/oembed.js | 17 +-------- lib/plugins/system/promo/promoOembedLink.js | 38 +++++++++++++++++++++ 2 files changed, 39 insertions(+), 16 deletions(-) create mode 100644 lib/plugins/system/promo/promoOembedLink.js diff --git a/lib/plugins/system/oembed/oembed.js b/lib/plugins/system/oembed/oembed.js index e660de78d..a28432339 100644 --- a/lib/plugins/system/oembed/oembed.js +++ b/lib/plugins/system/oembed/oembed.js @@ -1,9 +1,8 @@ var oembedUtils = require('./oembedUtils'); -var urlLib = require('url'); module.exports = { - provides: ['self', '__promoUri'], + provides: 'self', getData: function(url, oembedLinks, options, cb) { @@ -25,20 +24,6 @@ module.exports = { } } - if (self_endpoint) { - - var urlObj = urlLib.parse(href, true); - - var promo = urlObj.query.promo; - - if (promo.match(/https?:\/\/.+/i)) { - - return cb(null, { - __promoUri: promo - }); - } - } - if (skip || self_endpoint) { return cb(null); } diff --git a/lib/plugins/system/promo/promoOembedLink.js b/lib/plugins/system/promo/promoOembedLink.js new file mode 100644 index 000000000..cd836d577 --- /dev/null +++ b/lib/plugins/system/promo/promoOembedLink.js @@ -0,0 +1,38 @@ +var urlLib = require('url'); + +module.exports = { + + provides: '__promoUri', + + generic: true, + + getData: function(oembedLinks, whitelistRecord) { + + if (meta.promo && whitelistRecord.isAllowed && whitelistRecord.isAllowed('html-meta.promo')) { + + var href = oembedLinks[0].href; + var self_endpoint = false; + + if (CONFIG.SELF_OEMBED_POINT_RE_LIST) { + var i; + for(i = 0; i < CONFIG.SELF_OEMBED_POINT_RE_LIST.length && !self_endpoint; i++) { + self_endpoint = href.match(CONFIG.SELF_OEMBED_POINT_RE_LIST[i]); + } + } + + if (self_endpoint) { + + var urlObj = urlLib.parse(href, true); + var promo = urlObj.query.promo; + + if (promo.match(/https?:\/\/.+/i)) { + + return { + __promoUri: promo + }; + } + } + + } + } +}; \ No newline at end of file From 21c8823cc4ad5d975e43fc440a20505c94462f4c Mon Sep 17 00:00:00 2001 From: Ivan Paramonau Date: Sat, 12 Dec 2015 15:56:46 -0500 Subject: [PATCH 011/320] move all promo-related plugins to one generic parsers folder --- plugins/links/{ => promo}/brightcove-hosted.js | 0 plugins/links/{ => promo}/og-youtube.js | 0 .../promo/promoLink.js => plugins/links/promo/promo-link.js | 2 -- .../promoOembedLink.js => plugins/links/promo/promo-oembed.js | 4 +--- {lib/plugins/system => plugins/links}/promo/promo.js | 2 +- plugins/links/{ => promo}/twitter-youtube.js | 0 6 files changed, 2 insertions(+), 6 deletions(-) rename plugins/links/{ => promo}/brightcove-hosted.js (100%) rename plugins/links/{ => promo}/og-youtube.js (100%) rename lib/plugins/system/promo/promoLink.js => plugins/links/promo/promo-link.js (93%) rename lib/plugins/system/promo/promoOembedLink.js => plugins/links/promo/promo-oembed.js (86%) rename {lib/plugins/system => plugins/links}/promo/promo.js (97%) rename plugins/links/{ => promo}/twitter-youtube.js (100%) diff --git a/plugins/links/brightcove-hosted.js b/plugins/links/promo/brightcove-hosted.js similarity index 100% rename from plugins/links/brightcove-hosted.js rename to plugins/links/promo/brightcove-hosted.js diff --git a/plugins/links/og-youtube.js b/plugins/links/promo/og-youtube.js similarity index 100% rename from plugins/links/og-youtube.js rename to plugins/links/promo/og-youtube.js diff --git a/lib/plugins/system/promo/promoLink.js b/plugins/links/promo/promo-link.js similarity index 93% rename from lib/plugins/system/promo/promoLink.js rename to plugins/links/promo/promo-link.js index bc075a27b..e32041623 100644 --- a/lib/plugins/system/promo/promoLink.js +++ b/plugins/links/promo/promo-link.js @@ -2,8 +2,6 @@ module.exports = { provides: '__promoUri', - generic: true, - getData: function(meta, whitelistRecord) { if (meta.promo && whitelistRecord.isAllowed && whitelistRecord.isAllowed('html-meta.promo')) { return { diff --git a/lib/plugins/system/promo/promoOembedLink.js b/plugins/links/promo/promo-oembed.js similarity index 86% rename from lib/plugins/system/promo/promoOembedLink.js rename to plugins/links/promo/promo-oembed.js index cd836d577..9dce32f38 100644 --- a/lib/plugins/system/promo/promoOembedLink.js +++ b/plugins/links/promo/promo-oembed.js @@ -4,11 +4,9 @@ module.exports = { provides: '__promoUri', - generic: true, - getData: function(oembedLinks, whitelistRecord) { - if (meta.promo && whitelistRecord.isAllowed && whitelistRecord.isAllowed('html-meta.promo')) { + if (whitelistRecord.isAllowed && whitelistRecord.isAllowed('html-meta.promo')) { var href = oembedLinks[0].href; var self_endpoint = false; diff --git a/lib/plugins/system/promo/promo.js b/plugins/links/promo/promo.js similarity index 97% rename from lib/plugins/system/promo/promo.js rename to plugins/links/promo/promo.js index 1af1ed1f0..1cb53bcf7 100644 --- a/lib/plugins/system/promo/promo.js +++ b/plugins/links/promo/promo.js @@ -1,4 +1,4 @@ -var core = require('../../../core'); +var core = require('../../../lib/core'); var _ = require('underscore'); module.exports = { diff --git a/plugins/links/twitter-youtube.js b/plugins/links/promo/twitter-youtube.js similarity index 100% rename from plugins/links/twitter-youtube.js rename to plugins/links/promo/twitter-youtube.js From cc71dd3ca7807b1177f673472a5fe0305b6f68eb Mon Sep 17 00:00:00 2001 From: Ivan Paramonau Date: Mon, 14 Dec 2015 16:55:42 -0500 Subject: [PATCH 012/320] [general] make sure favicon's content_length > 0 --- lib/plugins/validators/async/20_checkFavicon.js | 5 +++++ lib/utils.js | 3 ++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/plugins/validators/async/20_checkFavicon.js b/lib/plugins/validators/async/20_checkFavicon.js index 2f33fb0ef..0bcd03eba 100644 --- a/lib/plugins/validators/async/20_checkFavicon.js +++ b/lib/plugins/validators/async/20_checkFavicon.js @@ -46,6 +46,11 @@ module.exports = { link.error = "Non-image MIME type: '" + data.content_type + "'"; } } + + if (data.code == 200 && data.content_length && data.content_length == 0) { + link.error = "Image with 0 content_length"; + } + } // Store timing. diff --git a/lib/utils.js b/lib/utils.js index ab9e3d86b..264242497 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -668,7 +668,8 @@ var getUriStatus = function(uri, options, cb) { r.abort(); cb(null, { code: res.statusCode, - content_type: res.headers['content-type'] + content_type: res.headers['content-type'], + content_length: res.headers['content-length'] || '0' }); }); }; From 26718bbf7ac8be5ff1cfdc914ecd3d9dc96a2403 Mon Sep 17 00:00:00 2001 From: Nazar Leush Date: Thu, 17 Dec 2015 15:47:50 +0200 Subject: [PATCH 013/320] [domains] twitter: custom API request cache TTL --- config.local.js.SAMPLE | 3 ++- lib/request.js | 4 +++- plugins/domains/twitter.status.js | 1 + 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/config.local.js.SAMPLE b/config.local.js.SAMPLE index e7b68e556..8be56ded2 100644 --- a/config.local.js.SAMPLE +++ b/config.local.js.SAMPLE @@ -108,7 +108,8 @@ access_token_secret: 'INSERT YOUR VALUE', hide_media: false, hide_thread: false, - omit_script: false + omit_script: false, + cache_ttl: 100 * 365 * 24 * 3600 // 100 Years. }, flickr: { apiKey: 'INSERT YOUR VALUE' diff --git a/lib/request.js b/lib/request.js index 81656260a..f6a6f8a35 100644 --- a/lib/request.js +++ b/lib/request.js @@ -34,9 +34,11 @@ module.exports = function(options, callback) { var prepareResult = options.prepareResult; var useCacheOnly = options.useCacheOnly; + var ttl = options.ttl; delete options.prepareData; delete options.useCacheOnly; + delete options.ttl; var prefix = CONFIG.API_REQUEST_CACHE_PREFIX ? (CONFIG.API_REQUEST_CACHE_PREFIX + ':') : ''; @@ -68,7 +70,7 @@ module.exports = function(options, callback) { }, data: data }, { - ttl: CONFIG.API_REQUEST_CACHE_TTL + ttl: ttl || CONFIG.API_REQUEST_CACHE_TTL }); } diff --git a/plugins/domains/twitter.status.js b/plugins/domains/twitter.status.js index 300307630..87781039a 100644 --- a/plugins/domains/twitter.status.js +++ b/plugins/domains/twitter.status.js @@ -65,6 +65,7 @@ module.exports = { oauth: oauth, json: true, useCacheOnly: blockExpireIn > 0, + ttl: c.cache_ttl, prepareResult: function(error, response, data, cb) { if (response.fromRequestCache) { From 9511ee17c447f3962c6f4677fee193fc07712dae Mon Sep 17 00:00:00 2001 From: Nazar Leush Date: Thu, 17 Dec 2015 18:10:38 +0200 Subject: [PATCH 014/320] [oembed] do not leave undefined content_length in oembed response --- lib/oembed.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/oembed.js b/lib/oembed.js index 8f2d674a5..8a93cc848 100644 --- a/lib/oembed.js +++ b/lib/oembed.js @@ -85,7 +85,7 @@ exports.getOembed = function(uri, data, options) { oembed.height = m.height; } } - if (link) { + if (link && link.content_length) { oembed.content_length = link.content_length; } From cb772b98044ebc0b2abb6b9f1a87b41494e9ecf4 Mon Sep 17 00:00:00 2001 From: Nazar Leush Date: Thu, 17 Dec 2015 19:23:02 +0200 Subject: [PATCH 015/320] [meta] canonical: resolve relative path to absolute --- plugins/meta/canonical.js | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/plugins/meta/canonical.js b/plugins/meta/canonical.js index 2a96b80b9..3b15ae4bf 100644 --- a/plugins/meta/canonical.js +++ b/plugins/meta/canonical.js @@ -1,8 +1,18 @@ +var urlLib = require('url'); + module.exports = { - getMeta: function(meta) { - return { - canonical: (meta.canonical && meta.canonical.href || meta.canonical) || (meta.og && meta.og.url) || (meta.twitter && meta.twitter.url) - }; + getMeta: function(url, meta) { + + var canonical = (meta.canonical && meta.canonical.href || meta.canonical) || (meta.og && meta.og.url) || (meta.twitter && meta.twitter.url); + + if (canonical) { + + canonical = urlLib.resolve(url, canonical); + + return { + canonical: canonical + }; + } } }; \ No newline at end of file From a07fcd7a601f860d0ea1e71408d319bb2de0819f Mon Sep 17 00:00:00 2001 From: Nazar Leush Date: Thu, 17 Dec 2015 19:53:49 +0200 Subject: [PATCH 016/320] [config] add html-meta.embedURL option --- config.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/config.js b/config.js index d3b701dbe..70ae46e61 100644 --- a/config.js +++ b/config.js @@ -139,7 +139,8 @@ "photo" ], "html-meta": [ // TODO: Need change to 'fb'. - "video" + "video", + "embedURL" ] }, From 1e5c900f9cdac2dc9189f08e1fd3896e2309b274 Mon Sep 17 00:00:00 2001 From: Nazar Leush Date: Thu, 17 Dec 2015 23:15:02 +0200 Subject: [PATCH 017/320] [whitelist] fix apply whitelist rels for embedURL video --- lib/whitelist.js | 9 +-------- plugins/links/embedURL/embedURL.js | 4 ++-- plugins/links/video_src.js | 10 +++++++--- 3 files changed, 10 insertions(+), 13 deletions(-) diff --git a/lib/whitelist.js b/lib/whitelist.js index 0821cda8a..050eb325c 100644 --- a/lib/whitelist.js +++ b/lib/whitelist.js @@ -41,14 +41,7 @@ if (sources.length == 0 && rels.indexOf("player") > -1) { - // Meta is not available in new version. - // Maybe need to create new tag. - //if (meta && meta.video_src) { - result.push({ - source: "html-meta", - type: "video" - }); - //} + // Skip single player rel. } else { sources.forEach(function(source) { diff --git a/plugins/links/embedURL/embedURL.js b/plugins/links/embedURL/embedURL.js index f9d026561..f0ea060dc 100644 --- a/plugins/links/embedURL/embedURL.js +++ b/plugins/links/embedURL/embedURL.js @@ -64,10 +64,10 @@ module.exports = { type: type }; - if (whitelistRecord.isAllowed('html-meta.embedURL', 'html5')) { + if (whitelistRecord.isAllowed('html-meta.embedURL', CONFIG.R.html5)) { player.rel.push(CONFIG.R.html5); } - if (whitelistRecord.isAllowed('html-meta.embedURL', 'autoplay')) { + if (whitelistRecord.isAllowed('html-meta.embedURL', CONFIG.R.autoplay)) { player.rel.push(CONFIG.R.autoplay); } diff --git a/plugins/links/video_src.js b/plugins/links/video_src.js index 64113f6b6..82356e108 100644 --- a/plugins/links/video_src.js +++ b/plugins/links/video_src.js @@ -17,9 +17,13 @@ module.exports = { player.height = meta.video_height; } - if (whitelistRecord.isAllowed('html-meta.video', 'html5')) { - player.rel.push('html5'); - } + if (whitelistRecord.isAllowed('html-meta.video', CONFIG.R.html5)) { + player.rel.push(CONFIG.R.html5); + } + + if (whitelistRecord.isAllowed('html-meta.video', CONFIG.R.autoplay)) { + player.rel.push(CONFIG.R.autoplay); + } return player; } From d1763d1973fd3f34e8d89291b376bc65dca0de8a Mon Sep 17 00:00:00 2001 From: Ivan Paramonau Date: Fri, 18 Dec 2015 13:57:25 -0500 Subject: [PATCH 018/320] change default aspect ratio to 16:9 --- config.js | 2 +- plugins/domains/kickstarter.com.js | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/config.js b/config.js index d3b701dbe..39117e49d 100644 --- a/config.js +++ b/config.js @@ -33,7 +33,7 @@ VERSION: version, SKIP_IFRAMELY_RENDERS: false, - DEFAULT_ASPECT_RATIO: 4 / 3, + DEFAULT_ASPECT_RATIO: 16 / 9, T: { text_html: "text/html", diff --git a/plugins/domains/kickstarter.com.js b/plugins/domains/kickstarter.com.js index a0d5f75ef..06dfee378 100644 --- a/plugins/domains/kickstarter.com.js +++ b/plugins/domains/kickstarter.com.js @@ -48,8 +48,6 @@ module.exports = { if ((meta.twitter && meta.twitter.card == 'player') || (meta.og && meta.og.type == 'video') || meta.video_src || (href && /video\.html$/.test(href))) { - console.log("was here"); - links.push ({ href: href, type: CONFIG.T.text_html, From 3a40060c83199c71c25f095187a5eb72532dd1a7 Mon Sep 17 00:00:00 2001 From: Ivan Paramonau Date: Fri, 18 Dec 2015 14:30:46 -0500 Subject: [PATCH 019/320] [domains] better support for Getty's international domains --- plugins/domains/gettyimages.com.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/plugins/domains/gettyimages.com.js b/plugins/domains/gettyimages.com.js index 62eca8df9..ba6724225 100644 --- a/plugins/domains/gettyimages.com.js +++ b/plugins/domains/gettyimages.com.js @@ -3,7 +3,7 @@ var $ = require('cheerio'); module.exports = { // Photos only for now. TODO: Stay tuned for when video embeds become available - re: /^https?:\/\/www\.gettyimages\.(com|ca|com\.au|be|dk|de|es|fr|in|ie|it|nl|co\.nz|no|at|pt|ch|fi|se|ae|co\.uk|co\.jp)\/detail\/([a-zA-Z0-9\-]+)\/[a-zA-Z0-9\-]+\/(\d+)/i, + re: /^https?:\/\/www\.gettyimages\.(com|ca|com\.au|be|dk|de|es|fr|in|ie|it|nl|co\.nz|no|at|pt|ch|fi|se|ae|co\.uk|co\.jp)\/detail\/([^\/]+)\/[^\/]+\/(\d+)/i, provides: 'getty', @@ -68,6 +68,7 @@ module.exports = { tests: [ "http://www.gettyimages.ca/detail/photo/reflection-of-trees-high-res-stock-photography/103260792", "http://www.gettyimages.com/detail/illustration/pizza-icons-white-series-royalty-free-illustration/185819032", - "http://www.gettyimages.de/detail/nachrichtenfoto/sylvie-meis-and-daniel-hartwich-attend-the-8th-show-of-nachrichtenfoto/493388593" + "http://www.gettyimages.de/detail/nachrichtenfoto/sylvie-meis-and-daniel-hartwich-attend-the-8th-show-of-nachrichtenfoto/493388593", + "http://www.gettyimages.fr/detail/photo-d'actualit%C3%A9/filipe-toledo-of-brasil-is-the-2015-quiksilver-pro-photo-dactualit%C3%A9/466056674?license" ] }; \ No newline at end of file From f30713f62e331c9b7579e6cfd0a2bc0480ab1292 Mon Sep 17 00:00:00 2001 From: Ivan Paramonau Date: Fri, 18 Dec 2015 15:08:40 -0500 Subject: [PATCH 020/320] [domains] add buzzfeed videos via youtube promo --- .../domains/buzzfeed.com/buzzfeed.isvideo.js | 20 +++++++++++++ .../domains/buzzfeed.com/buzzfeed.video.js | 30 +++++++++++++++++++ 2 files changed, 50 insertions(+) create mode 100644 plugins/domains/buzzfeed.com/buzzfeed.isvideo.js create mode 100644 plugins/domains/buzzfeed.com/buzzfeed.video.js diff --git a/plugins/domains/buzzfeed.com/buzzfeed.isvideo.js b/plugins/domains/buzzfeed.com/buzzfeed.isvideo.js new file mode 100644 index 000000000..8dbce1a4e --- /dev/null +++ b/plugins/domains/buzzfeed.com/buzzfeed.isvideo.js @@ -0,0 +1,20 @@ +module.exports = { + + re: [ + /^https?:\/\/www\.buzzfeed\.com\//i + ], + + provides: "__isBuzzFeedVideo", + + getData: function(twitter, cb) { + + if (twitter.card === 'player') { + cb(null, { + __isBuzzFeedVideo: true + }); + } else { + cb(); + } + + } +}; diff --git a/plugins/domains/buzzfeed.com/buzzfeed.video.js b/plugins/domains/buzzfeed.com/buzzfeed.video.js new file mode 100644 index 000000000..ad5a29708 --- /dev/null +++ b/plugins/domains/buzzfeed.com/buzzfeed.video.js @@ -0,0 +1,30 @@ +module.exports = { + + provides: '__promoUri', + + re: [ + /^https?:\/\/www\.buzzfeed\.com\//i + ], + + mixins: [ + "*" + ], + + getData: function(cheerio, __isBuzzFeedVideo, cb) { + + var $el = cheerio('.video-embed-videopost'); + var embed = JSON.parse($el.attr('rel:bf_bucket_data')); + + if (embed.video && embed.video.url) { + cb (null, { + __promoUri: embed.video.url.replace(/^http:\/\/youtube/, 'https://www.youtube') + }); + } else { + cb(); + } + }, + + tests: [ + "http://www.buzzfeed.com/brentbennett/star-wars-cast-members-do-star-wars-impersonations#.idE4zm45aA" + ] +}; From 783dd26cecd63b64c205688c68d6e6c2523af591 Mon Sep 17 00:00:00 2001 From: Ivan Paramonau Date: Mon, 21 Dec 2015 13:57:46 -0500 Subject: [PATCH 021/320] [domains] return Someecards parser --- plugins/.noneed/someecards.com.js | 35 ------------------------------- plugins/domains/someecards.com.js | 21 +++++++++++++++++++ 2 files changed, 21 insertions(+), 35 deletions(-) delete mode 100644 plugins/.noneed/someecards.com.js create mode 100644 plugins/domains/someecards.com.js diff --git a/plugins/.noneed/someecards.com.js b/plugins/.noneed/someecards.com.js deleted file mode 100644 index a0b1acb96..000000000 --- a/plugins/.noneed/someecards.com.js +++ /dev/null @@ -1,35 +0,0 @@ -module.exports = { - - notPlugin: true, - - mixins: [ - "og-title", - "og-site", - "canonical", - "favicon" - ], - - getLink: function (meta) { - if (meta.twitter && meta.twitter.card == "photo" && meta.twitter.image) { - return { - href: meta.twitter.image.url || meta.twitter.image, - type: CONFIG.T.image, - rel: [CONFIG.R.image], - width: meta.twitter.image.width, - height: meta.twitter.image.height - }; - } - - if (meta.image_src) { - return { - href: meta.image_src, - type: CONFIG.t.image, - rel: [CONGIG.R.image] - } - } - }, - - tests: [ - "http://www.someecards.com/usercards/viewcard/eea3c10dfaeb6ef8c6eb386707343c36" - ] -}; diff --git a/plugins/domains/someecards.com.js b/plugins/domains/someecards.com.js new file mode 100644 index 000000000..3d9ae857e --- /dev/null +++ b/plugins/domains/someecards.com.js @@ -0,0 +1,21 @@ +module.exports = { + + mixins: [ + "*" + ], + + getLink: function (og) { + if (og.type === "someecards:card" && og.image) { + return { + href: og.image.url || og.image, + type: CONFIG.T.image, + rel: [CONFIG.R.image, CONFIG.R.og], + }; + } + }, + + tests: [ + "http://www.someecards.com/usercards/viewcard/eea3c10dfaeb6ef8c6eb386707343c36", + "http://www.someecards.com/christmas-cards/theres-nothing-like-holiday-cheer-to-offset-devastating-seasonal-affective-disorder" + ] +}; \ No newline at end of file From d13aee972c4ae0a0b5b48fe649b156acfe4904bd Mon Sep 17 00:00:00 2001 From: Nazar Leush Date: Wed, 23 Dec 2015 17:05:02 +0200 Subject: [PATCH 022/320] [validators] add 'player' rel to video file link --- lib/plugins/validators/sync/10_video_hml5.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/lib/plugins/validators/sync/10_video_hml5.js b/lib/plugins/validators/sync/10_video_hml5.js index 46f65faa3..e0614f506 100644 --- a/lib/plugins/validators/sync/10_video_hml5.js +++ b/lib/plugins/validators/sync/10_video_hml5.js @@ -2,8 +2,15 @@ module.exports = { prepareLink: function(link) { // Add 'html5' rel to 'video/*'. - if (link.type.indexOf('video/') === 0 && link.rel.indexOf('html5') === -1) { - link.rel.push('html5'); + if (link.type.indexOf('video/') === 0) { + + if (link.rel.indexOf('html5') === -1) { + link.rel.push('html5'); + } + + if (link.rel.indexOf('player') === -1) { + link.rel.push('player'); + } } } }; \ No newline at end of file From ec3b89d312dd0d42508b053c8e32b919a79ef416 Mon Sep 17 00:00:00 2001 From: Ivan Paramonau Date: Fri, 25 Dec 2015 12:21:38 -0500 Subject: [PATCH 023/320] [domains] support amcharts --- plugins/domains/live.amcharts.com.js | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 plugins/domains/live.amcharts.com.js diff --git a/plugins/domains/live.amcharts.com.js b/plugins/domains/live.amcharts.com.js new file mode 100644 index 000000000..dda761d42 --- /dev/null +++ b/plugins/domains/live.amcharts.com.js @@ -0,0 +1,20 @@ +module.exports = { + + re: /https?:\/\/live\.amcharts\.com\/([a-zA-Z0-9\-]+)/i, + + mixins: ["*"], + + getLink: function(urlMatch) { + + return { + type: CONFIG.T.text_html, + rel: [CONFIG.R.app, CONFIG.R.ssl, CONFIG.R.html5], + href: 'https://live.amcharts.com/' + urlMatch[1] + '/embed/', + "aspect-ratio": 16 / 9 + }; + }, + + tests: [ + "http://live.amcharts.com/UxZGR/" + ] +}; \ No newline at end of file From 2e569e4915681652e0fe036247d42bc1ca5ad3bf Mon Sep 17 00:00:00 2001 From: Ivan Paramonau Date: Fri, 25 Dec 2015 12:56:20 -0500 Subject: [PATCH 024/320] [core] better handle some Invalid images --- lib/plugins/validators/async/22_imageSize.js | 30 ++++++++++---------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/lib/plugins/validators/async/22_imageSize.js b/lib/plugins/validators/async/22_imageSize.js index 243ff7329..7078e8f9e 100644 --- a/lib/plugins/validators/async/22_imageSize.js +++ b/lib/plugins/validators/async/22_imageSize.js @@ -53,7 +53,7 @@ module.exports = { }; } - if (error === 404 || (error.indexOf && error.indexOf('invalid') > -1)) { + if (error === 404 || (typeof error === 'string' && /invalid/i.test(error))) { // Image not found. Exclude link from results. link.error = error; } @@ -68,24 +68,24 @@ module.exports = { if (data.content_length) { link.content_length = data.content_length; } - } - // Special case: add rel image for image file with specific size. - if (link.rel.indexOf(CONFIG.R.image) === -1 && link.rel.indexOf(CONFIG.R.file) > -1 && data.width >= 100 && data.height >= 100) { - link.rel.push(CONFIG.R.image); - } + // Special case: add rel image for image file with specific size. + if (link.rel.indexOf(CONFIG.R.image) === -1 && link.rel.indexOf(CONFIG.R.file) > -1 && data.width >= 100 && data.height >= 100) { + link.rel.push(CONFIG.R.image); + } - if (link.rel.indexOf(CONFIG.R.file) > -1 && data.width === 1 && data.height === 1) { - link.error = "Too small image file"; - } + if (link.rel.indexOf(CONFIG.R.file) > -1 && data.width === 1 && data.height === 1) { + link.error = "Too small image file"; + } - // Store timing. - if (options.debug && data && data._time) { - link._imageMeta = link._imageMeta || {}; - link._imageMeta.time = data && data._time; - } + // Store timing. + if (options.debug && data && data._time) { + link._imageMeta = link._imageMeta || {}; + link._imageMeta.time = data && data._time; + } - mediaPlugin.prepareLink(link, options); + mediaPlugin.prepareLink(link, options); + } cb(); }); From 65a5991625f64b0e37cd7419d291a38364c3983d Mon Sep 17 00:00:00 2001 From: Ivan Paramonau Date: Sun, 27 Dec 2015 11:57:09 -0500 Subject: [PATCH 025/320] [domains] start of Amazon parser - get missing thumbnails --- plugins/domains/amazon.com.js | 47 +++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 plugins/domains/amazon.com.js diff --git a/plugins/domains/amazon.com.js b/plugins/domains/amazon.com.js new file mode 100644 index 000000000..c6373c374 --- /dev/null +++ b/plugins/domains/amazon.com.js @@ -0,0 +1,47 @@ +var $ = require('cheerio'); + +module.exports = { + + re: /^https?:\/\/www\.amazon\.(com|ca|com\.au|be|dk|de|es|fr|in|ie|it|nl|co\.nz|no|at|pt|ch|fi|se|ae|pl|co\.uk|co\.jp)\/([a-zA-Z0-9\-]+\/)?dp\/[a-zA-Z0-9\-]+/i, + + provides: "__isAmazonImageNeeded", + + mixins: [ + "*" + ], + + getLink: function(__isAmazonImageNeeded, cheerio) { + + // Smart move: grab missing image from Pinterest share button + var $pin = cheerio('#tell-a-friend-byline a[href*="pinterest"], #tell-a-friend a[href*="pinterest"]'); + + if ($pin.length) { + + href = $pin.attr('href'); + + return { + href: decodeURIComponent(decodeURIComponent(href.match(/media%3D([^&]+)/i)[1])), + rel: CONFIG.R.thumbnail, + type: CONFIG.T.image + } + } + }, + + getData: function (meta) { + if ((meta.twitter && meta.twitter.image) || (meta.og && meta.og.image)) { + return; + } else { + return { + __isAmazonImageNeeded: true + } + } + }, + + tests: [ + "http://www.amazon.com/Vegucated/dp/B006LZSF8M/ref=sr_1_1?s=instant-video&ie=UTF8&qid=1372118186&sr=1-1&keywords=vegucated", + "http://www.amazon.com/The-Whole-Truth-Shaw-Book-ebook/dp/B0011UCPM4/ref=pd_zg_rss_ts_b_17_6?ie=UTF8&tag=recomshop-22", + "http://www.amazon.co.uk/Vegetable-Perfection-tasty-recipes-shoots/dp/1849757097/ref=asap_bc?ie=UTF8", + "http://www.amazon.com/Tapestry-Hanging-Mandala-Tapestries-Bedspread/dp/B00ODVE012/ref=sr_1_75?s=furniture&ie=UTF8&qid=1450055989&sr=1-75&keywords=tapestry", + "http://www.amazon.ca/The-Fight-Security-Failings-Political/dp/1250082986?tag=smarturl-ca-20" + ] +}; \ No newline at end of file From b4bddfeeb7c6484cfed01a85fb39abf872fbb682 Mon Sep 17 00:00:00 2001 From: Ivan Paramonau Date: Sun, 27 Dec 2015 12:11:30 -0500 Subject: [PATCH 026/320] [domains] more URLs for Amazon products --- plugins/domains/amazon.com.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/plugins/domains/amazon.com.js b/plugins/domains/amazon.com.js index c6373c374..37ccaf682 100644 --- a/plugins/domains/amazon.com.js +++ b/plugins/domains/amazon.com.js @@ -2,7 +2,10 @@ var $ = require('cheerio'); module.exports = { - re: /^https?:\/\/www\.amazon\.(com|ca|com\.au|be|dk|de|es|fr|in|ie|it|nl|co\.nz|no|at|pt|ch|fi|se|ae|pl|co\.uk|co\.jp)\/([a-zA-Z0-9\-]+\/)?dp\/[a-zA-Z0-9\-]+/i, + re: [ + /^https?:\/\/www\.amazon\.(com|ca|com\.au|be|dk|de|es|fr|in|ie|it|nl|co\.nz|no|at|pt|ch|fi|se|ae|pl|co\.uk|co\.jp)\/([a-zA-Z0-9\-]+\/)?dp\/[a-zA-Z0-9\-]+/i, + /^https?:\/\/www\.amazon\.(com|ca|com\.au|be|dk|de|es|fr|in|ie|it|nl|co\.nz|no|at|pt|ch|fi|se|ae|pl|co\.uk|co\.jp)\/gp\/product\/[a-zA-Z0-9\-]+/i + ], provides: "__isAmazonImageNeeded", @@ -42,6 +45,7 @@ module.exports = { "http://www.amazon.com/The-Whole-Truth-Shaw-Book-ebook/dp/B0011UCPM4/ref=pd_zg_rss_ts_b_17_6?ie=UTF8&tag=recomshop-22", "http://www.amazon.co.uk/Vegetable-Perfection-tasty-recipes-shoots/dp/1849757097/ref=asap_bc?ie=UTF8", "http://www.amazon.com/Tapestry-Hanging-Mandala-Tapestries-Bedspread/dp/B00ODVE012/ref=sr_1_75?s=furniture&ie=UTF8&qid=1450055989&sr=1-75&keywords=tapestry", - "http://www.amazon.ca/The-Fight-Security-Failings-Political/dp/1250082986?tag=smarturl-ca-20" + "http://www.amazon.ca/The-Fight-Security-Failings-Political/dp/1250082986?tag=smarturl-ca-20", + "http://www.amazon.com/gp/product/B0057OC5O8/" ] }; \ No newline at end of file From 1ce47a60eb07fb0d6ba3ab899bc62660215ae5aa Mon Sep 17 00:00:00 2001 From: Ivan Paramonau Date: Mon, 28 Dec 2015 12:41:12 -0500 Subject: [PATCH 027/320] [domains] move Flickr photos to native img html --- plugins/domains/flickr.com/flickr.photo.js | 25 ++++++++++++++++------ 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/plugins/domains/flickr.com/flickr.photo.js b/plugins/domains/flickr.com/flickr.photo.js index ad81720ba..321db1fb0 100644 --- a/plugins/domains/flickr.com/flickr.photo.js +++ b/plugins/domains/flickr.com/flickr.photo.js @@ -12,7 +12,7 @@ module.exports = { "domain-icon" ], - getLink: function(urlMatch, request, options, cb) { + getLink: function(urlMatch, oembed, request, options, cb) { gUtils.getPhotoSizes(urlMatch[2], request, options.getProviderOptions('flickr.apiKey'), function(error, sizes) { if (error) { @@ -47,12 +47,22 @@ module.exports = { var media_only = options.getProviderOptions('flickr.media_only', false); if (!media_only) { - result.splice(0, 0, { - href: 'https://www.flickr.com/photos/' + urlMatch[1] + '/' + urlMatch[2] + '/player', - rel: [CONFIG.R.image, CONFIG.R.player, CONFIG.R.html5], - type: CONFIG.T.text_html, - "aspect-ratio": last.width / last.height - }); + + if (oembed.html) { + result.splice(0, 0, { + html: oembed.html, + rel: [CONFIG.R.image, CONFIG.R.ssl, CONFIG.R.inline, CONFIG.R.html5], + type: CONFIG.T.text_html, + "aspect-ratio": last.width / last.height + }); + } else { // future-proof, if html disappears + result.splice(0, 0, { + href: 'https://www.flickr.com/photos/' + urlMatch[1] + '/' + urlMatch[2] + '/player', + rel: [CONFIG.R.image, CONFIG.R.player, CONFIG.R.html5], + type: CONFIG.T.text_html, + "aspect-ratio": last.width / last.height + }); + } } cb(null, result); @@ -63,6 +73,7 @@ module.exports = { feed: "http://api.flickr.com/services/feeds/photos_public.gne" }, "http://www.flickr.com/photos/jup3nep/8243797061/?f=hp", + "https://www.flickr.com/photos/marshal-banana/23869537421", { skipMixins: [ "oembed-title", From 80b385e85c7f3ed3371b2f925256740c14e56bbb Mon Sep 17 00:00:00 2001 From: Ivan Paramonau Date: Mon, 28 Dec 2015 13:39:52 -0500 Subject: [PATCH 028/320] [domains] simplify Flickr parser --- config.local.js.SAMPLE | 4 - plugins/domains/flickr.com/flickr.photo.js | 81 +++++++------------- plugins/domains/flickr.com/flickr.profile.js | 7 +- 3 files changed, 28 insertions(+), 64 deletions(-) diff --git a/config.local.js.SAMPLE b/config.local.js.SAMPLE index 70f97a541..1057ab5df 100644 --- a/config.local.js.SAMPLE +++ b/config.local.js.SAMPLE @@ -110,10 +110,6 @@ hide_thread: false, omit_script: false }, - flickr: { - apiKey: 'INSERT YOUR VALUE' - // media_only: true // disables slideshow and gives plain image - }, "google.maps": { // apiKey: 'INSERT YOUR VALUE' // not required, but recommended }, diff --git a/plugins/domains/flickr.com/flickr.photo.js b/plugins/domains/flickr.com/flickr.photo.js index 321db1fb0..47c83918a 100644 --- a/plugins/domains/flickr.com/flickr.photo.js +++ b/plugins/domains/flickr.com/flickr.photo.js @@ -12,61 +12,33 @@ module.exports = { "domain-icon" ], - getLink: function(urlMatch, oembed, request, options, cb) { - gUtils.getPhotoSizes(urlMatch[2], request, options.getProviderOptions('flickr.apiKey'), function(error, sizes) { - - if (error) { - return cb(error); - } - - var result = sizes && sizes.map(function(size, idx) { - - if (size.media == "photo") { - - return { - href: size.source.replace(/^https?:/i, ""), - width: size.width, - height: size.height, - type: CONFIG.T.image_jpeg, - rel: size.width >= 800 || (idx === sizes.length - 1) ? CONFIG.R.image : CONFIG.R.thumbnail - }; - - } else if (size.media == "video") { - - return { - href: size.source, - "aspect-ratio": size.width / size.height, - type: /mp4/i.test(size.label) ? CONFIG.T.video_mp4 : CONFIG.T.flash, - rel: CONFIG.R.player - }; - } - }) || []; - - var last = sizes[sizes.length - 1]; - - var media_only = options.getProviderOptions('flickr.media_only', false); - - if (!media_only) { - - if (oembed.html) { - result.splice(0, 0, { - html: oembed.html, - rel: [CONFIG.R.image, CONFIG.R.ssl, CONFIG.R.inline, CONFIG.R.html5], - type: CONFIG.T.text_html, - "aspect-ratio": last.width / last.height - }); - } else { // future-proof, if html disappears - result.splice(0, 0, { - href: 'https://www.flickr.com/photos/' + urlMatch[1] + '/' + urlMatch[2] + '/player', - rel: [CONFIG.R.image, CONFIG.R.player, CONFIG.R.html5], - type: CONFIG.T.text_html, - "aspect-ratio": last.width / last.height - }); - } - } + getLink: function(oembed) { + + var result = [{ + html: oembed.html, + rel: [oembed.type === 'photo' ? CONFIG.R.image : CONFIG.R.player, CONFIG.R.ssl, CONFIG.R.inline, CONFIG.R.html5], + type: CONFIG.T.text_html, + "aspect-ratio": oembed.width / oembed.height, + "max-width": oembed.width + } , { + href: oembed.thumbnail_url, + rel: CONFIG.R.thumbnail, + type: CONFIG.T.image_jpeg, + width: oembed.thumbnail_width, + heigh: oembed.thumbnail_height + }]; + + if (oembed.type === 'photo') { + result.push ({ + href: oembed.url, + rel: [CONFIG.R.image, CONFIG.R.thumbnail], + type: CONFIG.T.image_jpeg, + width: oembed.width, + heigh: oembed.height + }); + } - cb(null, result); - }); + return result; }, tests: [{ @@ -74,6 +46,7 @@ module.exports = { }, "http://www.flickr.com/photos/jup3nep/8243797061/?f=hp", "https://www.flickr.com/photos/marshal-banana/23869537421", + "http://www.flickr.com/photos/gonzai/6027481335/in/photostream/", { skipMixins: [ "oembed-title", diff --git a/plugins/domains/flickr.com/flickr.profile.js b/plugins/domains/flickr.com/flickr.profile.js index 872654352..56f1cccc6 100644 --- a/plugins/domains/flickr.com/flickr.profile.js +++ b/plugins/domains/flickr.com/flickr.profile.js @@ -3,12 +3,7 @@ module.exports = { re: /^https?:\/\/www\.flickr\.com\/photos\/([@a-zA-Z0-9_\.-]+)\/?([?#].*)?$/, mixins: [ - "og-image", - "favicon", - "canonical", - "twitter-description", - "og-site", - "og-title" + "*" ], getLink: function(urlMatch, og) { From 34f54b7f50f37fac0c156c4cc4c3af1d57cc57aa Mon Sep 17 00:00:00 2001 From: Nazar Leush Date: Tue, 29 Dec 2015 15:25:25 +0200 Subject: [PATCH 029/320] [meta] delete meta 'description' if it is equal to 'title' --- lib/core.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/core.js b/lib/core.js index d4b75e244..3de94e579 100644 --- a/lib/core.js +++ b/lib/core.js @@ -922,6 +922,10 @@ // Remove _meta data. var canonical = result.meta.canonical; + if (result.meta.title === result.meta.description) { + delete result.meta.description; + } + for(var i = 0; i < links.length;) { var link = links[i]; From 636650dd78a24149a873a2de804ea8ac57dbc2f3 Mon Sep 17 00:00:00 2001 From: Nazar Leush Date: Tue, 29 Dec 2015 16:17:33 +0200 Subject: [PATCH 030/320] [promo] accept app responsive iframes as promo --- plugins/links/promo/promo.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/plugins/links/promo/promo.js b/plugins/links/promo/promo.js index 1cb53bcf7..c5eac6a15 100644 --- a/plugins/links/promo/promo.js +++ b/plugins/links/promo/promo.js @@ -37,6 +37,13 @@ module.exports = { // Detect if has something except thumbnail. hasGoodLinks = true; } + + if (link.href && link.type === CONFIG.T.text_html && (!link.media || link.media["aspect-ratio"])) { + // Detect responsive iframes. + hasGoodLinks = true; + return true; + } + return match.length; }); From d9c57cecff01714858385cda8ef4eeab920e1578 Mon Sep 17 00:00:00 2001 From: Ivan Paramonau Date: Tue, 29 Dec 2015 12:32:17 -0500 Subject: [PATCH 031/320] [domains] add Discovery.com --- plugins/domains/discovery.com.js | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 plugins/domains/discovery.com.js diff --git a/plugins/domains/discovery.com.js b/plugins/domains/discovery.com.js new file mode 100644 index 000000000..1ca25e9a5 --- /dev/null +++ b/plugins/domains/discovery.com.js @@ -0,0 +1,26 @@ +module.exports = { + + mixins: [ + "*" + ], + + getLink: function(meta, og) { + + if (og.video && meta.shortlink && /https?:\/\/www\.discovery\.com\/\?p=\d+/i.test(meta.shortlink)) { + + var id = meta.shortlink.match(/https?:\/\/www\.discovery\.com\/\?p=(\d+)/i)[1]; + + return { + href: "http://www.discovery.com/embed?page=" + id, + rel: [CONFIG.R.player], // not html5, not ssl + type: CONFIG.T.text_html, + "aspect-ratio": 16 / 9 + } + } + + }, + + tests: [ + "http://www.discovery.com/tv-shows/mythbusters/videos/hindenburg-minimyth/" + ] +}; \ No newline at end of file From 3cead6a65530d8bc143ae94a2116c8e7545f9c45 Mon Sep 17 00:00:00 2001 From: Ivan Paramonau Date: Tue, 29 Dec 2015 12:56:58 -0500 Subject: [PATCH 032/320] [general] try & return videos attached to og article with rel=promo --- plugins/links/og-video.js | 18 ++++++++++++------ plugins/meta/media-detector.js | 2 +- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/plugins/links/og-video.js b/plugins/links/og-video.js index 8746db2dc..7d063b00a 100644 --- a/plugins/links/og-video.js +++ b/plugins/links/og-video.js @@ -1,12 +1,18 @@ var _ = require("underscore"); var utils = require('./utils'); -function getVideoLinks(video, whitelistRecord) { +function getVideoLinks(video, whitelistRecord, og) { + + var rel = [CONFIG.R.player, CONFIG.R.og]; + + if (og.type && typeof og.type === 'string' && og.type.match(/article/i)) { + rel.push (CONFIG.R.promo); + } var players = [{ href: video.url || video, type: CONFIG.T.maybe_text_html, - rel: [CONFIG.R.player, CONFIG.R.og], + rel: rel, width: video.width, height: video.height }]; @@ -15,7 +21,7 @@ function getVideoLinks(video, whitelistRecord) { players.push({ href: video.secure_url, type: CONFIG.T.maybe_text_html, - rel: [CONFIG.R.player, CONFIG.R.og], + rel: rel, width: video.width, height: video.height }); @@ -25,7 +31,7 @@ function getVideoLinks(video, whitelistRecord) { players.push({ href: video.iframe, type: CONFIG.T.maybe_text_html, - rel: [CONFIG.R.player, CONFIG.R.og], + rel: rel, width: video.width, height: video.height }); @@ -43,12 +49,12 @@ module.exports = { if (og.video instanceof Array) { return utils.mergeMediaSize(_.flatten(og.video.map(function(video) { - return getVideoLinks(video, whitelistRecord); + return getVideoLinks(video, whitelistRecord, og); }))); } else if (og.video) { - return getVideoLinks(og.video, whitelistRecord); + return getVideoLinks(og.video, whitelistRecord, og); } } } diff --git a/plugins/meta/media-detector.js b/plugins/meta/media-detector.js index 56d975baa..6bab01a90 100644 --- a/plugins/meta/media-detector.js +++ b/plugins/meta/media-detector.js @@ -8,7 +8,7 @@ module.exports = { if (meta.og) { - if (meta.og.video || (meta.og.type && typeof meta.og.type === 'string' && meta.og.type.match(/video|movie/i) || /\/(video|videos)\//i.test(url))) { + if ((meta.og.video && !meta.og.type )|| (meta.og.type && typeof meta.og.type === 'string' && meta.og.type.match(/video|movie/i) || /\/(video|videos)\//i.test(url))) { has_player = true; } From c1f4a2cf76354c3a372612b84c63d51c6d1ad712 Mon Sep 17 00:00:00 2001 From: Ivan Paramonau Date: Tue, 29 Dec 2015 15:26:51 -0500 Subject: [PATCH 033/320] Revert "[general] try & return videos attached to og article with rel=promo" This reverts commit 3cead6a65530d8bc143ae94a2116c8e7545f9c45. --- plugins/links/og-video.js | 18 ++++++------------ plugins/meta/media-detector.js | 2 +- 2 files changed, 7 insertions(+), 13 deletions(-) diff --git a/plugins/links/og-video.js b/plugins/links/og-video.js index 7d063b00a..8746db2dc 100644 --- a/plugins/links/og-video.js +++ b/plugins/links/og-video.js @@ -1,18 +1,12 @@ var _ = require("underscore"); var utils = require('./utils'); -function getVideoLinks(video, whitelistRecord, og) { - - var rel = [CONFIG.R.player, CONFIG.R.og]; - - if (og.type && typeof og.type === 'string' && og.type.match(/article/i)) { - rel.push (CONFIG.R.promo); - } +function getVideoLinks(video, whitelistRecord) { var players = [{ href: video.url || video, type: CONFIG.T.maybe_text_html, - rel: rel, + rel: [CONFIG.R.player, CONFIG.R.og], width: video.width, height: video.height }]; @@ -21,7 +15,7 @@ function getVideoLinks(video, whitelistRecord, og) { players.push({ href: video.secure_url, type: CONFIG.T.maybe_text_html, - rel: rel, + rel: [CONFIG.R.player, CONFIG.R.og], width: video.width, height: video.height }); @@ -31,7 +25,7 @@ function getVideoLinks(video, whitelistRecord, og) { players.push({ href: video.iframe, type: CONFIG.T.maybe_text_html, - rel: rel, + rel: [CONFIG.R.player, CONFIG.R.og], width: video.width, height: video.height }); @@ -49,12 +43,12 @@ module.exports = { if (og.video instanceof Array) { return utils.mergeMediaSize(_.flatten(og.video.map(function(video) { - return getVideoLinks(video, whitelistRecord, og); + return getVideoLinks(video, whitelistRecord); }))); } else if (og.video) { - return getVideoLinks(og.video, whitelistRecord, og); + return getVideoLinks(og.video, whitelistRecord); } } } diff --git a/plugins/meta/media-detector.js b/plugins/meta/media-detector.js index 6bab01a90..56d975baa 100644 --- a/plugins/meta/media-detector.js +++ b/plugins/meta/media-detector.js @@ -8,7 +8,7 @@ module.exports = { if (meta.og) { - if ((meta.og.video && !meta.og.type )|| (meta.og.type && typeof meta.og.type === 'string' && meta.og.type.match(/video|movie/i) || /\/(video|videos)\//i.test(url))) { + if (meta.og.video || (meta.og.type && typeof meta.og.type === 'string' && meta.og.type.match(/video|movie/i) || /\/(video|videos)\//i.test(url))) { has_player = true; } From dc6d9e529b0beef61cddb9fd3099e330e119e63f Mon Sep 17 00:00:00 2001 From: Ivan Paramonau Date: Sun, 3 Jan 2016 12:09:12 -0500 Subject: [PATCH 034/320] [domains] do not use Vine's oembed player --- plugins/domains/vine.co.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/plugins/domains/vine.co.js b/plugins/domains/vine.co.js index 7a9823aba..854a5a3e2 100644 --- a/plugins/domains/vine.co.js +++ b/plugins/domains/vine.co.js @@ -7,7 +7,8 @@ module.exports = { mixins: [ "twitter-player", "twitter-stream", - "oembed-video", + //"oembed-video", + "og-video", "oembed-thumbnail", "favicon", "oembed-author", From 4442a9790cea1eeb51817e9042663b52a892657b Mon Sep 17 00:00:00 2001 From: Ivan Paramonau Date: Sun, 3 Jan 2016 12:20:38 -0500 Subject: [PATCH 035/320] [general] only use twitter:site as sitename when it matches the domain --- plugins/meta/twitter-site.js | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/plugins/meta/twitter-site.js b/plugins/meta/twitter-site.js index b7873c83b..fc186c62d 100644 --- a/plugins/meta/twitter-site.js +++ b/plugins/meta/twitter-site.js @@ -2,10 +2,17 @@ module.exports = { lowestPriority: true, - getMeta: function(twitter) { + getMeta: function(url, twitter) { - return { - site: (twitter.site && twitter.site.value) || twitter.site - } + var site = (twitter.site && twitter.site.value) || twitter.site; + if (!site) {return;} + + site = site.replace(/^@/, ''); + + if (url.indexOf(site.toLowerCase())) { + return { + site: site + } + } } }; \ No newline at end of file From 876af3af2de58a3db4cb7cf3623350ac8b8d9164 Mon Sep 17 00:00:00 2001 From: Ivan Paramonau Date: Mon, 4 Jan 2016 10:45:44 -0500 Subject: [PATCH 036/320] [domains] add option to customize Bandcamp --- config.local.js.SAMPLE | 15 +++++++++++++++ plugins/domains/bandcamp.com.js | 30 ++++++++++++++++++++++++------ 2 files changed, 39 insertions(+), 6 deletions(-) diff --git a/config.local.js.SAMPLE b/config.local.js.SAMPLE index 1057ab5df..f03a61f02 100644 --- a/config.local.js.SAMPLE +++ b/config.local.js.SAMPLE @@ -159,6 +159,21 @@ media_only: true // disables branded player for gifs and returns just the image } */ + /* + bandcamp: { + get_params: '/size=large/bgcol=333333/linkcol=ffffff/artwork=small/transparent=true/', + media: { + album: { + height: 472, + 'max-width': 700 + }, + track: { + height: 120, + 'max-width': 700 + } + } + } + */ }, // WHITELIST_WILDCARD, if present, will be added to whitelist as record for top level domain: "*" diff --git a/plugins/domains/bandcamp.com.js b/plugins/domains/bandcamp.com.js index f08ed01a2..076ac46b3 100644 --- a/plugins/domains/bandcamp.com.js +++ b/plugins/domains/bandcamp.com.js @@ -27,15 +27,18 @@ module.exports = { }; }, - getLinks: function(meta, twitter) { + getLinks: function(meta, twitter, options) { - if (twitter.site !== 'bandcamp') { + if (twitter.site !== 'bandcamp' || !twitter.player.value) { return; } + + var params = options.getProviderOptions('bandcamp'); + var result = null; - if (meta.og && meta.og.video && meta.twitter.site == "bandcamp") { + if (!params && meta.og && meta.og.video) { - return [{ + result = [{ href: meta.twitter.player.value, type: CONFIG.T.text_html, rel: [CONFIG.R.player, CONFIG.R.twitter, CONFIG.R.html5], @@ -47,8 +50,23 @@ module.exports = { rel: [CONFIG.R.player, CONFIG.R.og, CONFIG.R.html5], "max-width": 700, height: meta.og.video.height - }] - } + }]; + + } else if (params) { + + var album = /album=\d+/i.test(twitter.player.value) && twitter.player.value.match(/album=(\d+)/i)[1]; + var track = /track=\d+/i.test(twitter.player.value) && twitter.player.value.match(/track=(\d+)/i)[1]; + + result = { + href: 'https://bandcamp.com/EmbeddedPlayer' + (album ? '/album=' + album : '') + (track ? '/track=' + track : '') + params.get_params, // (in /../../ way) + rel: [CONFIG.R.player, CONFIG.R.html5], + type: CONFIG.T.text_html, + media: album ? params.media.album : params.media.track + } + + } + + return result; }, From 50cf1761dbde3b58f80770e98f7310f0d8b9e4c2 Mon Sep 17 00:00:00 2001 From: Ivan Paramonau Date: Mon, 4 Jan 2016 11:17:09 -0500 Subject: [PATCH 037/320] Revert "[domains] simplify Flickr parser" This reverts commit 80b385e85c7f3ed3371b2f925256740c14e56bbb. --- config.local.js.SAMPLE | 4 + plugins/domains/flickr.com/flickr.photo.js | 81 +++++++++++++------- plugins/domains/flickr.com/flickr.profile.js | 7 +- 3 files changed, 64 insertions(+), 28 deletions(-) diff --git a/config.local.js.SAMPLE b/config.local.js.SAMPLE index f03a61f02..a82862f62 100644 --- a/config.local.js.SAMPLE +++ b/config.local.js.SAMPLE @@ -110,6 +110,10 @@ hide_thread: false, omit_script: false }, + flickr: { + apiKey: 'INSERT YOUR VALUE' + // media_only: true // disables slideshow and gives plain image + }, "google.maps": { // apiKey: 'INSERT YOUR VALUE' // not required, but recommended }, diff --git a/plugins/domains/flickr.com/flickr.photo.js b/plugins/domains/flickr.com/flickr.photo.js index 47c83918a..321db1fb0 100644 --- a/plugins/domains/flickr.com/flickr.photo.js +++ b/plugins/domains/flickr.com/flickr.photo.js @@ -12,33 +12,61 @@ module.exports = { "domain-icon" ], - getLink: function(oembed) { - - var result = [{ - html: oembed.html, - rel: [oembed.type === 'photo' ? CONFIG.R.image : CONFIG.R.player, CONFIG.R.ssl, CONFIG.R.inline, CONFIG.R.html5], - type: CONFIG.T.text_html, - "aspect-ratio": oembed.width / oembed.height, - "max-width": oembed.width - } , { - href: oembed.thumbnail_url, - rel: CONFIG.R.thumbnail, - type: CONFIG.T.image_jpeg, - width: oembed.thumbnail_width, - heigh: oembed.thumbnail_height - }]; - - if (oembed.type === 'photo') { - result.push ({ - href: oembed.url, - rel: [CONFIG.R.image, CONFIG.R.thumbnail], - type: CONFIG.T.image_jpeg, - width: oembed.width, - heigh: oembed.height - }); - } + getLink: function(urlMatch, oembed, request, options, cb) { + gUtils.getPhotoSizes(urlMatch[2], request, options.getProviderOptions('flickr.apiKey'), function(error, sizes) { + + if (error) { + return cb(error); + } + + var result = sizes && sizes.map(function(size, idx) { + + if (size.media == "photo") { + + return { + href: size.source.replace(/^https?:/i, ""), + width: size.width, + height: size.height, + type: CONFIG.T.image_jpeg, + rel: size.width >= 800 || (idx === sizes.length - 1) ? CONFIG.R.image : CONFIG.R.thumbnail + }; + + } else if (size.media == "video") { + + return { + href: size.source, + "aspect-ratio": size.width / size.height, + type: /mp4/i.test(size.label) ? CONFIG.T.video_mp4 : CONFIG.T.flash, + rel: CONFIG.R.player + }; + } + }) || []; + + var last = sizes[sizes.length - 1]; + + var media_only = options.getProviderOptions('flickr.media_only', false); + + if (!media_only) { + + if (oembed.html) { + result.splice(0, 0, { + html: oembed.html, + rel: [CONFIG.R.image, CONFIG.R.ssl, CONFIG.R.inline, CONFIG.R.html5], + type: CONFIG.T.text_html, + "aspect-ratio": last.width / last.height + }); + } else { // future-proof, if html disappears + result.splice(0, 0, { + href: 'https://www.flickr.com/photos/' + urlMatch[1] + '/' + urlMatch[2] + '/player', + rel: [CONFIG.R.image, CONFIG.R.player, CONFIG.R.html5], + type: CONFIG.T.text_html, + "aspect-ratio": last.width / last.height + }); + } + } - return result; + cb(null, result); + }); }, tests: [{ @@ -46,7 +74,6 @@ module.exports = { }, "http://www.flickr.com/photos/jup3nep/8243797061/?f=hp", "https://www.flickr.com/photos/marshal-banana/23869537421", - "http://www.flickr.com/photos/gonzai/6027481335/in/photostream/", { skipMixins: [ "oembed-title", diff --git a/plugins/domains/flickr.com/flickr.profile.js b/plugins/domains/flickr.com/flickr.profile.js index 56f1cccc6..872654352 100644 --- a/plugins/domains/flickr.com/flickr.profile.js +++ b/plugins/domains/flickr.com/flickr.profile.js @@ -3,7 +3,12 @@ module.exports = { re: /^https?:\/\/www\.flickr\.com\/photos\/([@a-zA-Z0-9_\.-]+)\/?([?#].*)?$/, mixins: [ - "*" + "og-image", + "favicon", + "canonical", + "twitter-description", + "og-site", + "og-title" ], getLink: function(urlMatch, og) { From d0d2b6aa835ea7c30ec2510e643691f9cc500e54 Mon Sep 17 00:00:00 2001 From: Ivan Paramonau Date: Mon, 4 Jan 2016 11:18:54 -0500 Subject: [PATCH 038/320] Revert "[domains] move Flickr photos to native img html" This reverts commit 1ce47a60eb07fb0d6ba3ab899bc62660215ae5aa. --- plugins/domains/flickr.com/flickr.photo.js | 25 ++++++---------------- 1 file changed, 7 insertions(+), 18 deletions(-) diff --git a/plugins/domains/flickr.com/flickr.photo.js b/plugins/domains/flickr.com/flickr.photo.js index 321db1fb0..ad81720ba 100644 --- a/plugins/domains/flickr.com/flickr.photo.js +++ b/plugins/domains/flickr.com/flickr.photo.js @@ -12,7 +12,7 @@ module.exports = { "domain-icon" ], - getLink: function(urlMatch, oembed, request, options, cb) { + getLink: function(urlMatch, request, options, cb) { gUtils.getPhotoSizes(urlMatch[2], request, options.getProviderOptions('flickr.apiKey'), function(error, sizes) { if (error) { @@ -47,22 +47,12 @@ module.exports = { var media_only = options.getProviderOptions('flickr.media_only', false); if (!media_only) { - - if (oembed.html) { - result.splice(0, 0, { - html: oembed.html, - rel: [CONFIG.R.image, CONFIG.R.ssl, CONFIG.R.inline, CONFIG.R.html5], - type: CONFIG.T.text_html, - "aspect-ratio": last.width / last.height - }); - } else { // future-proof, if html disappears - result.splice(0, 0, { - href: 'https://www.flickr.com/photos/' + urlMatch[1] + '/' + urlMatch[2] + '/player', - rel: [CONFIG.R.image, CONFIG.R.player, CONFIG.R.html5], - type: CONFIG.T.text_html, - "aspect-ratio": last.width / last.height - }); - } + result.splice(0, 0, { + href: 'https://www.flickr.com/photos/' + urlMatch[1] + '/' + urlMatch[2] + '/player', + rel: [CONFIG.R.image, CONFIG.R.player, CONFIG.R.html5], + type: CONFIG.T.text_html, + "aspect-ratio": last.width / last.height + }); } cb(null, result); @@ -73,7 +63,6 @@ module.exports = { feed: "http://api.flickr.com/services/feeds/photos_public.gne" }, "http://www.flickr.com/photos/jup3nep/8243797061/?f=hp", - "https://www.flickr.com/photos/marshal-banana/23869537421", { skipMixins: [ "oembed-title", From ecb0ffbc6fb8a4487f7b0c78930fc181e0ebebd5 Mon Sep 17 00:00:00 2001 From: Ivan Paramonau Date: Mon, 4 Jan 2016 12:10:41 -0500 Subject: [PATCH 039/320] [docs] add Bandcamp to the list of customization examples --- docs/PARAMS.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/docs/PARAMS.md b/docs/PARAMS.md index bb5b294ff..b41cdcf73 100644 --- a/docs/PARAMS.md +++ b/docs/PARAMS.md @@ -43,9 +43,9 @@ Also, for [oEmbed API](https://iframely.com/docs/oembed-api) only: ## For individual embeds publishers -By default, Iframely provides what we believe is the best embeds for any individual publisher. But tastes do differ. +Number of publishers give different embedding options. By default, Iframely provides embeds that we believe is the best fit for most common use case. But you, of course, may need it differently. -Iframely team can configure what embeds you get for most publishers with multiple options. [Send us an email](mailto:support@iframely.com) and we'll start from there. Most adjustments take less than 30 mins to turn around. Since it's a manual process, however, we only offer this option for paid accounts. +In that case, Iframely team can configure the exact embeds you like for your favourite publishers. Since it's a manual process, we offer it for paid accounts only. [Send us an email](mailto:support@iframely.com) and we'll start from there. Most adjustments take less than 30 mins to manually turn around. Examples of what people often request: @@ -57,4 +57,6 @@ Examples of what people often request: - Show user message for Instagram embeds - Giphy: disable branded GIF player and use Iframely's [friendly GIFs](/docs/gifs) instead - Turn on support of Twitter videos (experimental) + - Bandcamp players + - Etc. From f2520a49299d8cbaccf72d6d1371ecf5c5d2e5c6 Mon Sep 17 00:00:00 2001 From: Ivan Paramonau Date: Mon, 4 Jan 2016 12:44:52 -0500 Subject: [PATCH 040/320] [domains] proper responsive hack for Flickr's photo html embeds --- config.local.js.SAMPLE | 4 -- plugins/domains/flickr.com/flickr.gallery.js | 20 ++++-- plugins/domains/flickr.com/flickr.photo.js | 73 ++++++++------------ plugins/domains/flickr.com/flickr.profile.js | 7 +- 4 files changed, 44 insertions(+), 60 deletions(-) diff --git a/config.local.js.SAMPLE b/config.local.js.SAMPLE index a82862f62..f03a61f02 100644 --- a/config.local.js.SAMPLE +++ b/config.local.js.SAMPLE @@ -110,10 +110,6 @@ hide_thread: false, omit_script: false }, - flickr: { - apiKey: 'INSERT YOUR VALUE' - // media_only: true // disables slideshow and gives plain image - }, "google.maps": { // apiKey: 'INSERT YOUR VALUE' // not required, but recommended }, diff --git a/plugins/domains/flickr.com/flickr.gallery.js b/plugins/domains/flickr.com/flickr.gallery.js index f456b3f4f..4947a1828 100644 --- a/plugins/domains/flickr.com/flickr.gallery.js +++ b/plugins/domains/flickr.com/flickr.gallery.js @@ -1,17 +1,26 @@ module.exports = { - re: /^https?:\/\/www\.flickr\.com(\/photos\/[@a-zA-Z0-9_\.]+\/sets\/(\d+))/i, + re: /^https?:\/\/www\.flickr\.com(\/photos\/[@a-zA-Z0-9_\.\-]+\/(?:sets|albums)\/(\d+))/i, mixins: [ - "*" + "oembed-thumbnail", + "domain-icon", + "oembed-author", + "oembed-site", + "oembed-title" ], - getLink: function(urlMatch) { - return { + getLink: function(urlMatch, oembed) { + return [{ href: 'https://www.flickr.com/apps/slideshow/show.swf?v=143270&offsite=true&lang=en-us&page_show_url=' + encodeURIComponent(urlMatch[1] + '/show/') + '&page_show_back_url=' + encodeURIComponent(urlMatch[1] + '/') + '&set_id=' + encodeURIComponent(urlMatch[2]) + '&jump_to=', type: CONFIG.T.flash, rel: CONFIG.R.player - }; + }, { + html: oembed.html.replace(/width=\"\d+\" height=\"\d+\" alt/, 'width="100%" alt'), + rel: [CONFIG.R.player, CONFIG.R.ssl, CONFIG.R.inline, CONFIG.R.html5], + type: CONFIG.T.text_html, + "aspect-ratio": oembed.width / oembed.height + }]; }, tests: [ @@ -21,6 +30,7 @@ module.exports = { selector: "a.photo-list-album" }, "http://www.flickr.com/photos/jup3nep/sets/72157603856136177/", + "https://www.flickr.com/photos/marshal-banana/albums/72157661935064149", { skipMixins: [ "twitter-author", diff --git a/plugins/domains/flickr.com/flickr.photo.js b/plugins/domains/flickr.com/flickr.photo.js index ad81720ba..2c05b8551 100644 --- a/plugins/domains/flickr.com/flickr.photo.js +++ b/plugins/domains/flickr.com/flickr.photo.js @@ -2,7 +2,7 @@ var gUtils = require('./utils'); module.exports = { - re: /^https?:\/\/www\.flickr\.com\/photos\/([@a-zA-Z0-9_\.-]+)\/(\d+).*?$/i, + re: /^https?:\/\/www\.flickr\.com\/photos\/([@a-zA-Z0-9_\.\-]+)\/(\d+).*?$/i, mixins: [ "oembed-title", @@ -12,57 +12,40 @@ module.exports = { "domain-icon" ], - getLink: function(urlMatch, request, options, cb) { - gUtils.getPhotoSizes(urlMatch[2], request, options.getProviderOptions('flickr.apiKey'), function(error, sizes) { - - if (error) { - return cb(error); - } - - var result = sizes && sizes.map(function(size, idx) { - - if (size.media == "photo") { - - return { - href: size.source.replace(/^https?:/i, ""), - width: size.width, - height: size.height, - type: CONFIG.T.image_jpeg, - rel: size.width >= 800 || (idx === sizes.length - 1) ? CONFIG.R.image : CONFIG.R.thumbnail - }; - - } else if (size.media == "video") { - - return { - href: size.source, - "aspect-ratio": size.width / size.height, - type: /mp4/i.test(size.label) ? CONFIG.T.video_mp4 : CONFIG.T.flash, - rel: CONFIG.R.player - }; - } - }) || []; - - var last = sizes[sizes.length - 1]; - - var media_only = options.getProviderOptions('flickr.media_only', false); - - if (!media_only) { - result.splice(0, 0, { - href: 'https://www.flickr.com/photos/' + urlMatch[1] + '/' + urlMatch[2] + '/player', - rel: [CONFIG.R.image, CONFIG.R.player, CONFIG.R.html5], - type: CONFIG.T.text_html, - "aspect-ratio": last.width / last.height - }); - } + getLink: function(oembed) { + + var result = [{ + html: oembed.html.replace(/width=\"\d+\" height=\"\d+\" alt/, 'width="100%" alt'), + rel: [oembed.type === 'photo' ? CONFIG.R.image : CONFIG.R.player, CONFIG.R.ssl, CONFIG.R.inline, CONFIG.R.html5], + type: CONFIG.T.text_html, + "aspect-ratio": oembed.width / oembed.height + } , { + href: oembed.thumbnail_url, + rel: CONFIG.R.thumbnail, + type: CONFIG.T.image_jpeg, + width: oembed.thumbnail_width, + heigh: oembed.thumbnail_height + }]; + + if (oembed.type === 'photo') { + result.push ({ + href: oembed.url, + rel: [CONFIG.R.image, CONFIG.R.thumbnail], + type: CONFIG.T.image_jpeg, + width: oembed.width, + heigh: oembed.height + }); + } - cb(null, result); - }); + return result; }, tests: [{ feed: "http://api.flickr.com/services/feeds/photos_public.gne" }, "http://www.flickr.com/photos/jup3nep/8243797061/?f=hp", + "https://www.flickr.com/photos/marshal-banana/23869537421", + "http://www.flickr.com/photos/gonzai/6027481335/in/photostream/", { skipMixins: [ "oembed-title", diff --git a/plugins/domains/flickr.com/flickr.profile.js b/plugins/domains/flickr.com/flickr.profile.js index 872654352..56f1cccc6 100644 --- a/plugins/domains/flickr.com/flickr.profile.js +++ b/plugins/domains/flickr.com/flickr.profile.js @@ -3,12 +3,7 @@ module.exports = { re: /^https?:\/\/www\.flickr\.com\/photos\/([@a-zA-Z0-9_\.-]+)\/?([?#].*)?$/, mixins: [ - "og-image", - "favicon", - "canonical", - "twitter-description", - "og-site", - "og-title" + "*" ], getLink: function(urlMatch, og) { From dd8fe7473b142e397249a5ab5344aa00812715e8 Mon Sep 17 00:00:00 2001 From: Nazar Leush Date: Tue, 5 Jan 2016 15:46:26 +0200 Subject: [PATCH 041/320] [domains] flickr.com: update oembed provider In url like: https://www.flickr.com//photos/supportspartans/sets/72157630936017776/sh ow/with/7727549982/ skip part /show/with/7727549982/ --- lib/plugins/system/oembed/providers.json | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/plugins/system/oembed/providers.json b/lib/plugins/system/oembed/providers.json index 726ccf643..f22ede731 100644 --- a/lib/plugins/system/oembed/providers.json +++ b/lib/plugins/system/oembed/providers.json @@ -39,9 +39,11 @@ { "name": "Flickr", "templates": [ - "(www\\.)?flickr\\.com/.*" + "(?:www\\.)?flickr\\.com/(photos/[@a-zA-Z0-9_\\.-]+/?(?:[?#].*)?$)", + "(?:www\\.)?flickr\\.com/(photos/[@a-zA-Z0-9_\\.-]+/\\d+.*?$)", + "(?:www\\.)?flickr\\.com/(photos/[@a-zA-Z0-9_\\.-]+/(?:sets|albums)/(?:\\d+))" ], - "endpoint": "http://www.flickr.com/services/oembed/" + "endpoint": "http://www.flickr.com/services/oembed/?format={format}&url=https://www.flickr.com/{1}" }, { "name": "Hulu", From 23f68e01f907d967f8e4ba705b588aed25cdca3a Mon Sep 17 00:00:00 2001 From: Nazar Leush Date: Tue, 5 Jan 2016 17:00:57 +0200 Subject: [PATCH 042/320] [domains] flickr.com gallery: fix lowercase 'n' --- plugins/domains/flickr.com/flickr.gallery.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/plugins/domains/flickr.com/flickr.gallery.js b/plugins/domains/flickr.com/flickr.gallery.js index 4947a1828..b48317e8c 100644 --- a/plugins/domains/flickr.com/flickr.gallery.js +++ b/plugins/domains/flickr.com/flickr.gallery.js @@ -16,7 +16,9 @@ module.exports = { type: CONFIG.T.flash, rel: CONFIG.R.player }, { - html: oembed.html.replace(/width=\"\d+\" height=\"\d+\" alt/, 'width="100%" alt'), + html: oembed.html + .replace(/\@n/g, "@N") + .replace(/width=\"\d+\" height=\"\d+\" alt/, 'width="100%" alt'), rel: [CONFIG.R.player, CONFIG.R.ssl, CONFIG.R.inline, CONFIG.R.html5], type: CONFIG.T.text_html, "aspect-ratio": oembed.width / oembed.height From b8efd50728d5bdc4aac12656dd60ec2caf3174d2 Mon Sep 17 00:00:00 2001 From: Nazar Leush Date: Tue, 5 Jan 2016 18:17:48 +0200 Subject: [PATCH 043/320] [promo] promo-oembed: better promo check --- plugins/links/promo/promo-oembed.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/links/promo/promo-oembed.js b/plugins/links/promo/promo-oembed.js index 9dce32f38..589f6fe39 100644 --- a/plugins/links/promo/promo-oembed.js +++ b/plugins/links/promo/promo-oembed.js @@ -23,7 +23,7 @@ module.exports = { var urlObj = urlLib.parse(href, true); var promo = urlObj.query.promo; - if (promo.match(/https?:\/\/.+/i)) { + if (promo && promo.match(/https?:\/\/.+/i)) { return { __promoUri: promo From d2981e0f5ce22e91afddcff9ffcd6bfd81173e92 Mon Sep 17 00:00:00 2001 From: Nazar Leush Date: Thu, 7 Jan 2016 20:06:50 +0200 Subject: [PATCH 044/320] [cache] do not use cache for meta and oembed if options.refrsh=true --- lib/plugins/system/meta/cachedMeta.js | 43 ++++++++++++++---------- lib/plugins/system/oembed/oembedUtils.js | 6 +++- modules/api/views.js | 6 ++-- 3 files changed, 35 insertions(+), 20 deletions(-) diff --git a/lib/plugins/system/meta/cachedMeta.js b/lib/plugins/system/meta/cachedMeta.js index 9dab478d0..e9011b7c1 100644 --- a/lib/plugins/system/meta/cachedMeta.js +++ b/lib/plugins/system/meta/cachedMeta.js @@ -6,31 +6,40 @@ module.exports = { provides: ['__noCachedMeta', 'meta'], - getData: function(url, cb) { + getData: function(url, options, cb) { - var meta_key = 'meta:' + url; + if (options.refresh) { - cache.get(meta_key, function(error, data) { + cb(null, { + __noCachedMeta: true + }); - if (error) { - sysUtils.log(' -- Error loading cached meta for: ' + url + '. ' + error); - } + } else { - if (!error && data) { + var meta_key = 'meta:' + url; - sysUtils.log(' -- Using cached meta for: ' + url); + cache.get(meta_key, function(error, data) { - cb(error, { - meta: data - }); + if (error) { + sysUtils.log(' -- Error loading cached meta for: ' + url + '. ' + error); + } - } else { + if (!error && data) { - cb(null, { - __noCachedMeta: true - }); - } - }); + sysUtils.log(' -- Using cached meta for: ' + url); + + cb(error, { + meta: data + }); + + } else { + + cb(null, { + __noCachedMeta: true + }); + } + }); + } } }; \ No newline at end of file diff --git a/lib/plugins/system/oembed/oembedUtils.js b/lib/plugins/system/oembed/oembedUtils.js index 2738a3a8c..ef60545e6 100644 --- a/lib/plugins/system/oembed/oembedUtils.js +++ b/lib/plugins/system/oembed/oembedUtils.js @@ -146,7 +146,11 @@ module.exports.getOembed = function(uri, options, callback) { async.waterfall([ function(cb) { - cache.get(oembed_key, cb); + if (options.refresh) { + cb(null, null); + } else { + cache.get(oembed_key, cb); + } }, function(data, cb) { diff --git a/modules/api/views.js b/modules/api/views.js index 1f9eaae87..e96976fe4 100644 --- a/modules/api/views.js +++ b/modules/api/views.js @@ -70,7 +70,8 @@ module.exports = function(app) { readability: getBooleanParam(req, 'readability'), getWhitelistRecord: whitelist.findWhitelistRecordFor, maxWidth: getIntParam(req, 'maxwidth') || getIntParam(req, 'max-width'), - promoUri: req.query.promoUri + promoUri: req.query.promoUri, + refresh: getBooleanParam(req, 'refresh') }, cb); } @@ -375,7 +376,8 @@ module.exports = function(app) { getWhitelistRecord: whitelist.findWhitelistRecordFor, filterNonSSL: getBooleanParam(req, 'ssl'), filterNonHTML5: getBooleanParam(req, 'html5'), - maxWidth: getIntParam(req, 'maxwidth') || getIntParam(req, 'max-width') + maxWidth: getIntParam(req, 'maxwidth') || getIntParam(req, 'max-width'), + refresh: getBooleanParam(req, 'refresh') }, cb); } From 4a69b03413f1ace8ff0a4cb244bc092cc3349e0a Mon Sep 17 00:00:00 2001 From: Ivan Paramonau Date: Thu, 7 Jan 2016 17:17:52 -0500 Subject: [PATCH 045/320] [domains] add Reddit comments --- plugins/domains/reddit.com/reddit.com.ejs | 1 + plugins/domains/reddit.com/reddit.com.js | 26 +++++++++++++++++++++++ 2 files changed, 27 insertions(+) create mode 100644 plugins/domains/reddit.com/reddit.com.ejs create mode 100644 plugins/domains/reddit.com/reddit.com.js diff --git a/plugins/domains/reddit.com/reddit.com.ejs b/plugins/domains/reddit.com/reddit.com.ejs new file mode 100644 index 000000000..ae1ba3bba --- /dev/null +++ b/plugins/domains/reddit.com/reddit.com.ejs @@ -0,0 +1 @@ +
Comment from discussion <%=thread_title%>.
\ No newline at end of file diff --git a/plugins/domains/reddit.com/reddit.com.js b/plugins/domains/reddit.com/reddit.com.js new file mode 100644 index 000000000..eff630385 --- /dev/null +++ b/plugins/domains/reddit.com/reddit.com.js @@ -0,0 +1,26 @@ +module.exports = { + + re: /^https?:\/\/(?:www|m\.)?reddit\.com\/r\/([^\/]+)\/comments\/([a-zA-Z0-9]+)\/([a-zA-Z0-9_]+)\/([a-zA-Z0-9]+)/i, + + mixins: [ + "*" + ], + + getLink: function(urlMatch, twitter) { + + return { + template_context: { + url: 'https://reddit.com/r/' + urlMatch[1] + '/comments/' + urlMatch[2] + '/' + urlMatch[3] + '/' + urlMatch[4], + thread_title: twitter.title || 'reddit thread', + thread_url: 'https://reddit.com/r/' + urlMatch[1] + '/comments/' + urlMatch[2] + '/' + urlMatch[3], + date: new Date () + }, + type: CONFIG.T.text_html, + rel: [CONFIG.R.app, CONFIG.R.inline, CONFIG.R.ssl] + } + }, + + tests: [ + "https://www.reddit.com/r/photography/comments/3ub9mo/official_mega_thread_black_friday_cyber_monday/cxdtl7r" + ] +}; \ No newline at end of file From 1c24d853c2d8bef1cb9dc42c6de569d992983e5d Mon Sep 17 00:00:00 2001 From: Nazar Leush Date: Fri, 8 Jan 2016 14:26:26 +0200 Subject: [PATCH 046/320] [domains] reddit.com: fix plugin regexp --- plugins/domains/reddit.com/reddit.com.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/plugins/domains/reddit.com/reddit.com.js b/plugins/domains/reddit.com/reddit.com.js index eff630385..6f9a2cebe 100644 --- a/plugins/domains/reddit.com/reddit.com.js +++ b/plugins/domains/reddit.com/reddit.com.js @@ -1,13 +1,13 @@ module.exports = { - re: /^https?:\/\/(?:www|m\.)?reddit\.com\/r\/([^\/]+)\/comments\/([a-zA-Z0-9]+)\/([a-zA-Z0-9_]+)\/([a-zA-Z0-9]+)/i, + + re: /^https?:\/\/(?:www\.|m\.)?reddit\.com\/r\/([^\/]+)\/comments\/([a-zA-Z0-9]+)\/([a-zA-Z0-9_]+)\/([a-zA-Z0-9]+)/i, mixins: [ "*" ], getLink: function(urlMatch, twitter) { - return { template_context: { url: 'https://reddit.com/r/' + urlMatch[1] + '/comments/' + urlMatch[2] + '/' + urlMatch[3] + '/' + urlMatch[4], @@ -17,7 +17,7 @@ module.exports = { }, type: CONFIG.T.text_html, rel: [CONFIG.R.app, CONFIG.R.inline, CONFIG.R.ssl] - } + }; }, tests: [ From 3edd57960185d7672471d21db30cb0e573d08c09 Mon Sep 17 00:00:00 2001 From: Ivan Paramonau Date: Fri, 8 Jan 2016 08:00:04 -0500 Subject: [PATCH 047/320] [domains] fix some cases for NBC --- plugins/domains/nbc.com.js | 26 ++++++++++++++++++++++++ plugins/domains/tumblr.com/tumblr.api.js | 2 +- 2 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 plugins/domains/nbc.com.js diff --git a/plugins/domains/nbc.com.js b/plugins/domains/nbc.com.js new file mode 100644 index 000000000..f1a3d9ac5 --- /dev/null +++ b/plugins/domains/nbc.com.js @@ -0,0 +1,26 @@ +module.exports = { + + mixins: [ + "*" + ], + + getLink: function(twitter) { + + if (twitter.player && twitter.player.value && !/\/onsite_universal\//i.test(twitter.player.value)) { // avoid "this video is not allowed on this domain" + + return { + href: twitter.player.value, + type: CONFIG.T.text_html, + rel: [CONFIG.R.player, CONFIG.R.html5], + "aspect-ratio": twitter.player.width > twitter.player.height ? twitter.player.width / twitter.player.height : twitter.player.height / twitter.player.width + // yep, width and height can be mixed + } + } + }, + + tests: [ + "https://www.nbc.com/the-tonight-show/video/alex-rodriguez-clears-up-his-animosity-toward-jimmy/2928739", + "http://www.nbc.com/late-night-with-seth-meyers/video/the-bots-performance-blinded/2845870" // US only, wrong width and height + // "http://www.nbc.com/saturday-night-live/video/hotline-bling-parody/2933534", // not allowed + ] +}; \ No newline at end of file diff --git a/plugins/domains/tumblr.com/tumblr.api.js b/plugins/domains/tumblr.com/tumblr.api.js index c67e85baa..8318245c9 100644 --- a/plugins/domains/tumblr.com/tumblr.api.js +++ b/plugins/domains/tumblr.com/tumblr.api.js @@ -18,7 +18,7 @@ module.exports = { } return { - title: tumblr_post.title || caption || tumblr_post.blog_name, + title: tumblr_post.title || caption || tumblr_post.summary || tumblr_post.blog_name, site: 'Tumblr', author: tumblr_post.blog_name, author_url: 'http://' + tumblr_post.blog_name + '.tumblr.com', From 2795bfa001943e57a42b36d5abcf286708b76e67 Mon Sep 17 00:00:00 2001 From: Nazar Leush Date: Fri, 8 Jan 2016 16:10:01 +0200 Subject: [PATCH 048/320] [domains] add "reddit comment" oembed endpoint --- lib/plugins/system/oembed/providers.json | 7 ++++++ plugins/domains/reddit.com/reddit.com.ejs | 1 - plugins/domains/reddit.com/reddit.com.js | 26 ----------------------- 3 files changed, 7 insertions(+), 27 deletions(-) delete mode 100644 plugins/domains/reddit.com/reddit.com.ejs delete mode 100644 plugins/domains/reddit.com/reddit.com.js diff --git a/lib/plugins/system/oembed/providers.json b/lib/plugins/system/oembed/providers.json index f22ede731..f18cfb569 100644 --- a/lib/plugins/system/oembed/providers.json +++ b/lib/plugins/system/oembed/providers.json @@ -452,5 +452,12 @@ "stock.adobe.com/.*" ], "endpoint": "https://stock.adobe.com/oembed" + }, + { + "name": "Reddit comment", + "templates": [ + "(?:www\\.|m\\.)?reddit\\.com/r/([^\/]+)/comments/([a-zA-Z0-9]+)/([a-zA-Z0-9_]+)/([a-zA-Z0-9]+)" + ], + "endpoint": "https://www.reddit.com/oembed" } ] \ No newline at end of file diff --git a/plugins/domains/reddit.com/reddit.com.ejs b/plugins/domains/reddit.com/reddit.com.ejs deleted file mode 100644 index ae1ba3bba..000000000 --- a/plugins/domains/reddit.com/reddit.com.ejs +++ /dev/null @@ -1 +0,0 @@ -
Comment from discussion <%=thread_title%>.
\ No newline at end of file diff --git a/plugins/domains/reddit.com/reddit.com.js b/plugins/domains/reddit.com/reddit.com.js deleted file mode 100644 index 6f9a2cebe..000000000 --- a/plugins/domains/reddit.com/reddit.com.js +++ /dev/null @@ -1,26 +0,0 @@ -module.exports = { - - - re: /^https?:\/\/(?:www\.|m\.)?reddit\.com\/r\/([^\/]+)\/comments\/([a-zA-Z0-9]+)\/([a-zA-Z0-9_]+)\/([a-zA-Z0-9]+)/i, - - mixins: [ - "*" - ], - - getLink: function(urlMatch, twitter) { - return { - template_context: { - url: 'https://reddit.com/r/' + urlMatch[1] + '/comments/' + urlMatch[2] + '/' + urlMatch[3] + '/' + urlMatch[4], - thread_title: twitter.title || 'reddit thread', - thread_url: 'https://reddit.com/r/' + urlMatch[1] + '/comments/' + urlMatch[2] + '/' + urlMatch[3], - date: new Date () - }, - type: CONFIG.T.text_html, - rel: [CONFIG.R.app, CONFIG.R.inline, CONFIG.R.ssl] - }; - }, - - tests: [ - "https://www.reddit.com/r/photography/comments/3ub9mo/official_mega_thread_black_friday_cyber_monday/cxdtl7r" - ] -}; \ No newline at end of file From 2cfb6c7ab790e93e742e82893d6abd1f729adb3c Mon Sep 17 00:00:00 2001 From: Ivan Paramonau Date: Sun, 10 Jan 2016 11:01:00 -0500 Subject: [PATCH 049/320] [domains] simple fix for monosnap's small twitter photos --- plugins/domains/monosnap.com.js | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 plugins/domains/monosnap.com.js diff --git a/plugins/domains/monosnap.com.js b/plugins/domains/monosnap.com.js new file mode 100644 index 000000000..48a789f12 --- /dev/null +++ b/plugins/domains/monosnap.com.js @@ -0,0 +1,9 @@ +module.exports = { + + re: [ + /^https?:\/\/monosnap\.com\/file\/[a-zA-Z0-9]+/i + ], + + mixins: ['*', 'og-image-rel-image'] + +}; \ No newline at end of file From 9d90db2152c856fea3021136d2aaf9a3b2579476 Mon Sep 17 00:00:00 2001 From: Ivan Paramonau Date: Sun, 10 Jan 2016 11:01:27 -0500 Subject: [PATCH 050/320] [domains] a little better regex for hosted brightcove --- plugins/links/promo/brightcove-hosted.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/links/promo/brightcove-hosted.js b/plugins/links/promo/brightcove-hosted.js index 6a606de17..9cfb9e018 100644 --- a/plugins/links/promo/brightcove-hosted.js +++ b/plugins/links/promo/brightcove-hosted.js @@ -25,7 +25,7 @@ module.exports = { } - var urlMatch = video_src.match(/^https?:\/\/link\.brightcove\.com\/services\/player\/bcpid(\d+)\?/i); + var urlMatch = video_src.match(/^https?:\/\/link\.brightcove\.com\/services\/player\/bcpid(\d+)\/?\?/i); if (urlMatch) { From d203178be8f6c1b24854cf21830a9d71ac575819 Mon Sep 17 00:00:00 2001 From: Ivan Paramonau Date: Wed, 13 Jan 2016 07:40:53 -0500 Subject: [PATCH 051/320] [domain] config option to disable Vine player on mobile --- plugins/domains/vine.co.js | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/plugins/domains/vine.co.js b/plugins/domains/vine.co.js index 854a5a3e2..d7f8d8b55 100644 --- a/plugins/domains/vine.co.js +++ b/plugins/domains/vine.co.js @@ -5,7 +5,7 @@ module.exports = { ], mixins: [ - "twitter-player", + //"twitter-player", "twitter-stream", //"oembed-video", "og-video", @@ -18,6 +18,22 @@ module.exports = { "oembed-title" ], + getLink: function (twitter, options) { + + var rel = [CONFIG.R.player]; + + if (!(options.getProviderOptions("vine") && options.getProviderOptions("vine").disable_on_mobile)) { + rel.push(CONFIG.R.html5); + } + + return { + href: twitter.player.value, + type: CONFIG.T.text_html, + rel: rel, + "aspect-ratio": twitter.player.width / twitter.player.height + } + }, + // plugin is left for tests and speed mostly, as it is well covered by generic plugins tests: [ "https://vine.co/v/bjHh0zHdgZT", From b8a6e6c48b31768ae0efacea9e56771f49bd20d5 Mon Sep 17 00:00:00 2001 From: Nazar Leush Date: Wed, 13 Jan 2016 14:52:34 +0200 Subject: [PATCH 052/320] [domain] config option to disable Vine player on mobile --- plugins/domains/vine.co.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/domains/vine.co.js b/plugins/domains/vine.co.js index d7f8d8b55..c426cc29f 100644 --- a/plugins/domains/vine.co.js +++ b/plugins/domains/vine.co.js @@ -22,7 +22,7 @@ module.exports = { var rel = [CONFIG.R.player]; - if (!(options.getProviderOptions("vine") && options.getProviderOptions("vine").disable_on_mobile)) { + if (!options.getProviderOptions("vine.disable_on_mobile")) { rel.push(CONFIG.R.html5); } From 55635b0c47243d3317884367b8208eba0ddcbafc Mon Sep 17 00:00:00 2001 From: Ivan Paramonau Date: Wed, 13 Jan 2016 12:12:37 -0500 Subject: [PATCH 053/320] [meta] return media=reader for og:type==article --- plugins/meta/media-detector.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/meta/media-detector.js b/plugins/meta/media-detector.js index 56d975baa..6bab01a90 100644 --- a/plugins/meta/media-detector.js +++ b/plugins/meta/media-detector.js @@ -8,7 +8,7 @@ module.exports = { if (meta.og) { - if (meta.og.video || (meta.og.type && typeof meta.og.type === 'string' && meta.og.type.match(/video|movie/i) || /\/(video|videos)\//i.test(url))) { + if ((meta.og.video && !meta.og.type )|| (meta.og.type && typeof meta.og.type === 'string' && meta.og.type.match(/video|movie/i) || /\/(video|videos)\//i.test(url))) { has_player = true; } From 94eb8c62c3958b49fe80d19c94b391803a303f2b Mon Sep 17 00:00:00 2001 From: Ivan Paramonau Date: Wed, 13 Jan 2016 12:27:13 -0500 Subject: [PATCH 054/320] [meta] do not force media=player on players if there's another media already --- lib/core.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/core.js b/lib/core.js index 3de94e579..6af8f003f 100644 --- a/lib/core.js +++ b/lib/core.js @@ -956,7 +956,7 @@ } } - if (link.rel.indexOf(CONFIG.R.player) > -1) { + if (link.rel.indexOf(CONFIG.R.player) > -1 && !(result.meta && result.meta.media)) { result.meta.media = 'player'; } From d9c3acdd0c2fcdf82c6418aa3dc22b2c03a87d38 Mon Sep 17 00:00:00 2001 From: Nazar Leush Date: Wed, 13 Jan 2016 19:31:15 +0200 Subject: [PATCH 055/320] [core] simplify check --- lib/core.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/core.js b/lib/core.js index 6af8f003f..f70545581 100644 --- a/lib/core.js +++ b/lib/core.js @@ -956,7 +956,7 @@ } } - if (link.rel.indexOf(CONFIG.R.player) > -1 && !(result.meta && result.meta.media)) { + if (!result.meta.media && link.rel.indexOf(CONFIG.R.player) > -1) { result.meta.media = 'player'; } From 3640560f225db47e8d0e998c9a1d686b671f44a2 Mon Sep 17 00:00:00 2001 From: Ivan Paramonau Date: Thu, 14 Jan 2016 10:35:04 -0500 Subject: [PATCH 056/320] [domains] do not use rel promo for bleacher report --- plugins/domains/bleacherreport.com.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/plugins/domains/bleacherreport.com.js b/plugins/domains/bleacherreport.com.js index 815ad95b6..88921beb7 100644 --- a/plugins/domains/bleacherreport.com.js +++ b/plugins/domains/bleacherreport.com.js @@ -7,13 +7,24 @@ module.exports = { if (oembed.type === 'video' && oembed.video_id) { return { href: "http://bleacherreport.com/video_embed?id=" + oembed.video_id, - rel: [CONFIG.R.player, CONFIG.R.html5, CONFIG.R.promo], + rel: [CONFIG.R.player, CONFIG.R.html5], type: CONFIG.T.text_html, 'aspect-ratio': 630 / 355 } } }, + getMeta: function (oembed) { + + if (oembed.type === 'video' && oembed.video_id) { + return { + media: "player" + } + } + }, + + highestPriority: true, + tests: [ "http://bleacherreport.com/articles/2522329-cam-newton-most-fun-substitute-teacher-ever" // Should not work - http://bleacherreport.com/articles/2580263-newsman-says-michigan-beat-michigan-state-while-reporting-outside-the-big-house (embeded video) From ecb94de29a2634303c38a3430445ccfb3a049e13 Mon Sep 17 00:00:00 2001 From: Ivan Paramonau Date: Thu, 14 Jan 2016 11:00:21 -0500 Subject: [PATCH 057/320] [domain] add popsugar vids --- plugins/domains/popsugar.com.js | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 plugins/domains/popsugar.com.js diff --git a/plugins/domains/popsugar.com.js b/plugins/domains/popsugar.com.js new file mode 100644 index 000000000..f3228e9d7 --- /dev/null +++ b/plugins/domains/popsugar.com.js @@ -0,0 +1,21 @@ +module.exports = { + + mixins: ["*"], + + getLink: function (twitter) { + + if (twitter.player && twitter.player.stream) { + return { + href: (twitter.player.stream.value || twitter.player.stream).replace(/^https:\/\//, 'http://'), //https has broken redirects + rel: CONFIG.R.player, + type: CONFIG.T.maybe_text_html, // verify that it is ok + 'aspect-ratio': 16/9 + } + } + }, + + tests: [ + "http://www.popsugar.com/home/House-Hunters-Spoof-Video-38029585", + "http://www.popsugar.com/celebrity/Viola-Davis-Sexual-Assault-Speech-Video-39127511" + ] +}; \ No newline at end of file From 137a99868b33bc9c7affff56a907d17fe46bbc31 Mon Sep 17 00:00:00 2001 From: Ivan Paramonau Date: Thu, 14 Jan 2016 11:19:56 -0500 Subject: [PATCH 058/320] [domains] support nbcsports vids --- plugins/domains/nbcsports.com.js | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 plugins/domains/nbcsports.com.js diff --git a/plugins/domains/nbcsports.com.js b/plugins/domains/nbcsports.com.js new file mode 100644 index 000000000..416e14d35 --- /dev/null +++ b/plugins/domains/nbcsports.com.js @@ -0,0 +1,27 @@ +module.exports = { + + re: [ + /^https?:\/\/www\.nbcsports\.com\/videos?\/[a-zA-Z0-9-]+/i + ], + + mixins: [ + "*" + ], + + getLink: function(twitter) { + + if (twitter.player) { + + return { + href: twitter.player.stream.value || twitter.player.stream, + type: CONFIG.T.maybe_text_html, // verify, it is likely a text/html rather than mp4 + rel: [CONFIG.R.player, CONFIG.R.html5], + "aspect-ratio": 16 / 9 // twitter.player width & height are incorrect + } + } + }, + + tests: [ + "http://www.nbcsports.com/video/redskins-team-beat-wild-card-matchup-vs-packers" + ] +}; \ No newline at end of file From aaf3c790dc90ba84ba5c06f74e21e28a13c197fc Mon Sep 17 00:00:00 2001 From: Ivan Paramonau Date: Thu, 14 Jan 2016 19:59:45 -0500 Subject: [PATCH 059/320] [docs] better embed selector for buzzfeed --- plugins/domains/buzzfeed.com/buzzfeed.video.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/plugins/domains/buzzfeed.com/buzzfeed.video.js b/plugins/domains/buzzfeed.com/buzzfeed.video.js index ad5a29708..fb324d4d3 100644 --- a/plugins/domains/buzzfeed.com/buzzfeed.video.js +++ b/plugins/domains/buzzfeed.com/buzzfeed.video.js @@ -12,7 +12,7 @@ module.exports = { getData: function(cheerio, __isBuzzFeedVideo, cb) { - var $el = cheerio('.video-embed-videopost'); + var $el = cheerio('.video-embed-area'); var embed = JSON.parse($el.attr('rel:bf_bucket_data')); if (embed.video && embed.video.url) { @@ -25,6 +25,7 @@ module.exports = { }, tests: [ - "http://www.buzzfeed.com/brentbennett/star-wars-cast-members-do-star-wars-impersonations#.idE4zm45aA" + "http://www.buzzfeed.com/brentbennett/star-wars-cast-members-do-star-wars-impersonations#.idE4zm45aA", + "http://www.buzzfeed.com/tristanhill/if-you-won-the-lottery" ] }; From 96370bb6e0b2d2ca42fe01872f246e2ac464687e Mon Sep 17 00:00:00 2001 From: Ivan Paramonau Date: Fri, 15 Jan 2016 12:20:28 -0500 Subject: [PATCH 060/320] fix undefined on og-youtube --- plugins/links/promo/og-youtube.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/links/promo/og-youtube.js b/plugins/links/promo/og-youtube.js index e91a67f8d..8aee03cfb 100644 --- a/plugins/links/promo/og-youtube.js +++ b/plugins/links/promo/og-youtube.js @@ -7,7 +7,7 @@ module.exports = { // do not process if there is a whitelist record for this domain as processing will take longer if (!whitelistRecord.isDefault && whitelistRecord.isAllowed && whitelistRecord.isAllowed('og.video')) {return;} - var video_src = (og.video && og.video.url) || og.video; + var video_src = (og.video && og.video.url) || (og.video && og.video.iframe) || og.video; if (!video_src || /youtube\.com|vimeo\.com|dailymotion\.com/.test(url) || video_src instanceof Array) { return; } From dfc59be5ccff2a979879d311550d0687a7158d2e Mon Sep 17 00:00:00 2001 From: Ivan Paramonau Date: Fri, 15 Jan 2016 14:33:20 -0500 Subject: [PATCH 061/320] [domains] add support for cinesports --- plugins/domains/cinesport.video.js | 52 ++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 plugins/domains/cinesport.video.js diff --git a/plugins/domains/cinesport.video.js b/plugins/domains/cinesport.video.js new file mode 100644 index 000000000..44dfc084a --- /dev/null +++ b/plugins/domains/cinesport.video.js @@ -0,0 +1,52 @@ +var cheerio = require('cheerio'); + +module.exports = { + + re: [ + /^https?:\/\/cinesport\.(\w+)\.com\/[a-zA-Z0-9-]+/i, + /^https?:\/\/(?:www\.)?cinesport\.com\/[a-zA-Z0-9-]+/i + ], + + mixins: ["*"], + + getMeta: function (oembed) { + return { + keywords: oembed.keywords + } + }, + + getLink: function(oembed) { + + if (!(oembed.type === 'video' && oembed.html)) { + return; + } + + var $container = cheerio('
'); + try{ + $container.html(oembed.html); + } catch(ex) {} + + var $iframe = $container.find('iframe'); + + if ($iframe.length == 1) { + + var href = $iframe.attr('src'); + + return { + href: href, + type: CONFIG.T.text_html, + rel: [CONFIG.R.player, CONFIG.R.autoplay, CONFIG.R.html5], + "aspect-ratio": 1 / 0.5725 + }; + } + + }, + + tests: [ + "http://cinesport.stltoday.com/saint-louis-sports/matter-will-sanctions-hurt-mizzou/", + "http://www.cinesport.com/nba/three-jimmy-butler-scores-53-points/", + "http://www.cinesport.com/nhl/rutherford-blues-send-kroenke-message/", + "http://cinesport.cincinnati.com/cincinnati-sports/ap-alabama-tops-clemson-title-game/" + ] + +}; \ No newline at end of file From 53c1a935a77372a08d45623309a62a462ea9a516 Mon Sep 17 00:00:00 2001 From: Ivan Paramonau Date: Fri, 15 Jan 2016 14:50:12 -0500 Subject: [PATCH 062/320] [fb] fix broken embeds for fb personal pages when "security check required" --- plugins/domains/facebook.com/facebook.data.js | 3 ++- plugins/domains/facebook.com/facebook.page.js | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/plugins/domains/facebook.com/facebook.data.js b/plugins/domains/facebook.com/facebook.data.js index 62e8a64b5..d3cfd43ac 100644 --- a/plugins/domains/facebook.com/facebook.data.js +++ b/plugins/domains/facebook.com/facebook.data.js @@ -11,7 +11,8 @@ module.exports = { getMeta: function(meta) { return { - title: title = meta["description"] ? meta["description"]: meta["html-title"].replace(/ \| Facebook$/, "") + title: meta["html-title"].replace(/ \| Facebook$/, ""), + description: meta["description"] }; }, diff --git a/plugins/domains/facebook.com/facebook.page.js b/plugins/domains/facebook.com/facebook.page.js index f9fc3a0cf..2215522f0 100644 --- a/plugins/domains/facebook.com/facebook.page.js +++ b/plugins/domains/facebook.com/facebook.page.js @@ -8,7 +8,7 @@ module.exports = { getLink: function(meta, oembed, options) { // skip user profiles - they can not be embedded - if (meta.al && meta.al.android && meta.al.android.url && /\/profile\//.test(meta.al.android.url)) { + if (!meta.al || (meta.al && meta.al.android && meta.al.android.url && /\/profile\//.test(meta.al.android.url))) { return; } From f1005e80fe094ada224c9c371b4e81fdd4c33bef Mon Sep 17 00:00:00 2001 From: Ivan Paramonau Date: Sat, 16 Jan 2016 09:27:36 -0500 Subject: [PATCH 063/320] [domains] add support for foxsports --- plugins/domains/foxsports.com.js | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 plugins/domains/foxsports.com.js diff --git a/plugins/domains/foxsports.com.js b/plugins/domains/foxsports.com.js new file mode 100644 index 000000000..858d944f0 --- /dev/null +++ b/plugins/domains/foxsports.com.js @@ -0,0 +1,29 @@ +module.exports = { + + re: [ + /^https?:\/\/www\.foxsports\.com\/video\/?\?vid=(\d+)/i + ], + + mixins: [ + "*" + ], + + getLink: function(urlMatch, cheerio) { + + var $el = cheerio('.platformPlayer'); + var player = JSON.parse($el.attr('data-player-config')); + + if (player.share_embed && player.releaseURL) { + return { + href: '//player.foxfdm.com/sports/embed-iframe.html?videourl=' + player.releaseURL, + rel: [CONFIG.R.player, CONFIG.R.autoplay, CONFIG.R.html5], + type: CONFIG.T.text_html, + 'aspect-ratio': 640 / 360 + } + } + }, + + tests: [ + "http://www.foxsports.com/video?vid=551579203750" + ] +}; From 4d5984ad156dfb355f5727290356eafb3e719b1b Mon Sep 17 00:00:00 2001 From: Ivan Paramonau Date: Sat, 16 Jan 2016 09:31:55 -0500 Subject: [PATCH 064/320] [domains] some more URLs for foxsports --- plugins/domains/foxsports.com.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/plugins/domains/foxsports.com.js b/plugins/domains/foxsports.com.js index 858d944f0..2b5984197 100644 --- a/plugins/domains/foxsports.com.js +++ b/plugins/domains/foxsports.com.js @@ -1,7 +1,7 @@ module.exports = { re: [ - /^https?:\/\/www\.foxsports\.com\/video\/?\?vid=(\d+)/i + /^https?:\/\/www\.foxsports\.com\/(?:\w+\/)?video\/?\?vid=(\d+)/i ], mixins: [ @@ -24,6 +24,7 @@ module.exports = { }, tests: [ - "http://www.foxsports.com/video?vid=551579203750" + "http://www.foxsports.com/video?vid=551579203750", + "http://www.foxsports.com/mlb/video?vid=602673731627" ] }; From b079550d06015d605f707ba9eda4a353b17d895d Mon Sep 17 00:00:00 2001 From: Ivan Paramonau Date: Mon, 18 Jan 2016 11:49:30 -0500 Subject: [PATCH 065/320] [general] better media detector for /video/ urls --- plugins/meta/date.js | 2 +- plugins/meta/media-detector.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/meta/date.js b/plugins/meta/date.js index 117c63e50..b02377d4b 100644 --- a/plugins/meta/date.js +++ b/plugins/meta/date.js @@ -2,7 +2,7 @@ module.exports = { getMeta: function(meta, url) { - var date = meta.date || meta.pubdate || meta.lastmod || (meta.article && meta.article.published_time) || meta['last-modified']; + var date = meta.date || meta.pubdate || meta.lastmod || (meta.article && meta.article.published_time) || meta['last-modified'] || meta.timestamp; // Can be multiple dates. if (date && date instanceof Array) { diff --git a/plugins/meta/media-detector.js b/plugins/meta/media-detector.js index 6bab01a90..bca43b6ae 100644 --- a/plugins/meta/media-detector.js +++ b/plugins/meta/media-detector.js @@ -8,7 +8,7 @@ module.exports = { if (meta.og) { - if ((meta.og.video && !meta.og.type )|| (meta.og.type && typeof meta.og.type === 'string' && meta.og.type.match(/video|movie/i) || /\/(video|videos)\//i.test(url))) { + if ((meta.og.video && !meta.og.type )|| (meta.og.type && typeof meta.og.type === 'string' && meta.og.type.match(/video|movie/i)) || /\/videos?\//i.test(url)) { has_player = true; } From 8b04a232b29e45e99f7f9bbec0c0301fdc5ad256 Mon Sep 17 00:00:00 2001 From: Ivan Paramonau Date: Mon, 18 Jan 2016 11:53:55 -0500 Subject: [PATCH 066/320] [youtube] detect when embeds are not allowed --- plugins/domains/youtube.com/youtube.video.js | 33 +++++++++++++------- 1 file changed, 21 insertions(+), 12 deletions(-) diff --git a/plugins/domains/youtube.com/youtube.video.js b/plugins/domains/youtube.com/youtube.video.js index 55ae6dcb3..465e14849 100644 --- a/plugins/domains/youtube.com/youtube.video.js +++ b/plugins/domains/youtube.com/youtube.video.js @@ -24,7 +24,7 @@ module.exports = { return cb (new Error ("No youtube.api_key configured")); } - var statsUri = "https://www.googleapis.com/youtube/v3/videos?part=id%2Csnippet%2Cstatistics%2CcontentDetails%2Cplayer&key=" + api_key + "&id=" + urlMatch[1]; + var statsUri = "https://www.googleapis.com/youtube/v3/videos?part=id%2Csnippet%2Cstatistics%2CcontentDetails%2Cplayer%2Cstatus&key=" + api_key + "&id=" + urlMatch[1]; request({ uri: statsUri, @@ -67,7 +67,8 @@ module.exports = { viewCount: entry.statistics && entry.statistics.viewCount, hd: entry.contentDetails && entry.contentDetails.definition == "hd", - playerHtml: entry.player && entry.player.embedHtml + playerHtml: entry.player && entry.player.embedHtml, + embeddable: entry.status ? entry.status.embeddable : true }; if (entry.snippet && entry.snippet.thumbnails ) { @@ -105,6 +106,7 @@ module.exports = { likes: youtube_video_gdata.likeCount, dislikes: youtube_video_gdata.dislikeCount, views: youtube_video_gdata.viewCount, + media: 'player', site: "YouTube" }; }, @@ -161,16 +163,6 @@ module.exports = { var links = [{ - href: 'https://www.youtube.com/embed/' + youtube_video_gdata.id + params, - rel: [CONFIG.R.player, CONFIG.R.html5], - type: CONFIG.T.text_html, - "aspect-ratio": widescreen ? 16 / 9 : 4 / 3 - }, { - href: 'https://www.youtube.com/embed/' + youtube_video_gdata.id + autoplay, - rel: [CONFIG.R.player, CONFIG.R.html5, CONFIG.R.autoplay], - type: CONFIG.T.text_html, - "aspect-ratio": widescreen ? 16 / 9 : 4 / 3 - }, { href: youtube_video_gdata.thumbnails.mq && youtube_video_gdata.thumbnails.mq.url, rel: CONFIG.R.thumbnail, type: CONFIG.T.image_jpeg, @@ -178,6 +170,22 @@ module.exports = { height: 180 }]; + if (youtube_video_gdata.embeddable) { + links.push({ + href: 'https://www.youtube.com/embed/' + youtube_video_gdata.id + params, + rel: [CONFIG.R.player, CONFIG.R.html5], + type: CONFIG.T.text_html, + "aspect-ratio": widescreen ? 16 / 9 : 4 / 3 + }); + + links.push({ + href: 'https://www.youtube.com/embed/' + youtube_video_gdata.id + autoplay, + rel: [CONFIG.R.player, CONFIG.R.html5, CONFIG.R.autoplay], + type: CONFIG.T.text_html, + "aspect-ratio": widescreen ? 16 / 9 : 4 / 3 + }); + } + if (youtube_video_gdata.thumbnails.maxres) { links.push({ href: youtube_video_gdata.thumbnails.maxres.url, @@ -208,5 +216,6 @@ module.exports = { }, "http://www.youtube.com/watch?v=etDRmrB9Css", "http://www.youtube.com/embed/Q_uaI28LGJk" + // embeds disabled - https://www.youtube.com/watch?v=e58FeKOgsU8 ] }; From a16dac2a35543ead681c5448a280da625c7c2f67 Mon Sep 17 00:00:00 2001 From: Ivan Paramonau Date: Mon, 18 Jan 2016 12:04:13 -0500 Subject: [PATCH 067/320] [core] allow new and custom request cache keys (unique) + cache migration --- lib/request.js | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/lib/request.js b/lib/request.js index f6a6f8a35..15c8ef5c9 100644 --- a/lib/request.js +++ b/lib/request.js @@ -35,14 +35,18 @@ module.exports = function(options, callback) { var prepareResult = options.prepareResult; var useCacheOnly = options.useCacheOnly; var ttl = options.ttl; + var cache_key = options.cache_key; + var new_cache_key = options.new_cache_key; // this is to allow temp migration delete options.prepareData; delete options.useCacheOnly; delete options.ttl; + delete options.cache_key; + delete options.new_cache_key; var prefix = CONFIG.API_REQUEST_CACHE_PREFIX ? (CONFIG.API_REQUEST_CACHE_PREFIX + ':') : ''; - var key = 'req:' + prefix + hash(JSON.stringify(options)); + var key = 'req:' + prefix + (cache_key || hash(JSON.stringify(options))); cache.get(key, function(error, data) { @@ -72,6 +76,19 @@ module.exports = function(options, callback) { }, { ttl: ttl || CONFIG.API_REQUEST_CACHE_TTL }); + + // temp cache migration, set new key as well + if (new_cache_key) { + cache.set('req:' + prefix + new_cache_key, { + response: { + statusCode: response && response.statusCode, + headers: response.headers + }, + data: data + }, { + ttl: ttl || CONFIG.API_REQUEST_CACHE_TTL + }); + } } // Send prepared data up. From 74dba1db754513cef87df6a875fa2d026ae2db77 Mon Sep 17 00:00:00 2001 From: Ivan Paramonau Date: Mon, 18 Jan 2016 12:04:44 -0500 Subject: [PATCH 068/320] [youtube] move youtube to new custom cache key --- plugins/domains/youtube.com/youtube.video.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/plugins/domains/youtube.com/youtube.video.js b/plugins/domains/youtube.com/youtube.video.js index 465e14849..40c9aa76e 100644 --- a/plugins/domains/youtube.com/youtube.video.js +++ b/plugins/domains/youtube.com/youtube.video.js @@ -28,6 +28,8 @@ module.exports = { request({ uri: statsUri, + cache_key: "https://www.googleapis.com/youtube/v3/videos?part=id%2Csnippet%2Cstatistics%2CcontentDetails%2Cplayer&key=" + api_key + "&id=" + urlMatch[1], + new_cache_key: "youtube:" + urlMatch[1], json: true, prepareResult: function(error, b, data, cb) { From ed1fe2cda61bcbcbf8623ad68e5f0b981e2df3a9 Mon Sep 17 00:00:00 2001 From: Ivan Paramonau Date: Mon, 18 Jan 2016 12:18:01 -0500 Subject: [PATCH 069/320] [migrate keys] fix older yt cache key --- plugins/domains/youtube.com/youtube.video.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/plugins/domains/youtube.com/youtube.video.js b/plugins/domains/youtube.com/youtube.video.js index 40c9aa76e..5c86a1280 100644 --- a/plugins/domains/youtube.com/youtube.video.js +++ b/plugins/domains/youtube.com/youtube.video.js @@ -1,4 +1,5 @@ var cheerio = require('cheerio'); +var crypto = require('crypto'); // temp module.exports = { @@ -26,10 +27,15 @@ module.exports = { var statsUri = "https://www.googleapis.com/youtube/v3/videos?part=id%2Csnippet%2Cstatistics%2CcontentDetails%2Cplayer%2Cstatus&key=" + api_key + "&id=" + urlMatch[1]; + var cache_key = '"' + crypto.createHash('md5').update(JSON.stringify({ + uri: "https://www.googleapis.com/youtube/v3/videos?part=id%2Csnippet%2Cstatistics%2CcontentDetails%2Cplayer&key=" + api_key + "&id=" + urlMatch[1], //old_one + json: true + })).digest("hex") + '"'; + request({ uri: statsUri, - cache_key: "https://www.googleapis.com/youtube/v3/videos?part=id%2Csnippet%2Cstatistics%2CcontentDetails%2Cplayer&key=" + api_key + "&id=" + urlMatch[1], - new_cache_key: "youtube:" + urlMatch[1], + cache_key: cache_key, + new_cache_key: "youtube:gdata:" + urlMatch[1], json: true, prepareResult: function(error, b, data, cb) { From 3ef146558df57e97a7f4f8480d070b84297f2911 Mon Sep 17 00:00:00 2001 From: Ivan Paramonau Date: Mon, 18 Jan 2016 12:23:56 -0500 Subject: [PATCH 070/320] [migrate keys] simple cache key for Twitter oEmbed --- plugins/domains/twitter.status.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/plugins/domains/twitter.status.js b/plugins/domains/twitter.status.js index 87781039a..9193db47e 100644 --- a/plugins/domains/twitter.status.js +++ b/plugins/domains/twitter.status.js @@ -2,6 +2,7 @@ var async = require('async'); var cache = require('../../lib/cache'); var sysUtils = require('../../logging'); var _ = require('underscore'); +var crypto = require('crypto'); // temp module.exports = { @@ -59,12 +60,22 @@ module.exports = { omit_script: c.omit_script }; + var cache_key = '"' + crypto.createHash('md5').update(JSON.stringify({ + url: 'https://api.twitter.com/1.1/statuses/oembed.json', + qs: qs, + oauth: oauth, + json: true + })).digest("hex") + '"'; + + request({ url: url, qs: qs, oauth: oauth, json: true, useCacheOnly: blockExpireIn > 0, + cache_key: cache_key, + new_cache_key: 'twitter:oembed:' + id, ttl: c.cache_ttl, prepareResult: function(error, response, data, cb) { From a10d7f05f0b997f455e7b1ebd6d34ee81955dfb6 Mon Sep 17 00:00:00 2001 From: Ivan Paramonau Date: Mon, 18 Jan 2016 14:23:39 -0500 Subject: [PATCH 071/320] [twitter] if API is blocked - fallback to oembed 1.0 rather than generic parsers --- plugins/domains/twitter.status.js | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/plugins/domains/twitter.status.js b/plugins/domains/twitter.status.js index 9193db47e..0c35be9cf 100644 --- a/plugins/domains/twitter.status.js +++ b/plugins/domains/twitter.status.js @@ -51,7 +51,7 @@ module.exports = { oembed: function(cb) { - var url = "https://api.twitter.com/1.1/statuses/oembed.json"; + var url = "https://api.twitter.com/1" + (blockExpireIn > 0 ? "" : ".1") + "/statuses/oembed.json"; var qs = { id: id, @@ -68,12 +68,10 @@ module.exports = { })).digest("hex") + '"'; - request({ + request(_.extend({ url: url, - qs: qs, - oauth: oauth, + qs: qs, json: true, - useCacheOnly: blockExpireIn > 0, cache_key: cache_key, new_cache_key: 'twitter:oembed:' + id, ttl: c.cache_ttl, @@ -115,7 +113,7 @@ module.exports = { } // Store expire date as value to be sure it past. - var expireIn = now + ttl; + var expireIn = now + ttl; cache.set(block_key, expireIn, {ttl: ttl}); } @@ -129,9 +127,10 @@ module.exports = { return cb('Object expected in Twitter API (statuses/oembed.json), got: ' + data); } + cb(error, data); } - }, cb); + }, (blockExpireIn > 0 ? null : {oauth: oauth})), cb); // add oauth if 1.1, else skip it }, post: function(cb) { @@ -181,10 +180,6 @@ module.exports = { ], function(error, data) { - if (error === 'no-cache') { - sysUtils.log(' -- Twitter API limit reached, plugin temporary disabled for ' + blockExpireIn + ' seconds.'); - return cb('Twitter API limit reached, wait ' + blockExpireIn + ' seconds.'); - } if (error) { return cb(error); From 1ec2c8c04f8257b14b71b53fb5cf810375442781 Mon Sep 17 00:00:00 2001 From: Nazar Leush Date: Mon, 18 Jan 2016 22:35:16 +0200 Subject: [PATCH 072/320] [domains] twitter: get is_video from og --- plugins/domains/twitter.status.js | 190 +++++++++++------------------- 1 file changed, 68 insertions(+), 122 deletions(-) diff --git a/plugins/domains/twitter.status.js b/plugins/domains/twitter.status.js index 0c35be9cf..9e45d2ecf 100644 --- a/plugins/domains/twitter.status.js +++ b/plugins/domains/twitter.status.js @@ -14,7 +14,7 @@ module.exports = { mixins: ['domain-icon'], - getData: function(urlMatch, request, options, cb) { + getData: function(urlMatch, og, request, options, cb) { var id = urlMatch[1]; var c = options.getProviderOptions("twitter") || options.getProviderOptions("twitter.status"); @@ -47,156 +47,102 @@ module.exports = { } } - async.parallel({ - - oembed: function(cb) { - - var url = "https://api.twitter.com/1" + (blockExpireIn > 0 ? "" : ".1") + "/statuses/oembed.json"; - - var qs = { - id: id, - hide_media: c.hide_media, - hide_thread: c.hide_thread, - omit_script: c.omit_script - }; - - var cache_key = '"' + crypto.createHash('md5').update(JSON.stringify({ - url: 'https://api.twitter.com/1.1/statuses/oembed.json', - qs: qs, - oauth: oauth, - json: true - })).digest("hex") + '"'; - - - request(_.extend({ - url: url, - qs: qs, - json: true, - cache_key: cache_key, - new_cache_key: 'twitter:oembed:' + id, - ttl: c.cache_ttl, - prepareResult: function(error, response, data, cb) { - - if (response.fromRequestCache) { - if (blockExpireIn > 0) { - sysUtils.log(' -- Twitter API limit reached (' + blockExpireIn + ' seconds left), but cache used.'); - } else { - sysUtils.log(' -- Twitter API cache used.'); - } - } - - // Do not block api if data from cache. - if (!response.fromRequestCache) { - - var remaining = parseInt(response.headers['x-rate-limit-remaining']); - - if (response.statusCode === 429 || remaining <= 7) { - var now = Math.round(new Date().getTime() / 1000); - var limitResetAt = parseInt(response.headers['x-rate-limit-reset']); - var ttl = limitResetAt - now; - - // Do not allow ttl 0. - // 5 seconds - to cover possible time difference with twitter. - if (ttl < 5) { - ttl = 5; - } + var url = "https://api.twitter.com/1" + (blockExpireIn > 0 ? "" : ".1") + "/statuses/oembed.json"; + + var qs = { + id: id, + hide_media: c.hide_media, + hide_thread: c.hide_thread, + omit_script: c.omit_script + }; + + var cache_key = '"' + crypto.createHash('md5').update(JSON.stringify({ + url: 'https://api.twitter.com/1.1/statuses/oembed.json', + qs: qs, + oauth: oauth, + json: true + })).digest("hex") + '"'; + + + request(_.extend({ + url: url, + qs: qs, + json: true, + cache_key: cache_key, + new_cache_key: 'twitter:oembed:' + id, + ttl: c.cache_ttl, + prepareResult: function(error, response, data, cb) { + + if (response.fromRequestCache) { + if (blockExpireIn > 0) { + sysUtils.log(' -- Twitter API limit reached (' + blockExpireIn + ' seconds left), but cache used.'); + } else { + sysUtils.log(' -- Twitter API cache used.'); + } + } - // Block maximum for 15 minutes. - if (ttl > 15*60) { - ttl = 15*60 - } + // Do not block api if data from cache. + if (!response.fromRequestCache) { - if (response.statusCode === 429) { - sysUtils.log(' -- Twitter API limit reached by status code 429. Disabling for ' + ttl + ' seconds.'); - } else { - sysUtils.log(' -- Twitter API limit warning, remaining calls: ' + remaining + '. Disabling for ' + ttl + ' seconds.'); - } + var remaining = parseInt(response.headers['x-rate-limit-remaining']); - // Store expire date as value to be sure it past. - var expireIn = now + ttl; + if (response.statusCode === 429 || remaining <= 7) { + var now = Math.round(new Date().getTime() / 1000); + var limitResetAt = parseInt(response.headers['x-rate-limit-reset']); + var ttl = limitResetAt - now; - cache.set(block_key, expireIn, {ttl: ttl}); - } + // Do not allow ttl 0. + // 5 seconds - to cover possible time difference with twitter. + if (ttl < 5) { + ttl = 5; } - if (response.statusCode !== 200) { - return cb('Non-200 response from Twitter API (statuses/oembed.json: ' + response.statusCode); + // Block maximum for 15 minutes. + if (ttl > 15*60) { + ttl = 15*60 } - if (typeof data !== 'object') { - return cb('Object expected in Twitter API (statuses/oembed.json), got: ' + data); + if (response.statusCode === 429) { + sysUtils.log(' -- Twitter API limit reached by status code 429. Disabling for ' + ttl + ' seconds.'); + } else { + sysUtils.log(' -- Twitter API limit warning, remaining calls: ' + remaining + '. Disabling for ' + ttl + ' seconds.'); } + // Store expire date as value to be sure it past. + var expireIn = now + ttl; - cb(error, data); + cache.set(block_key, expireIn, {ttl: ttl}); } - }, (blockExpireIn > 0 ? null : {oauth: oauth})), cb); // add oauth if 1.1, else skip it - }, - - post: function(cb) { - - var show_video = c.media_only; - - if (show_video) { - - var url = "https://api.twitter.com/1.1/statuses/show.json"; - - var qs = { - id: id - }; - - request({ - url: url, - qs: qs, - oauth: oauth, - json: true, - useCacheOnly: blockExpireIn > 0, - prepareResult: function(error, response, data, cb) { - - if (response.statusCode !== 200) { - return cb('Non-200 response from Twitter API (statuses/show.json): ' + response.statusCode); - } + } - if (typeof data !== 'object') { - return cb('Object expected in Twitter API (statuses/show.json), got: ' + data); - } + if (response.statusCode !== 200) { + return cb('Non-200 response from Twitter API (statuses/oembed.json: ' + response.statusCode); + } - var is_video = !!_.find(data.extended_entities && data.extended_entities.media, function(m) { - return m.video_info && m.type === "video"; - }); + if (typeof data !== 'object') { + return cb('Object expected in Twitter API (statuses/oembed.json), got: ' + data); + } - cb(error, { - is_video: is_video - }); - } - }, cb); - } else { - cb(null, null); - } + cb(error, data); } - }, cb); + }, (blockExpireIn > 0 ? null : {oauth: oauth})), cb); // add oauth if 1.1, else skip it + } - ], function(error, data) { + ], function(error, oembed) { if (error) { return cb(error); } - // Oembed. - - var oembed = data.oembed; - oembed.title = oembed.author_name + ' on Twitter'; oembed["min-width"] = c["min-width"]; oembed["max-width"] = c["max-width"]; - - // Post data. - - oembed.is_video = data.post && data.post.is_video; + + oembed.is_video = og.type === 'video'; cb(null, { twitter_oembed: oembed From f1f091f786bb55c680042d23e8dd58d8673bf7c8 Mon Sep 17 00:00:00 2001 From: Ivan Paramonau Date: Mon, 18 Jan 2016 16:01:36 -0500 Subject: [PATCH 073/320] better case for twitter video --- plugins/domains/twitter.status.js | 43 +++++++++++++------------------ plugins/domains/twitter.video.js | 15 +++++++++++ 2 files changed, 33 insertions(+), 25 deletions(-) create mode 100644 plugins/domains/twitter.video.js diff --git a/plugins/domains/twitter.status.js b/plugins/domains/twitter.status.js index 9e45d2ecf..6052d4f9c 100644 --- a/plugins/domains/twitter.status.js +++ b/plugins/domains/twitter.status.js @@ -10,11 +10,11 @@ module.exports = { /^https?:\/\/twitter\.com\/(?:\w+)\/status(?:es)?\/(\d+)/i ], - provides: 'twitter_oembed', + provides: ['twitter_oembed', 'twitter_video', '__allow_twitter_video'], mixins: ['domain-icon'], - getData: function(urlMatch, og, request, options, cb) { + getData: function(urlMatch, request, options, cb) { var id = urlMatch[1]; var c = options.getProviderOptions("twitter") || options.getProviderOptions("twitter.status"); @@ -141,12 +141,18 @@ module.exports = { oembed["min-width"] = c["min-width"]; oembed["max-width"] = c["max-width"]; - - oembed.is_video = og.type === 'video'; - cb(null, { - twitter_oembed: oembed - }); + var result = { + twitter_oembed: oembed, + }; + + if (c.media_only) { + result.__allow_twitter_video = true; + } else { + result.twitter_video = false; + } + + cb(null, result); }); }, @@ -161,7 +167,7 @@ module.exports = { }; }, - getLink: function(twitter_oembed, options) { + getLink: function(twitter_oembed, twitter_video, options) { var html = twitter_oembed.html; @@ -171,15 +177,14 @@ module.exports = { var links = []; - if (twitter_oembed.is_video) { + if (twitter_video) { html = html.replace(/class="twitter-tweet"/g, 'class="twitter-video"'); links.push({ html: html, type: CONFIG.T.text_html, - rel: [CONFIG.R.oembed, CONFIG.R.player, CONFIG.R.inline, CONFIG.R.ssl], - "min-width": twitter_oembed["min-width"], - "max-width": twitter_oembed["max-width"] + rel: [CONFIG.R.player, CONFIG.R.inline, CONFIG.R.ssl, CONFIG.R.html5], + "aspect-ratio": twitter_video.width / twitter_video.height }); } else { @@ -187,24 +192,12 @@ module.exports = { links.push({ html: html, type: CONFIG.T.text_html, - rel: [CONFIG.R.oembed, CONFIG.R.app, CONFIG.R.inline, CONFIG.R.ssl], + rel: [CONFIG.R.app, CONFIG.R.inline, CONFIG.R.ssl, CONFIG.R.html5], "min-width": twitter_oembed["min-width"], "max-width": twitter_oembed["max-width"] }); } - - /* - // forget about image for now - it takes 500 ms to verify its size - if (og.image && og.image.user_generated) { - links.push({ - href: og.image.url, - type: CONFIG.T.image, - rel: [CONFIG.R.image] - }); - } - */ - return links; }, diff --git a/plugins/domains/twitter.video.js b/plugins/domains/twitter.video.js new file mode 100644 index 000000000..aa74a52ba --- /dev/null +++ b/plugins/domains/twitter.video.js @@ -0,0 +1,15 @@ +module.exports = { + + re: [ + /^https?:\/\/twitter\.com\/(?:\w+)\/status(?:es)?\/(\d+)/i + ], + + provides: ['twitter_video'], + + getData: function(__allow_twitter_video, og) { + + return { + twitter_video: og.video || false + } + } +}; \ No newline at end of file From 7d28e0ae7f869ad09330125c4bb8a418eea80e83 Mon Sep 17 00:00:00 2001 From: Nazar Leush Date: Tue, 19 Jan 2016 14:16:04 +0200 Subject: [PATCH 074/320] [iframely.js] change default aspect ratio to 16/9 --- lib/html-utils.js | 2 +- static/js/iframely.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/html-utils.js b/lib/html-utils.js index d578cf024..9c181c61e 100644 --- a/lib/html-utils.js +++ b/lib/html-utils.js @@ -28,7 +28,7 @@ // Default aspect ratio. if (!media || (!media.height && !media["aspect-ratio"])) { - $container.css('padding-bottom', '75%'); + $container.css('padding-bottom', '56.25%'); } if (media) { diff --git a/static/js/iframely.js b/static/js/iframely.js index 9f4b0380e..0d63e187e 100644 --- a/static/js/iframely.js +++ b/static/js/iframely.js @@ -228,7 +228,7 @@ // Default aspect ratio. if (!media || (!media.height && !media["aspect-ratio"])) { - $container.css('padding-bottom', '75%'); + $container.css('padding-bottom', '56.25%'); } if (media) { From 1c12cdf74567d697a6f03a20c1ce07ace45a58be Mon Sep 17 00:00:00 2001 From: Nazar Leush Date: Wed, 20 Jan 2016 19:57:22 +0200 Subject: [PATCH 075/320] [cache] store request cache from old key to new key --- lib/request.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/request.js b/lib/request.js index 15c8ef5c9..3723ec710 100644 --- a/lib/request.js +++ b/lib/request.js @@ -55,6 +55,12 @@ module.exports = function(options, callback) { // Send cached data up. prepareResult(null, _.extend(data.response, {fromRequestCache: true}), data.data, callback); + if (new_cache_key) { + cache.set('req:' + prefix + new_cache_key, data, { + ttl: ttl || CONFIG.API_REQUEST_CACHE_TTL + }); + } + } else if (useCacheOnly) { callback('no-cache'); From af9486189d65671c2d546a927bf0d2690f75847b Mon Sep 17 00:00:00 2001 From: Ivan Paramonau Date: Thu, 21 Jan 2016 09:20:39 -0500 Subject: [PATCH 076/320] [domains] good-bye Rdio --- plugins/domains/rdio.com.js | 47 ------------------------------------- 1 file changed, 47 deletions(-) delete mode 100644 plugins/domains/rdio.com.js diff --git a/plugins/domains/rdio.com.js b/plugins/domains/rdio.com.js deleted file mode 100644 index 19d438d2c..000000000 --- a/plugins/domains/rdio.com.js +++ /dev/null @@ -1,47 +0,0 @@ -var $ = require('cheerio'); - -module.exports = { - - mixins: [ - "oembed-title", - "oembed-site" - ], - - getLink: function(oembed) { - - var $container = $('
'); - try { - $container.html(oembed.html); - } catch(ex) {} - - var $iframe = $container.find('iframe'); - var player; - - if ($iframe.length == 1) { - player = { - href: $iframe.attr('src'), - type: CONFIG.T.text_html, - rel: [CONFIG.R.player, CONFIG.R.html5], - "min-width": oembed.width, - "min-height": oembed.height - } - } - - return [player, { - }, { - href: oembed.thumbnail_url, - type: CONFIG.T.image, - rel: CONFIG.R.thumbnail, - width: oembed.thumbnail_width, - height: oembed.thumbnail_height - }, { - href: '//www.rdio.com/favicon.ico', - type: CONFIG.T.image, - rel: CONFIG.R.icon - }]; - }, - - tests: [ - "http://www.rdio.com/artist/Big_Boi/album/Vicious_Lies_and_Dangerous_Rumors_(Deluxe_Explicit_Version)/track/CPU/" - ] -}; \ No newline at end of file From ede01b187182b3c8360ec2005f7b4c5bd5f658ef Mon Sep 17 00:00:00 2001 From: Ivan Paramonau Date: Fri, 22 Jan 2016 13:09:02 -0500 Subject: [PATCH 077/320] [domains] support for imgur topic pages --- plugins/domains/imgur.com.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/plugins/domains/imgur.com.js b/plugins/domains/imgur.com.js index a1d296a61..81e9e9f84 100644 --- a/plugins/domains/imgur.com.js +++ b/plugins/domains/imgur.com.js @@ -1,6 +1,9 @@ module.exports = { - re: /https?:\/\/imgur\.com\/(?:\w+\/)?(\w+).*/i, + re: [ + /https?:\/\/imgur\.com\/t\/\w+\/(\w+).*/i, + /https?:\/\/imgur\.com\/(?:\w+\/)?(\w+).*/i + ], provides: ["oembedLinks"], @@ -64,6 +67,8 @@ module.exports = { // "http://imgur.com/r/aww/tFKv2zQ", // kitten bomb before, doesn't seem to show up any longer "http://imgur.com/gallery/bSE9nTM", "http://imgur.com/gallery/EqmEsJj", - "https://imgur.com/gallery/kkEzJsa" + "https://imgur.com/gallery/kkEzJsa", + "http://imgur.com/t/workout/HFwjGoF", + "http://imgur.com/t/water/ud7YwQp" ] }; \ No newline at end of file From 6d9bfb0c731d21783cb594b3958a1abd724748a1 Mon Sep 17 00:00:00 2001 From: Ivan Paramonau Date: Fri, 22 Jan 2016 13:24:44 -0500 Subject: [PATCH 078/320] [general] parsely page type == post doesn't mean it is reader ex. Eurosport --- plugins/meta/parsely_page.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/plugins/meta/parsely_page.js b/plugins/meta/parsely_page.js index 10b399b5f..dc0268449 100644 --- a/plugins/meta/parsely_page.js +++ b/plugins/meta/parsely_page.js @@ -28,8 +28,7 @@ module.exports = { date: parsely_page.pub_date, author: parsely_page.author, keywords: parsely_page.tags && parsely_page.tags instanceof Array ? parsely_page.tags.join(', ') : null, - category: parsely_page.section, - media: parsely_page.type == "post" ? 'reader': null + category: parsely_page.section }; } }; \ No newline at end of file From 428bc635b7ee40eacd2b7a3697dd4e3f08a43a7f Mon Sep 17 00:00:00 2001 From: Ivan Paramonau Date: Sat, 23 Jan 2016 14:38:23 -0500 Subject: [PATCH 079/320] [domains] better fix for fb profiles/pages --- lib/plugins/system/oembed/providers.json | 7 ------- plugins/domains/facebook.com/facebook.page.js | 6 ++++-- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/lib/plugins/system/oembed/providers.json b/lib/plugins/system/oembed/providers.json index f18cfb569..d75cd9263 100644 --- a/lib/plugins/system/oembed/providers.json +++ b/lib/plugins/system/oembed/providers.json @@ -22,13 +22,6 @@ ], "endpoint": "https://www.facebook.com/plugins/video/oembed.json/" }, - { - "name": "Facebook Page", - "templates": [ - "(www|m)\\.facebook\\.com/([a-zA-Z0-9\\.\\-]+)/?(?:\\?f?ref=\\w+)?$" - ], - "endpoint": "https://www.facebook.com/plugins/page/oembed.json/" - }, { "name": "Blip", "templates": [ diff --git a/plugins/domains/facebook.com/facebook.page.js b/plugins/domains/facebook.com/facebook.page.js index 2215522f0..17497ddb0 100644 --- a/plugins/domains/facebook.com/facebook.page.js +++ b/plugins/domains/facebook.com/facebook.page.js @@ -5,12 +5,14 @@ module.exports = { /^https?:\/\/(www|m)\.facebook\.com\/([a-zA-Z0-9\.\-]+)\/?(?:\?f?ref=\w+)?$/i ], - getLink: function(meta, oembed, options) { + getLink: function(oembed, options) { // skip user profiles - they can not be embedded + /* if (!meta.al || (meta.al && meta.al.android && meta.al.android.url && /\/profile\//.test(meta.al.android.url))) { return; - } + }*/ + // not required: as of Jan 23, 2016 the private profile do not have oembed discovery link, whereas public pages do. return { type: CONFIG.T.text_html, From 639967b897ea6d8074c1758eaadb1e6c352a611f Mon Sep 17 00:00:00 2001 From: Ivan Paramonau Date: Sun, 24 Jan 2016 08:30:40 -0500 Subject: [PATCH 080/320] [facebook] better fix for exclusion of user profiles --- lib/plugins/system/oembed/providers.json | 7 +++++++ plugins/domains/facebook.com/facebook.page.js | 10 ++++------ 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/lib/plugins/system/oembed/providers.json b/lib/plugins/system/oembed/providers.json index d75cd9263..f18cfb569 100644 --- a/lib/plugins/system/oembed/providers.json +++ b/lib/plugins/system/oembed/providers.json @@ -22,6 +22,13 @@ ], "endpoint": "https://www.facebook.com/plugins/video/oembed.json/" }, + { + "name": "Facebook Page", + "templates": [ + "(www|m)\\.facebook\\.com/([a-zA-Z0-9\\.\\-]+)/?(?:\\?f?ref=\\w+)?$" + ], + "endpoint": "https://www.facebook.com/plugins/page/oembed.json/" + }, { "name": "Blip", "templates": [ diff --git a/plugins/domains/facebook.com/facebook.page.js b/plugins/domains/facebook.com/facebook.page.js index 17497ddb0..388435d53 100644 --- a/plugins/domains/facebook.com/facebook.page.js +++ b/plugins/domains/facebook.com/facebook.page.js @@ -5,14 +5,12 @@ module.exports = { /^https?:\/\/(www|m)\.facebook\.com\/([a-zA-Z0-9\.\-]+)\/?(?:\?f?ref=\w+)?$/i ], - getLink: function(oembed, options) { + getLink: function(oembed, meta, options) { - // skip user profiles - they can not be embedded - /* - if (!meta.al || (meta.al && meta.al.android && meta.al.android.url && /\/profile\//.test(meta.al.android.url))) { + // skip user profiles - they can not be embedded + if ((meta.al && meta.al.android && meta.al.android.url && /\/profile\//.test(meta.al.android.url)) || !/blockquote/.test(oembed.html)) { return; - }*/ - // not required: as of Jan 23, 2016 the private profile do not have oembed discovery link, whereas public pages do. + } return { type: CONFIG.T.text_html, From 6c0ea6b89d720feaf180719e64f1a2b88ead7779 Mon Sep 17 00:00:00 2001 From: Ivan Paramonau Date: Sun, 24 Jan 2016 14:20:37 -0500 Subject: [PATCH 081/320] [domains] better coverage for fox sports --- plugins/domains/foxsports.com.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/plugins/domains/foxsports.com.js b/plugins/domains/foxsports.com.js index 2b5984197..3004d0daf 100644 --- a/plugins/domains/foxsports.com.js +++ b/plugins/domains/foxsports.com.js @@ -1,7 +1,8 @@ module.exports = { re: [ - /^https?:\/\/www\.foxsports\.com\/(?:\w+\/)?video\/?\?vid=(\d+)/i + /^https?:\/\/www\.foxsports\.com\/(?:\w+\/)?video\/?\?vid=(\d+)/i, + /^https?:\/\/www\.foxsports\.com\/(?:\w+\/)?video\/[a-zA-Z-]+\-()/i ], mixins: [ @@ -25,6 +26,7 @@ module.exports = { tests: [ "http://www.foxsports.com/video?vid=551579203750", - "http://www.foxsports.com/mlb/video?vid=602673731627" + "http://www.foxsports.com/mlb/video?vid=602673731627", + "http://www.foxsports.com/mlb/video/scherzer-harper-mock-papelbon-incident-with-handshake-100115?utm_medium=twitter&utm_source=twitterfeed" ] }; From 492ba043125431ccf398e7d2b24ff79c50e99182 Mon Sep 17 00:00:00 2001 From: Ivan Paramonau Date: Sun, 24 Jan 2016 21:23:13 -0500 Subject: [PATCH 082/320] [domains] support for naver tvcast --- plugins/domains/tvcast.naver.com.js | 61 +++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 plugins/domains/tvcast.naver.com.js diff --git a/plugins/domains/tvcast.naver.com.js b/plugins/domains/tvcast.naver.com.js new file mode 100644 index 000000000..573e1de83 --- /dev/null +++ b/plugins/domains/tvcast.naver.com.js @@ -0,0 +1,61 @@ +var cheerio = require('cheerio'); + +module.exports = { + + re: [ + /^https?:\/\/tvcast\.naver\.com\/v\/(\d+)/i + ], + + mixins: ['*'], + + provides: 'naver_html', + + getData: function(urlMatch, meta, request, cb) { + + if (!meta.naver || !meta.naver.video || !meta.naver.video.id) { + return cb (null); + } else { + + request({ + uri: "http://tvcast.naver.com/api/clipShareHtml?videoId=" + meta.naver.video.id, + json: true, + prepareResult: function(error, response, body, cb) { + + if (error) { + return cb(error); + } + cb(null, { + naver_html: body[0] // they return an array + }); + } + }, cb); + } + }, + + getLink: function(naver_html) { + + var $container = cheerio('
'); + try{ + $container.html(naver_html); + } catch(ex) {} + + var $iframe = $container.find('iframe'); + + if ($iframe.length == 1) { + + return { + href: $iframe.attr('src').replace(/isAutoPlay=true/, 'isAutoPlay=false'), + type: CONFIG.T.text_html, + rel: [CONFIG.R.player, CONFIG.R.html5], + "aspect-ratio": $iframe.attr('height') && $iframe.attr('width') ? $iframe.attr('width') / $iframe.attr('height') : CONFIG.DEFAULT_ASPECT_RATIO + }; + } + + }, + + tests: [{ + noFeeds: true + }, + "http://tvcast.naver.com/v/462633" + ] +}; \ No newline at end of file From 6d988519d6540b842c801e2b222b2dc3b1c3708f Mon Sep 17 00:00:00 2001 From: Ivan Paramonau Date: Mon, 25 Jan 2016 09:26:47 -0500 Subject: [PATCH 083/320] [domains] support for bloomberg videos --- plugins/domains/bloomberg.video.js | 55 ++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 plugins/domains/bloomberg.video.js diff --git a/plugins/domains/bloomberg.video.js b/plugins/domains/bloomberg.video.js new file mode 100644 index 000000000..4563cc45c --- /dev/null +++ b/plugins/domains/bloomberg.video.js @@ -0,0 +1,55 @@ +module.exports = { + + re: [ + /^https?:\/\/www\.bloomberg\.com\/news\/videos\/(\d{4}\-\d{2}\-\d{2}\/[a-zA-Z0-9\-]+)/i + ], + + mixins: ['*'], + + provides: 'bmmr', + + getData: function(urlMatch, request, cb) { + + request({ + uri: "http://www.bloomberg.com/api/videos/slug/" + urlMatch[1], + json: true, + prepareResult: function(error, response, body, cb) { + + if (error) { + return cb(error); + } + + var video_id = body.type === 'video' && body.attachments && body.attachments.video && body.attachments.all && body.attachments.all[0] && body.attachments.all[0].type === 'video' + ? body.attachments.all[0].id : null; + + var video = video_id && body.attachments.video [video_id]; + + if (video_id && video) { + cb(null, { + bmmr: video + }); + } else { + cb(null); + } + } + }, cb); + }, + + getLink: function(bmmr) { + + if (bmmr.bmmrId) { + return { + href: 'http://www.bloomberg.com/api/embed/iframe?id=' + bmmr.bmmrId, + type: CONFIG.T.text_html, + rel: [CONFIG.R.player, CONFIG.R.html5], + "aspect-ratio": 16 / 9 + }; + } + }, + + tests: [{ + noFeeds: true + }, + "http://www.bloomberg.com/news/videos/2015-03-05/why-cheap-oil-doesn-t-stop-the-drilling" + ] +}; \ No newline at end of file From 07978fee15442ed5b6e8aa176faa3530ce254e7e Mon Sep 17 00:00:00 2001 From: Ivan Paramonau Date: Mon, 25 Jan 2016 12:54:52 -0500 Subject: [PATCH 084/320] [domains] fix myvideo.de --- plugins/domains/myvideo.de.js | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/plugins/domains/myvideo.de.js b/plugins/domains/myvideo.de.js index 01d527c3e..8606e3eb8 100644 --- a/plugins/domains/myvideo.de.js +++ b/plugins/domains/myvideo.de.js @@ -1,8 +1,8 @@ module.exports = { re: [ - /^https?:\/\/www\.myvideo\.de\/watch\/([0-9]+)/i, - /^https?:\/\/www\.myvideo\.de\/musik\/\w+\/[\w-]+-([0-9]+)/i + /^https?:\/\/www\.myvideo\.de\/watch\/([0-9]+)/i + // the rest should be covered by whitelist via embedURL - it verifies permissions etc ], mixins: ["*"], @@ -10,7 +10,7 @@ module.exports = { getLink: function (urlMatch) { return { - href: "https://www.myvideo.de/embed/"+ urlMatch[1], + href: "http://www.myvideo.de/embedded/public/"+ urlMatch[1], type: CONFIG.T.text_html, rel: CONFIG.R.player, "aspect-ratio": 611 / 383, @@ -18,10 +18,7 @@ module.exports = { } }, - tests: [{ - page: "http://www.myvideo.de/Top_100/Top_100_Charts", - selector: ".chartlist--videolist-item-title" - }, + tests: [ "http://www.myvideo.de/watch/9790416/Balbina_Seife_feat_Maeckes" ] }; \ No newline at end of file From 3092be7f25d5b1be3a66058e2b2a1b3965fc5e68 Mon Sep 17 00:00:00 2001 From: Ivan Paramonau Date: Mon, 25 Jan 2016 15:59:11 -0500 Subject: [PATCH 085/320] [domains] fix media_only config for Imgur --- plugins/domains/500px.com.js | 2 +- plugins/domains/imgur.com.js | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/plugins/domains/500px.com.js b/plugins/domains/500px.com.js index 7abd647b4..d3f1c29b4 100644 --- a/plugins/domains/500px.com.js +++ b/plugins/domains/500px.com.js @@ -1,6 +1,6 @@ module.exports = { - re: /^https:\/\/500px\.com\/photo.+/, + re: /^https?:\/\/500px\.com\/photo.+/, mixins: [ "*", diff --git a/plugins/domains/imgur.com.js b/plugins/domains/imgur.com.js index 81e9e9f84..dad3d8163 100644 --- a/plugins/domains/imgur.com.js +++ b/plugins/domains/imgur.com.js @@ -32,6 +32,14 @@ module.exports = { type: CONFIG.T.text_html, rel: [CONFIG.R.app, CONFIG.R.oembed, CONFIG.R.html5, CONFIG.R.inline, CONFIG.R.ssl] }; + } else { + return { + href: "http://s.imgur.com/images/favicon-96x96.png", + width: 96, + height: 96, + type: CONFIG.T.image_png, + rel: CONFIG.R.icon + } } } }, From 590c9cb2773c08f84630bc5bc9f01402b3723128 Mon Sep 17 00:00:00 2001 From: Nazar Leush Date: Mon, 25 Jan 2016 23:46:08 +0200 Subject: [PATCH 086/320] [lib] fix: Cannot read property 'refresh' of null --- lib/plugins/system/oembed/oembedUtils.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/plugins/system/oembed/oembedUtils.js b/lib/plugins/system/oembed/oembedUtils.js index ef60545e6..3459e0d79 100644 --- a/lib/plugins/system/oembed/oembedUtils.js +++ b/lib/plugins/system/oembed/oembedUtils.js @@ -146,7 +146,7 @@ module.exports.getOembed = function(uri, options, callback) { async.waterfall([ function(cb) { - if (options.refresh) { + if (options && options.refresh) { cb(null, null); } else { cache.get(oembed_key, cb); From e742f9fea825dd852541bd6e10b859ef6d9c23a7 Mon Sep 17 00:00:00 2001 From: Ivan Paramonau Date: Tue, 26 Jan 2016 11:37:38 -0500 Subject: [PATCH 087/320] [domains] minor fixes for Archive, IMDB, giphy --- plugins/domains/archive.org.js | 5 +++-- plugins/domains/cnn.com.js | 2 +- plugins/domains/i.giphy.com.js | 5 +++-- plugins/domains/imdb.com.js | 18 ++++++++++++------ 4 files changed, 19 insertions(+), 11 deletions(-) diff --git a/plugins/domains/archive.org.js b/plugins/domains/archive.org.js index 3c6350dd9..c4c6377ad 100644 --- a/plugins/domains/archive.org.js +++ b/plugins/domains/archive.org.js @@ -24,7 +24,7 @@ module.exports = { } - if (/\.(mp4)$/i.test(player.href)) { + if (/\.(mp4|avi)$/i.test(player.href)) { player["aspect-ratio"] = twitter.player.width / twitter.player.height; } @@ -40,6 +40,7 @@ module.exports = { }, tests: [ - "https://archive.org/details/um2000-09-01.shnf" + "https://archive.org/details/um2000-09-01.shnf", + "https://archive.org/details/ChronoTrigger_456" ] }; \ No newline at end of file diff --git a/plugins/domains/cnn.com.js b/plugins/domains/cnn.com.js index c38ee6fca..79cf75c8f 100644 --- a/plugins/domains/cnn.com.js +++ b/plugins/domains/cnn.com.js @@ -1,7 +1,7 @@ module.exports = { re: [ - /^https?:\/\/(www|edition)\.cnn\.com\/videos\//i, + /^https?:\/\/(www|edition)\.cnn\.com\/videos\//i, ], mixins: [ diff --git a/plugins/domains/i.giphy.com.js b/plugins/domains/i.giphy.com.js index ff6650ab0..c80230ec9 100644 --- a/plugins/domains/i.giphy.com.js +++ b/plugins/domains/i.giphy.com.js @@ -2,8 +2,9 @@ module.exports = { re: [ /https?:\/\/i\.giphy\.com\/(\w+)\.gif(\?.*)?$/i, - /https?:\/\/media\d?\.giphy\.com\/media\/(\w+)\/giphy\.gif$/i, - /https?:\/\/giphy\.com\/gifs\/(\w+)\/html5$/i + /https?:\/\/media\d?\.giphy\.com\/media\/(\w+)\/(?:giphy|\d+)\.gif$/i, + /https?:\/\/giphy\.com\/gifs\/(\w+)\/html5$/i, + /https?:\/\/giphy\.com\/embed\/(\w+)/i ], getLink: function(urlMatch, cb) { diff --git a/plugins/domains/imdb.com.js b/plugins/domains/imdb.com.js index 14c17416c..793897bbf 100644 --- a/plugins/domains/imdb.com.js +++ b/plugins/domains/imdb.com.js @@ -1,7 +1,8 @@ module.exports = { re: [ - /^https?:\/\/www\.imdb\.com\/video\/[\w]+\/vi(\d+)/i + /^https?:\/\/www\.imdb\.com\/video\/[\w]+\/vi(\d+)/i, + /^https?:\/\/www\.imdb\.com\/title\/\w{2}[\d]+\/?[^\/#]+#\w{2}\-vi(\d+)$/i ], mixins: [ @@ -13,7 +14,11 @@ module.exports = { "og-title" ], - getLink: function(urlMatch, options) { + getLink: function(url, urlMatch, options) { + + if (/^https?:\/\/www\.imdb\.com\/video\/screenplay\/vi(\d+)/i.test(url)) { + return; + } var width = options.maxWidth || 480; @@ -22,16 +27,17 @@ module.exports = { } return { - href: "http://www.imdb.com/video/imdb/vi" + urlMatch[1] + "/imdb/embed?autoplay=false&width=" + width, + href: "//www.imdb.com/video/imdb/vi" + urlMatch[1] + "/imdb/embed?autoplay=false&width=" + width, type: CONFIG.T.text_html, rel: [CONFIG.R.player, CONFIG.R.html5], width: width, - height: width / (16/9) + 40 // 40px body margin - }; + height: width / (16/9) + } }, tests: [ "http://www.imdb.com/video/epk/vi1061203225/", - "http://www.imdb.com/video/imdb/vi2792795161?ref_=tt_pv_vi_aiv_2" + "http://www.imdb.com/video/imdb/vi2792795161?ref_=tt_pv_vi_aiv_2", + "http://www.imdb.com/title/tt2937696/?ref_=ext_shr_tw_vi_tt_ov_vi#lb-vi1383576089" ] }; \ No newline at end of file From 0e94f8a604c0c05158269e55ab20b51381b1a5ea Mon Sep 17 00:00:00 2001 From: Ivan Paramonau Date: Tue, 26 Jan 2016 11:49:02 -0500 Subject: [PATCH 088/320] [domains] support for aljazeera america --- plugins/domains/america.aljazeera.com.js | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 plugins/domains/america.aljazeera.com.js diff --git a/plugins/domains/america.aljazeera.com.js b/plugins/domains/america.aljazeera.com.js new file mode 100644 index 000000000..e59a692fa --- /dev/null +++ b/plugins/domains/america.aljazeera.com.js @@ -0,0 +1,22 @@ +module.exports = { + + re: [ + /^https?:\/\/america\.aljazeera\.com(\/watch\/shows\/[\/a-zA-Z0-9-]+)\.html$/i + ], + + mixins: ["*"], + + getLink: function(urlMatch) { + + return { + href: "http://america.aljazeera.com/watch/embed.html/content/ajam" + urlMatch[1], + type: CONFIG.T.text_html, + rel: [CONFIG.R.player, CONFIG.R.html5], + "aspect-ratio": 4 / 3 + }; + }, + + tests: [ + "http://america.aljazeera.com/watch/shows/live-news/2015/12/the-arts-raising-awareness-of-human-rights-abuses.html" + ] +}; \ No newline at end of file From 7a5185fc006127f70e35d4264c84a6288b3bdb10 Mon Sep 17 00:00:00 2001 From: Ivan Paramonau Date: Tue, 26 Jan 2016 12:02:18 -0500 Subject: [PATCH 089/320] [domains] support AOL features --- plugins/domains/features.aol.com.js | 30 +++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 plugins/domains/features.aol.com.js diff --git a/plugins/domains/features.aol.com.js b/plugins/domains/features.aol.com.js new file mode 100644 index 000000000..70e199c2f --- /dev/null +++ b/plugins/domains/features.aol.com.js @@ -0,0 +1,30 @@ +module.exports = { + + re: [ + /^https?:\/\/features\.aol\.com\/video\//i + ], + + mixins: ["*"], + + getLink: function(cheerio) { + + var $feature = cheerio('.feature-info'); + if ($feature.length) { + var playlist = $feature.attr('data-playlist'); + + if (playlist) { + return { + href: "//pshared.5min.com/Scripts/PlayerSeed.js?sid=281&&playList=" + playlist, + type: CONFIG.T.javascript, + rel: [CONFIG.R.player, CONFIG.R.inline, CONFIG.R.html5], + "aspect-ratio": 16 / 9 + + } + } + } + }, + + tests: [ + "http://features.aol.com/video/rescuers-make-shocking-discovery-inside-abandoned-home" + ] +}; \ No newline at end of file From 89f165177e298629f1e7f8f3c8fd15f49e9f2fa9 Mon Sep 17 00:00:00 2001 From: Ivan Paramonau Date: Tue, 26 Jan 2016 12:21:03 -0500 Subject: [PATCH 090/320] [domains] other form of Imgur topics --- plugins/domains/imgur.com.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/plugins/domains/imgur.com.js b/plugins/domains/imgur.com.js index dad3d8163..12afb969e 100644 --- a/plugins/domains/imgur.com.js +++ b/plugins/domains/imgur.com.js @@ -2,7 +2,8 @@ module.exports = { re: [ /https?:\/\/imgur\.com\/t\/\w+\/(\w+).*/i, - /https?:\/\/imgur\.com\/(?:\w+\/)?(\w+).*/i + /https?:\/\/imgur\.com\/topic\/[a-zA-Z0-9\-_&]+\/(\w+).*/i, + /https?:\/\/imgur\.com\/(?:\w+\/)?(\w+).*/i, ], provides: ["oembedLinks"], @@ -77,6 +78,7 @@ module.exports = { "http://imgur.com/gallery/EqmEsJj", "https://imgur.com/gallery/kkEzJsa", "http://imgur.com/t/workout/HFwjGoF", - "http://imgur.com/t/water/ud7YwQp" + "http://imgur.com/t/water/ud7YwQp", + "http://imgur.com/topic/The_Oscars_&_Movies/YFQo6Vl" ] }; \ No newline at end of file From aa1a01e4c09e4a4009e9cd6538b848e2412b5a52 Mon Sep 17 00:00:00 2001 From: Ivan Paramonau Date: Tue, 26 Jan 2016 12:30:01 -0500 Subject: [PATCH 091/320] [domains] fallback for interlude.fm --- lib/plugins/system/oembed/providers.json | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lib/plugins/system/oembed/providers.json b/lib/plugins/system/oembed/providers.json index f18cfb569..6030d22a2 100644 --- a/lib/plugins/system/oembed/providers.json +++ b/lib/plugins/system/oembed/providers.json @@ -459,5 +459,12 @@ "(?:www\\.|m\\.)?reddit\\.com/r/([^\/]+)/comments/([a-zA-Z0-9]+)/([a-zA-Z0-9_]+)/([a-zA-Z0-9]+)" ], "endpoint": "https://www.reddit.com/oembed" + }, + { + "name": "Interlude", + "templates": [ + "interlude.fm/v/([a-zA-Z0-9-]+)" + ], + "endpoint": "https://v.interlude.fm/oembed?vid={1}" } ] \ No newline at end of file From 9a77ac89fa603d5626be26f2864c232a35c7abfd Mon Sep 17 00:00:00 2001 From: Ivan Paramonau Date: Tue, 26 Jan 2016 12:37:29 -0500 Subject: [PATCH 092/320] [instagram] make title/description be consistent with Twitter & FB approach --- plugins/domains/instagram.com.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/plugins/domains/instagram.com.js b/plugins/domains/instagram.com.js index 1c5be47f4..0ecd48c0f 100644 --- a/plugins/domains/instagram.com.js +++ b/plugins/domains/instagram.com.js @@ -7,7 +7,6 @@ module.exports = { ], mixins: [ - "oembed-title", "oembed-site", "oembed-author", "oembed-thumbnail", @@ -15,6 +14,17 @@ module.exports = { "favicon" ], + getMeta: function (og) { + + var match = og.title.match(/[a-zA-Z0-9\s]+on\sInstagram/i); + + return { + title: match ? match[0] : "Post on Instagram", + description: og.description + } + + }, + getLinks: function(urlMatch, meta, oembed, options) { var src = 'http://instagram.com/p/' + urlMatch[1] + '/media/?size='; From 51a05e979fadeaa58492aa61634c64b08b2749f6 Mon Sep 17 00:00:00 2001 From: Ivan Paramonau Date: Tue, 26 Jan 2016 13:01:45 -0500 Subject: [PATCH 093/320] [tests] fix Google favicon --- lib/plugins/validators/async/20_checkFavicon.js | 2 +- lib/utils.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/plugins/validators/async/20_checkFavicon.js b/lib/plugins/validators/async/20_checkFavicon.js index 0bcd03eba..f6f21a8ff 100644 --- a/lib/plugins/validators/async/20_checkFavicon.js +++ b/lib/plugins/validators/async/20_checkFavicon.js @@ -47,7 +47,7 @@ module.exports = { } } - if (data.code == 200 && data.content_length && data.content_length == 0) { + if (data.code == 200 && data.content_length && data.content_length === 0) { link.error = "Image with 0 content_length"; } diff --git a/lib/utils.js b/lib/utils.js index 86de7ff7c..dcb789d1e 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -669,7 +669,7 @@ var getUriStatus = function(uri, options, cb) { cb(null, { code: res.statusCode, content_type: res.headers['content-type'], - content_length: res.headers['content-length'] || '0' + content_length: res.headers['content-length'] ? parseInt(res.headers['content-length'] || '0', 10) : null }); }); }; From b1dc991800d3f6ca593e842a3c173f305be461bf Mon Sep 17 00:00:00 2001 From: Ivan Paramonau Date: Tue, 26 Jan 2016 13:03:16 -0500 Subject: [PATCH 094/320] [domains] not required: Pastie, Screenr and Yandex vid --- plugins/domains/pastie.org.js | 25 ------------------------- plugins/domains/screenr.com.js | 17 ----------------- plugins/domains/video.yandex.ru.js | 21 --------------------- plugins/domains/videos.nymag.com.js | 2 +- 4 files changed, 1 insertion(+), 64 deletions(-) delete mode 100644 plugins/domains/pastie.org.js delete mode 100644 plugins/domains/screenr.com.js delete mode 100644 plugins/domains/video.yandex.ru.js diff --git a/plugins/domains/pastie.org.js b/plugins/domains/pastie.org.js deleted file mode 100644 index 2e8bcde5b..000000000 --- a/plugins/domains/pastie.org.js +++ /dev/null @@ -1,25 +0,0 @@ -module.exports = { - - re: /http:\/\/pastie\.org\/(?:pastes\/)?(\d+)/i, - - mixins: ['domain-icon'], - - getMeta: function(urlMatch) { - return { - title: '#' + urlMatch[1] + ' - Pastie' - }; - }, - - getLink: function(urlMatch) { - return { - html: '', - type: CONFIG.T.text_html, - rel: CONFIG.R.reader // not inline :\ - }; - }, - - tests: [ - "http://pastie.org/807135" - ] - -}; \ No newline at end of file diff --git a/plugins/domains/screenr.com.js b/plugins/domains/screenr.com.js deleted file mode 100644 index ec31535fd..000000000 --- a/plugins/domains/screenr.com.js +++ /dev/null @@ -1,17 +0,0 @@ -module.exports = { - - re: /https?:\/\/www\.screenr\.com\/\w+/i, - - mixins: [ - "oembed-title", - "oembed-thumbnail", - "oembed-author", - "oembed-site", - "oembed-video", - "domain-icon" - ], - - tests: [ - "http://www.screenr.com/e4HH" - ] -}; \ No newline at end of file diff --git a/plugins/domains/video.yandex.ru.js b/plugins/domains/video.yandex.ru.js deleted file mode 100644 index 94d6e3824..000000000 --- a/plugins/domains/video.yandex.ru.js +++ /dev/null @@ -1,21 +0,0 @@ -module.exports = { - - re: [ - /^https?:\/\/video\.yandex\.ru\/users\/[^\/]+\/view\/\d+\//i - ], - - mixins: [ - "oembed-title", - "oembed-thumbnail", - "oembed-author", - "oembed-duration", - "oembed-site", - "oembed-description", - "domain-icon", - "oembed-video" - ], - - tests: [ - "http://video.yandex.ru/users/remnjoff/view/347/" - ] -}; \ No newline at end of file diff --git a/plugins/domains/videos.nymag.com.js b/plugins/domains/videos.nymag.com.js index c209f41f7..f574ec964 100644 --- a/plugins/domains/videos.nymag.com.js +++ b/plugins/domains/videos.nymag.com.js @@ -30,7 +30,7 @@ module.exports = { }, "http://videos.nymag.com/video/Models-Studio-Jourdan-Dunn-2;toprated", { - skipMixins: ["og-description"] + skipMixins: ["og-description", "favicon"] } ] }; \ No newline at end of file From dccc7c1585a4cc302666d09bab82e519932b8d57 Mon Sep 17 00:00:00 2001 From: Nazar Leush Date: Tue, 26 Jan 2016 20:21:57 +0200 Subject: [PATCH 095/320] [core] fix date parsing --- lib/core.js | 4 ++++ lib/utils.js | 20 +++++++++++--------- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/lib/core.js b/lib/core.js index f70545581..f8456166e 100644 --- a/lib/core.js +++ b/lib/core.js @@ -797,6 +797,10 @@ if (key === 'date') { v = utils.unifyDate(v); + if (!v) { + // Disable invalid date. + r.data[key] = v; + } } if (key === 'title' || key === 'canonical') { diff --git a/lib/utils.js b/lib/utils.js index dcb789d1e..8c64c5ea8 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -423,6 +423,10 @@ var NOW = new Date().getTime(); exports.unifyDate = function(date) { + if (typeof date === "string" && date.match(/^\d+$/)) { + date = parseInt(date); + } + if (typeof date === "number") { if (date === 0) { @@ -434,19 +438,17 @@ exports.unifyDate = function(date) { date = date * 1000; } - var parsedDate = moment(date); - if (parsedDate.isValid()) { - return parsedDate.toJSON(); - } + return new Date(date).toISOString(); } // TODO: time in format 'Mon, 29 October 2012 18:15:00' parsed as local timezone anyway. - var parsedDate = moment.utc(date); - - if (parsedDate && parsedDate.isValid()) { - return parsedDate.toJSON(); + var timestamp = Date.parse(date); + if (!isNaN(timestamp)) { + return new Date(timestamp).toISOString(); } - return date; + + // Bad date to parse. + return null; }; From cd204baf6b3d7fc2108920e39a8b5959c067771a Mon Sep 17 00:00:00 2001 From: Ivan Paramonau Date: Tue, 26 Jan 2016 13:47:44 -0500 Subject: [PATCH 096/320] [domains] arte.tv not needed --- plugins/domains/arte.tv.js | 48 -------------------------------------- 1 file changed, 48 deletions(-) delete mode 100644 plugins/domains/arte.tv.js diff --git a/plugins/domains/arte.tv.js b/plugins/domains/arte.tv.js deleted file mode 100644 index a1d0da658..000000000 --- a/plugins/domains/arte.tv.js +++ /dev/null @@ -1,48 +0,0 @@ -var re = /^http:\/\/www\.arte\.tv\/guide\/(\w+)\/([\d-]+)\//i; - -module.exports = { - - re: re, - - mixins: [ - "og-image", - "favicon", - "twitter-author", - "canonical", - "date", - "og-site", - "twitter-title" - ], - - getLink: function(urlMatch) { - return [{ - href: 'http://www.arte.tv/guide/' + urlMatch[1] + '/embed/' + urlMatch[2] + '/small', - type: CONFIG.T.text_html, - rel: CONFIG.R.player, - width: 300, - height: 170 - }, { - href: 'http://www.arte.tv/guide/' + urlMatch[1] + '/embed/' + urlMatch[2] + '/medium', - type: CONFIG.T.text_html, - rel: CONFIG.R.player, - width: 600, - height: 340 - }, { - href: 'http://www.arte.tv/guide/' + urlMatch[1] + '/embed/' + urlMatch[2] + '/large', - type: CONFIG.T.text_html, - rel: CONFIG.R.player, - width: 900, - height: 510 - }] - }, - - tests: [{ - page: 'http://www.arte.tv/guide/de', - selector: 'li a', - getUrl: function(url) { - if (url.match(re)) return url; - } - }, - "http://www.arte.tv/guide/fr/050305-000/valery-giscard-d-estaing-et-helmut-schmidt#details-functions-share" - ] -}; \ No newline at end of file From cc87fffb4fc746de3bf29767fffbaefb3cc6e92b Mon Sep 17 00:00:00 2001 From: Ivan Paramonau Date: Tue, 26 Jan 2016 15:25:06 -0500 Subject: [PATCH 097/320] v 0.9.2 what's new --- WHATSNEW.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/WHATSNEW.md b/WHATSNEW.md index 6f505ff72..081eb034f 100644 --- a/WHATSNEW.md +++ b/WHATSNEW.md @@ -4,6 +4,14 @@ This is the history of the Iframely changes. Updates that are older than one yea Stay tuned, either by watching [Iframely on GitHub](https://github.com/itteco/iframely) or following [Iframely on Twitter](https://twitter.com/iframely). +### 2016.01.26, Version 0.9.2 + + - Domains clean up & maintenance + - Added: Reddit comments, Discovery, amCharts, Buzzfeed videos, Fox Sports, NBC Sports, Aljazeera, Naver tvcast, Cinesports, thumbnails for Amazon products + - Gave better life for `rel=promo`, treat it as attachment media, if you see it + + + ### 2015.12.15, Version 0.9.1 - Critical fix for Instagram From 4ce29403ff0999e516f351582fad702e28706eeb Mon Sep 17 00:00:00 2001 From: Nazar Leush Date: Tue, 26 Jan 2016 22:34:13 +0200 Subject: [PATCH 098/320] update version to 0.9.2 --- package.json | 2 +- static/js/iframely.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 34725c5dc..8402ee20a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "iframely", - "version": "0.9.1", + "version": "0.9.2", "description": "oEmbed/2 gateway endpoint. Get embed data for various http links through one self-hosted API", "keywords": ["oembed", "embed", "open graph", "og", "twitter cards"], diff --git a/static/js/iframely.js b/static/js/iframely.js index 0d63e187e..1f2629d20 100644 --- a/static/js/iframely.js +++ b/static/js/iframely.js @@ -4,7 +4,7 @@ Iframely consumer client lib. - Version 0.8.3 + Version 0.9.2 Fetches and renders iframely oebmed/2 widgets. From 003b346fc2bc7f1041a513155b252eb128bdbbc4 Mon Sep 17 00:00:00 2001 From: Ivan Paramonau Date: Tue, 26 Jan 2016 20:24:49 -0500 Subject: [PATCH 099/320] [domains] broader regex for Bloomberg video --- plugins/domains/bloomberg.video.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/plugins/domains/bloomberg.video.js b/plugins/domains/bloomberg.video.js index 4563cc45c..044482a4b 100644 --- a/plugins/domains/bloomberg.video.js +++ b/plugins/domains/bloomberg.video.js @@ -1,7 +1,9 @@ module.exports = { re: [ - /^https?:\/\/www\.bloomberg\.com\/news\/videos\/(\d{4}\-\d{2}\-\d{2}\/[a-zA-Z0-9\-]+)/i + /^https?:\/\/www\.bloomberg\.com\/news\/videos\/(\d{4}\-\d{2}\-\d{2}\/[a-zA-Z0-9\-]+)/i, + /^https?:\/\/www\.bloomberg\.com\/news\/videos\/(b\/[a-zA-Z0-9-]+)/i, + /^https?:\/\/www\.bloomberg\.com\/video\/([a-zA-Z0-9-]+)\.html$/i ], mixins: ['*'], From 9d9325a14d7b4fd6d72f074635f39451ebbf7af9 Mon Sep 17 00:00:00 2001 From: Ivan Paramonau Date: Tue, 26 Jan 2016 20:25:32 -0500 Subject: [PATCH 100/320] [domains] finally - support for player widget URLs of SoundCloud --- lib/plugins/system/oembed/providers.json | 3 ++- plugins/domains/w.soundcloud.com.js | 20 ++++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 plugins/domains/w.soundcloud.com.js diff --git a/lib/plugins/system/oembed/providers.json b/lib/plugins/system/oembed/providers.json index 6030d22a2..64273fc06 100644 --- a/lib/plugins/system/oembed/providers.json +++ b/lib/plugins/system/oembed/providers.json @@ -222,7 +222,8 @@ { "name": "SoundCloud", "templates": [ - "soundcloud\\.com/.+" + "soundcloud\\.com/.+", + "api\\.soundcloud\\.com\/tracks\\/\\d+" ], "endpoint": "http://soundcloud.com/oembed" }, diff --git a/plugins/domains/w.soundcloud.com.js b/plugins/domains/w.soundcloud.com.js new file mode 100644 index 000000000..c7ccc3282 --- /dev/null +++ b/plugins/domains/w.soundcloud.com.js @@ -0,0 +1,20 @@ +module.exports = { + + re: [ + /^https:?\/\/w\.soundcloud\.com\/player\/?\?\/?url=(https:\/\/api\.soundcloud\.com\/tracks\/\d+)$/i + ], + + getLink: function(urlMatch, cb) { + + cb ({ + redirect: urlMatch[1] + }); + }, + + tests: [{ + noFeeds: true, + + }, + "https://w.soundcloud.com/player/?/url=https://api.soundcloud.com/tracks/212506132" + ] +}; \ No newline at end of file From ed23c20aa84c371013d0cd442a2f26f90212d135 Mon Sep 17 00:00:00 2001 From: Ivan Paramonau Date: Tue, 26 Jan 2016 20:51:26 -0500 Subject: [PATCH 101/320] [domains] better aspect ratio for MSNBC + do not slow down non video pages --- plugins/domains/msnbc.com.js | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 plugins/domains/msnbc.com.js diff --git a/plugins/domains/msnbc.com.js b/plugins/domains/msnbc.com.js new file mode 100644 index 000000000..560c1ed0c --- /dev/null +++ b/plugins/domains/msnbc.com.js @@ -0,0 +1,30 @@ +module.exports = { + + mixins: [ + "*" + ], + + provides: '__allowEmbedURL', + + getData: function(twitter, whitelistRecord) { + + if (twitter.player && whitelistRecord.isAllowed && whitelistRecord.isAllowed('html-meta.embedURL')) { + return { + __allowEmbedURL: true + }; + } + }, + + getLink: function(schemaVideoObject, whitelistRecord) { + return { + href: schemaVideoObject.embedURL || schemaVideoObject.embedUrl, + rel: [CONFIG.R.player, CONFIG.R.html5], + type: CONFIG.T.text_html, + 'aspect-ratio': 4/3 + } + }, + + tests: [ + "http://www.msnbc.com/andrea-mitchell-reports/watch/clinton-emails-take-unwanted-spotlight-410353731888" + ] +}; \ No newline at end of file From 6a5f4e7fc32df1781b3bc9e2d2cf81c4bbda034d Mon Sep 17 00:00:00 2001 From: Ivan Paramonau Date: Tue, 26 Jan 2016 23:41:42 -0500 Subject: [PATCH 102/320] [domains] fix ssl for twitch --- plugins/domains/twitch.tv.js | 39 ++++++++++++++++++++++-------------- 1 file changed, 24 insertions(+), 15 deletions(-) diff --git a/plugins/domains/twitch.tv.js b/plugins/domains/twitch.tv.js index 799c2b4af..711c9244e 100644 --- a/plugins/domains/twitch.tv.js +++ b/plugins/domains/twitch.tv.js @@ -1,25 +1,34 @@ module.exports = { mixins: [ - "og-image", - "favicon", - "og-description", - "og-site", - "og-title" + "*" ], - getLink: function (og) { + getLink: function (og, request, cb) { - if (!(og.video && og.video.secure_url)) { - return; - } + if (og.video && og.video.secure_url) { + + request({ + uri: og.video.secure_url, + followRedirect: false, + prepareResult: function(error, response, body, cb) { + + if (error) { + return cb(error); + } + return cb (null, { + href: response.headers.location ? response.headers.location.replace(/^http/, 'https') : og.video.secure_url, // ssl re-directs to non-ssl. + type: og.video.type, + rel: [CONFIG.R.player, CONFIG.R.autoplay], + "aspect-ratio": og.video.width / og.video.height + }); - return { - href: og.video.secure_url, - type: og.video.type, - rel: [CONFIG.R.player, CONFIG.R.autoplay], - "aspect-ratio": og.video.width / og.video.height - }; + } + }, cb); + + } else { + return cb(null); + } } }; \ No newline at end of file From 6aa22f6d0602ca38b8c596ee89eed3d02f8ef178 Mon Sep 17 00:00:00 2001 From: Ivan Paramonau Date: Tue, 26 Jan 2016 23:45:41 -0500 Subject: [PATCH 103/320] [domains] fix media detector for smugmug --- plugins/domains/smugmug.com.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/plugins/domains/smugmug.com.js b/plugins/domains/smugmug.com.js index 6e15f14ee..a93b7f878 100644 --- a/plugins/domains/smugmug.com.js +++ b/plugins/domains/smugmug.com.js @@ -8,6 +8,16 @@ module.exports = { "*" ], + highestPriority: true, + + getMeta: function (oembed) { + + return { + media: 'player' + } + + }, + getLink: function (oembed) { var links = []; From f1692c1a3c6ef0e338b21817b7f81223a1ada621 Mon Sep 17 00:00:00 2001 From: Ivan Paramonau Date: Wed, 27 Jan 2016 09:56:55 -0500 Subject: [PATCH 104/320] [general] fix the check for broken favicons --- lib/plugins/validators/async/20_checkFavicon.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/plugins/validators/async/20_checkFavicon.js b/lib/plugins/validators/async/20_checkFavicon.js index f6f21a8ff..3dc4d6b45 100644 --- a/lib/plugins/validators/async/20_checkFavicon.js +++ b/lib/plugins/validators/async/20_checkFavicon.js @@ -47,7 +47,7 @@ module.exports = { } } - if (data.code == 200 && data.content_length && data.content_length === 0) { + if (data.code == 200 && data.content_length === 0) { link.error = "Image with 0 content_length"; } From 87f64fd7aff297bf5a59de4a738ec61b1cb02763 Mon Sep 17 00:00:00 2001 From: Ivan Paramonau Date: Wed, 27 Jan 2016 10:38:38 -0500 Subject: [PATCH 105/320] [domains] smugmug is also ssl now --- plugins/domains/smugmug.com.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/domains/smugmug.com.js b/plugins/domains/smugmug.com.js index a93b7f878..82cb74341 100644 --- a/plugins/domains/smugmug.com.js +++ b/plugins/domains/smugmug.com.js @@ -56,7 +56,7 @@ module.exports = { if ($iframe.length == 1) { links.push({ - href: $iframe.attr('src') + "?width=100%&height=100%", + href: $iframe.attr('src').replace(/^http:\/\//, '//') + "?width=100%&height=100%", type: CONFIG.T.text_html, rel: [CONFIG.R.player, CONFIG.R.oembed] }); From 7045cc7f27da87baf3160724a0dbecb721411c5c Mon Sep 17 00:00:00 2001 From: Ivan Paramonau Date: Thu, 28 Jan 2016 10:38:29 -0500 Subject: [PATCH 106/320] [domains] support vox cards --- plugins/domains/vox.com/vox.cards.ejs | 2 ++ plugins/domains/vox.com/vox.cards.js | 23 +++++++++++++++++++++++ 2 files changed, 25 insertions(+) create mode 100644 plugins/domains/vox.com/vox.cards.ejs create mode 100644 plugins/domains/vox.com/vox.cards.js diff --git a/plugins/domains/vox.com/vox.cards.ejs b/plugins/domains/vox.com/vox.cards.ejs new file mode 100644 index 000000000..de26eacd0 --- /dev/null +++ b/plugins/domains/vox.com/vox.cards.ejs @@ -0,0 +1,2 @@ +
+ \ No newline at end of file diff --git a/plugins/domains/vox.com/vox.cards.js b/plugins/domains/vox.com/vox.cards.js new file mode 100644 index 000000000..e5f78c0b1 --- /dev/null +++ b/plugins/domains/vox.com/vox.cards.js @@ -0,0 +1,23 @@ +module.exports = { + + re: /^https?:\/\/www\.vox\.com\/cards\/([a-z0-9\-]+)/i, + + mixins: [ + "*" + ], + + getLink: function(urlMatch) { + + return { + template_context: { + slug: urlMatch[1] + }, + type: CONFIG.T.text_html, + rel: [CONFIG.R.app, CONFIG.R.ssl] + } + }, + + tests: [ + "http://www.vox.com/cards/iowa-caucus-2016-polls" + ] +}; \ No newline at end of file From 5dbedcd6239c25de46e79aa49ed59653738125be Mon Sep 17 00:00:00 2001 From: Ivan Paramonau Date: Thu, 28 Jan 2016 10:38:52 -0500 Subject: [PATCH 107/320] [domains] add apester --- plugins/domains/apester.com.js | 64 ++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 plugins/domains/apester.com.js diff --git a/plugins/domains/apester.com.js b/plugins/domains/apester.com.js new file mode 100644 index 000000000..a63821e41 --- /dev/null +++ b/plugins/domains/apester.com.js @@ -0,0 +1,64 @@ +module.exports = { + + re: [ + /^https?:\/\/(?:renderer|preview)\.qmerce\.com\/interaction\/([a-z0-9]+)/i + ], + + mixins: ['*'], + + provides: 'qmerce', + + getData: function(urlMatch, request, cb) { + + // need to detect the height + request({ + uri: "http://preview.qmerce.com/api/interaction/" + urlMatch[1], + json: true, + prepareResult: function(error, response, body, cb) { + + if (error) { + return cb(error); + } + + if (body.message !== 'ok' ) { + return cb(body.message); + } else { + cb(null, { + qmerce: body.payload + }); + } + } + }, cb); + }, + + getLink: function(qmerce, urlMatch) { + return [{ + href: '//renderer.qmerce.com/interaction/' + urlMatch[1], + type: CONFIG.T.text_html, + rel: [CONFIG.R.survey, CONFIG.R.html5], + height: qmerce.data.size.height // do not check for "undefined" - let it fail if it happens + }, { + href: qmerce.image && qmerce.image.path && ('http://images.apester.com/' + qmerce.image.path.replace (/\//g, '%2F')), + type: CONFIG.T.image, + rel: CONFIG.R.thumbnail + }] + }, + + getMeta: function(qmerce) { + return { + title: qmerce.title, + date: qmerce.updated || qmerce.created, + author: qmerce.publisher && qmerce.publisher.name + } + }, + + tests: [ + "http://renderer.qmerce.com/interaction/5661a18763937fdb5ef4fa87", + "http://renderer.qmerce.com/interaction/567cd70dc3b9c606515e7716", + "http://renderer.qmerce.com/interaction/567af436781fde0551b3e049", + "https://preview.qmerce.com/interaction/566e7dacd98c046319a768b4", + "https://preview.qmerce.com/interaction/562a434547771a99601c3626", + "http://renderer.qmerce.com/interaction/562146b041d4754d14603b18", + "http://renderer.qmerce.com/interaction/569388818089e8dd05aff3a8" + ] +}; \ No newline at end of file From 526cea3e0619da7d15692ee97ed41e1dda12190f Mon Sep 17 00:00:00 2001 From: Ivan Paramonau Date: Fri, 29 Jan 2016 15:27:55 -0500 Subject: [PATCH 108/320] [domains] minor fixes --- plugins/domains/cnn.com.js | 2 +- plugins/domains/features.aol.com.js | 2 +- plugins/domains/mail.ru.js | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/plugins/domains/cnn.com.js b/plugins/domains/cnn.com.js index 79cf75c8f..7b6ac7137 100644 --- a/plugins/domains/cnn.com.js +++ b/plugins/domains/cnn.com.js @@ -1,7 +1,7 @@ module.exports = { re: [ - /^https?:\/\/(www|edition)\.cnn\.com\/videos\//i, + /^https?:\/\/(www|edition)?\.?cnn\.com\/videos\//i, ], mixins: [ diff --git a/plugins/domains/features.aol.com.js b/plugins/domains/features.aol.com.js index 70e199c2f..d975f0dbd 100644 --- a/plugins/domains/features.aol.com.js +++ b/plugins/domains/features.aol.com.js @@ -14,7 +14,7 @@ module.exports = { if (playlist) { return { - href: "//pshared.5min.com/Scripts/PlayerSeed.js?sid=281&&playList=" + playlist, + href: "http://pshared.5min.com/Scripts/PlayerSeed.js?sid=281&&playList=" + playlist, type: CONFIG.T.javascript, rel: [CONFIG.R.player, CONFIG.R.inline, CONFIG.R.html5], "aspect-ratio": 16 / 9 diff --git a/plugins/domains/mail.ru.js b/plugins/domains/mail.ru.js index 1507d9f74..48ced67ab 100644 --- a/plugins/domains/mail.ru.js +++ b/plugins/domains/mail.ru.js @@ -1,7 +1,7 @@ module.exports = { re: [ - /^https?:\/\/my\.mail\.ru\/(inbox|mail)\/[a-zA-Z0-9\._\-]+\/video\/([a-zA-Z0-9_]+)\/([a-zA-Z0-9_]+)\.html/i + /^https?:\/\/my\.mail\.ru\/(inbox|mail|list|bk|corp)\/[a-zA-Z0-9\._\-]+\/video\/([a-zA-Z0-9_]+)\/([a-zA-Z0-9_]+)\.html/i ], mixins: [ @@ -15,7 +15,7 @@ module.exports = { } return { - href: 'http://videoapi.my.mail.ru/videos/embed/mail/' + url.replace(/^https?:\/\/my\.mail\.ru\/(inbox|mail)\//, ''), + href: 'http://videoapi.my.mail.ru/videos/embed/' + url.replace(/^https?:\/\/my\.mail\.ru\//, '').replace(/^inbox/, 'mail'), type: CONFIG.T.text_html, rel: [CONFIG.R.player, CONFIG.R.ssl, CONFIG.R.html5], "aspect-ratio": 626 / 367 From 972486ec7204b85802930ab2be42e156bd61a8c5 Mon Sep 17 00:00:00 2001 From: Ivan Paramonau Date: Sat, 30 Jan 2016 11:20:48 -0500 Subject: [PATCH 109/320] [domains] globalnews.ca doesn't publish twitter:player any longer --- plugins/domains/archive.org.js | 2 +- plugins/domains/globalnews.ca.js | 22 ++++++++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 plugins/domains/globalnews.ca.js diff --git a/plugins/domains/archive.org.js b/plugins/domains/archive.org.js index c4c6377ad..0fced436a 100644 --- a/plugins/domains/archive.org.js +++ b/plugins/domains/archive.org.js @@ -24,7 +24,7 @@ module.exports = { } - if (/\.(mp4|avi)$/i.test(player.href)) { + if (/\.(mp4|avi|mov)$/i.test(player.href)) { player["aspect-ratio"] = twitter.player.width / twitter.player.height; } diff --git a/plugins/domains/globalnews.ca.js b/plugins/domains/globalnews.ca.js new file mode 100644 index 000000000..5c0765f3d --- /dev/null +++ b/plugins/domains/globalnews.ca.js @@ -0,0 +1,22 @@ +module.exports = { + + re: [ + /^https?:\/\/globalnews\.ca\/video\/(\d+)\//i + ], + + mixins: ["*"], + + getLink: function(urlMatch) { + + return { + href: "http://globalnews.ca/video/embed/" + urlMatch[1] + "/", + type: CONFIG.T.text_html, + rel: [CONFIG.R.player, CONFIG.R.html5], + "aspect-ratio": 670 / 437 + }; + }, + + tests: [ + "http://globalnews.ca/video/1915279/red-wings-forward-drew-miller-gets-slashed-in-face-on-ice" + ] +}; \ No newline at end of file From 8e97c28d7386df712966578a263ea8278f4e6f45 Mon Sep 17 00:00:00 2001 From: Ivan Paramonau Date: Mon, 1 Feb 2016 09:37:17 -0500 Subject: [PATCH 110/320] [domains] explicit media detector for clip.vn --- plugins/domains/clip.vn.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/plugins/domains/clip.vn.js b/plugins/domains/clip.vn.js index 1ed6ad2bf..910e39978 100644 --- a/plugins/domains/clip.vn.js +++ b/plugins/domains/clip.vn.js @@ -3,6 +3,7 @@ module.exports = { re: /^http:\/\/clip\.vn\/watch\/(?:[\w-]+,)?([\w-]+)\/?/i, mixins: ["*"], + highestPriority: true, getLink: function(urlMatch) { return { @@ -13,6 +14,12 @@ module.exports = { }; }, + getMeta: function(urlMatch) { + return { + "media": "player" + }; + }, + tests: [{ pageWithFeed: "http://clip.vn/" }, From 493db5aea3f205f6b6d48989d62e710939d797ab Mon Sep 17 00:00:00 2001 From: Ivan Paramonau Date: Thu, 4 Feb 2016 14:57:36 -0500 Subject: [PATCH 111/320] [domains] fix t-online.de --- plugins/domains/t-online.de.js | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 plugins/domains/t-online.de.js diff --git a/plugins/domains/t-online.de.js b/plugins/domains/t-online.de.js new file mode 100644 index 000000000..0426e6899 --- /dev/null +++ b/plugins/domains/t-online.de.js @@ -0,0 +1,29 @@ +module.exports = { + + re: [ + /^https?:\/\/www\.t\-online\.de\/tv\//i + ], + + mixins: [ + "*" + ], + + getLink: function(meta) { + + var href = meta.video_src.href || meta.video_src; + + if (href && /\.mp4$/.test(href)) { + + return { + href: meta.video_src.href || meta.video_src, + type: CONFIG.T.video_mp4, + rel: [CONFIG.R.player], + "aspect-ratio": meta.video_width && meta.video_height ? (meta.video_width > meta.video_height ? meta.video_width / meta.video_height : meta.video_height / meta.video_width) : 16 / 9 + } + } + }, + + tests: [ + "http://www.t-online.de/tv/stars/vip-spotlight/id_58647502/sexy-bilder-stars-im-bikini.html?vid=ap" + ] +}; \ No newline at end of file From eb9a01eb002d98f190f189d2345afce9ef118713 Mon Sep 17 00:00:00 2001 From: Ivan Paramonau Date: Thu, 4 Feb 2016 15:05:53 -0500 Subject: [PATCH 112/320] [domains] future fix for abc.go.com - when they actually fix the embed player --- plugins/.fixme/abc.go.com.js | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 plugins/.fixme/abc.go.com.js diff --git a/plugins/.fixme/abc.go.com.js b/plugins/.fixme/abc.go.com.js new file mode 100644 index 000000000..2385f5d9d --- /dev/null +++ b/plugins/.fixme/abc.go.com.js @@ -0,0 +1,24 @@ +module.exports = { + + re: /^https?:\/\/abc\.go\.com\/shows\/[\w\-]+\/video\/(?:most\-recent\/|featured\/)?([a-zA-Z0-9_]+)/i, + + mixins: [ + "*" + ], + + getLink: function(urlMatch) { + + return { + href: "//abc.go.com/embed/" + urlMatch[1], + rel: [CONFIG.R.player, CONFIG.R.html5], + type: CONFIG.T.text_html, + 'aspect-ratio': 644/362 + }; + }, + + tests: [ + "http://abc.go.com/shows/jimmy-kimmel-live/video/most-recent/vdka0_uujyfy0k", + "http://abc.go.com/shows/bachelor-live/video/VDKA0_phcdyfk5" + ] + +}; \ No newline at end of file From 9b9ad7eaa39e2acac7c335c4d6a6690383785dbf Mon Sep 17 00:00:00 2001 From: Ivan Paramonau Date: Wed, 10 Feb 2016 14:21:39 -0500 Subject: [PATCH 113/320] [domains] return support for ComedyCentral + other minors --- plugins/domains/behance.net.js | 3 ++- plugins/domains/cc.com.js | 30 ++++++++++++++++++++++++++++++ plugins/domains/mail.ru.js | 2 +- 3 files changed, 33 insertions(+), 2 deletions(-) create mode 100644 plugins/domains/cc.com.js diff --git a/plugins/domains/behance.net.js b/plugins/domains/behance.net.js index 41b7c11b5..d613670f2 100644 --- a/plugins/domains/behance.net.js +++ b/plugins/domains/behance.net.js @@ -45,7 +45,8 @@ module.exports = { type: CONFIG.T.text_html, rel: [CONFIG.R.reader, CONFIG.R.oembed, CONFIG.R.html5], "min-width": oembed.thumbnail_width, - "min-height": oembed.thumbnail_height + "min-height": oembed.thumbnail_height, + "aspect-ratio": 1 / Math.sqrt(2) // A4 }; } }, diff --git a/plugins/domains/cc.com.js b/plugins/domains/cc.com.js new file mode 100644 index 000000000..6811672a4 --- /dev/null +++ b/plugins/domains/cc.com.js @@ -0,0 +1,30 @@ +module.exports = { + + re: [ + /https?:\/\/www\.cc\.com\/video\-clips\//i + ], + + mixins: ["*"], + + getLink: function(sm4, cheerio) { + + if (sm4.type && /video/i.test(sm4.type)) { + + var $player = cheerio('.video_player[data-mgid*="mgid:arc:video:comedycentral.com"]'); + + if ($player.length) { + return { + href: "http://media.mtvnservices.com/embed/" + $player.attr('data-mgid'), + type: CONFIG.T.text_html, + rel: [CONFIG.R.player, CONFIG.R.html5], + "aspect-ratio": 512 / 288 + + } + } + } + }, + + tests: [ + "http://www.cc.com/video-clips/4hfvws/the-daily-show-with-trevor-noah-jon-stewart-returns-to-shame-congress" + ] +}; \ No newline at end of file diff --git a/plugins/domains/mail.ru.js b/plugins/domains/mail.ru.js index 48ced67ab..aaff56cdf 100644 --- a/plugins/domains/mail.ru.js +++ b/plugins/domains/mail.ru.js @@ -15,7 +15,7 @@ module.exports = { } return { - href: 'http://videoapi.my.mail.ru/videos/embed/' + url.replace(/^https?:\/\/my\.mail\.ru\//, '').replace(/^inbox/, 'mail'), + href: '//videoapi.my.mail.ru/videos/embed/' + url.replace(/^https?:\/\/my\.mail\.ru\//, '').replace(/^inbox/, 'mail'), type: CONFIG.T.text_html, rel: [CONFIG.R.player, CONFIG.R.ssl, CONFIG.R.html5], "aspect-ratio": 626 / 367 From 133a007054905e573a3752ac695d7a1a16288c72 Mon Sep 17 00:00:00 2001 From: Ivan Paramonau Date: Wed, 10 Feb 2016 21:47:49 -0500 Subject: [PATCH 114/320] [domains] support for NHL redesign --- plugins/domains/nhl.com.js | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 plugins/domains/nhl.com.js diff --git a/plugins/domains/nhl.com.js b/plugins/domains/nhl.com.js new file mode 100644 index 000000000..891c95126 --- /dev/null +++ b/plugins/domains/nhl.com.js @@ -0,0 +1,30 @@ +module.exports = { + + re: [ + /https?:\/\/(?:www\.)?nhl\.com(\/\w+\/)video\/([a-zA-Z0-9\-]+\/t\-\d+\/c\-\d+)/i, + /https?:\/\/(?:www\.)?nhl\.com(\/)video\/([a-zA-Z0-9\-]+\/t\-\d+\/c\-\d+)/i + ], + + mixins: ["*"], + + getLinks: function(urlMatch) { + + return [{ + href: "https://www.nhl.com" + urlMatch[1] + "video/embed/" + urlMatch[2] + "?autostart=false", + type: CONFIG.T.text_html, + rel: [CONFIG.R.player, CONFIG.R.html5], + "aspect-ratio": 540 / 310 + }, { + href: "https://www.nhl.com" + urlMatch[1] + "video/embed/" + urlMatch[2] + "?autostart=true", + type: CONFIG.T.text_html, + rel: [CONFIG.R.player, CONFIG.R.html5, CONFIG.R.autoplay], + "aspect-ratio": 540 / 310 + }] + }, + + tests: [ + "https://www.nhl.com/blackhawks/video/whatsyourgoal-emilie/t-277443408/c-40739903", + "https://www.nhl.com/video/toews-ot-winner/t-277350912/c-40861003", + "https://www.nhl.com/video/niskanens-go-ahead-goal/t-277983160/c-40970503" + ] +}; \ No newline at end of file From 8cfef27ffbcdcc1635a5a24f3ac1628af078e507 Mon Sep 17 00:00:00 2001 From: Ivan Paramonau Date: Wed, 10 Feb 2016 21:48:07 -0500 Subject: [PATCH 115/320] [domains] a bit more URLs for Comedy Central --- plugins/domains/cc.com.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/plugins/domains/cc.com.js b/plugins/domains/cc.com.js index 6811672a4..f509c39d6 100644 --- a/plugins/domains/cc.com.js +++ b/plugins/domains/cc.com.js @@ -1,7 +1,7 @@ module.exports = { re: [ - /https?:\/\/www\.cc\.com\/video\-clips\//i + /https?:\/\/www\.cc\.com\/video\-(clips|collections)\//i ], mixins: ["*"], @@ -25,6 +25,7 @@ module.exports = { }, tests: [ - "http://www.cc.com/video-clips/4hfvws/the-daily-show-with-trevor-noah-jon-stewart-returns-to-shame-congress" + "http://www.cc.com/video-clips/4hfvws/the-daily-show-with-trevor-noah-jon-stewart-returns-to-shame-congress", + "http://www.cc.com/video-collections/igf7f1/the-daily-show-with-jon-stewart-jon-s-final-episode/bjutn7?xrs=share_copy_email" ] }; \ No newline at end of file From a6dc3981e4fa023d827ba9b6eb9cb694498b7e2f Mon Sep 17 00:00:00 2001 From: Ivan Paramonau Date: Wed, 10 Feb 2016 22:26:06 -0500 Subject: [PATCH 116/320] [domains] 500px now provides js embeds --- lib/plugins/system/oembed/providers.json | 4 ++-- plugins/domains/500px/500px.com.ejs | 7 +++++++ plugins/domains/{ => 500px}/500px.com.js | 23 +++++++++++++++-------- 3 files changed, 24 insertions(+), 10 deletions(-) create mode 100644 plugins/domains/500px/500px.com.ejs rename plugins/domains/{ => 500px}/500px.com.js (55%) diff --git a/lib/plugins/system/oembed/providers.json b/lib/plugins/system/oembed/providers.json index 64273fc06..23835a6bc 100644 --- a/lib/plugins/system/oembed/providers.json +++ b/lib/plugins/system/oembed/providers.json @@ -253,9 +253,9 @@ { "name": "500px", "templates": [ - "500px\\.com/photo/(\\d+).*" + "500px\\.com/photo/(\\d+)\\[a-zA-Z0-9_-]+" ], - "endpoint": "http://500px.com/photo/{1}/oembed.{format}" + "endpoint": "https://500px.com/oembed" }, { "name": "Dipdive", diff --git a/plugins/domains/500px/500px.com.ejs b/plugins/domains/500px/500px.com.ejs new file mode 100644 index 000000000..5503672bc --- /dev/null +++ b/plugins/domains/500px/500px.com.ejs @@ -0,0 +1,7 @@ +
+

+ <%= title %> +

+ +
+ \ No newline at end of file diff --git a/plugins/domains/500px.com.js b/plugins/domains/500px/500px.com.js similarity index 55% rename from plugins/domains/500px.com.js rename to plugins/domains/500px/500px.com.js index d3f1c29b4..4e4197264 100644 --- a/plugins/domains/500px.com.js +++ b/plugins/domains/500px/500px.com.js @@ -23,19 +23,26 @@ module.exports = { }; }, - getLinks: function(meta) { - return { - href: meta["shortcut icon"].href, - type: CONFIG.T.image_icon, - rel: CONFIG.R.icon, - width: 32, - height: 32 + getLinks: function(url, oembed) { + if (oembed.type === 'photo') { + return { + template_context: { + title: oembed.title + ' | ' + oembed.provider_name, + img_src: oembed.url, + canonical: url + }, + type: CONFIG.T.text_html, + rel: [CONFIG.R.image, CONFIG.R.inline, CONFIG.R.html5], + "aspect-ratio": oembed.width / oembed.height + + } } }, tests: [{ pageWithFeed: "https://500px.com/flow" }, - "http://500px.com/photo/13541787?from=upcoming" + "http://500px.com/photo/13541787?from=upcoming", + "https://500px.com/photo/56891080/frozen-by-ryan-pendleton?ctx_page=1&from=user&user_id=116369" ] }; \ No newline at end of file From 4b0dc7acd58b13b44a60fa3e49da38d10d0850df Mon Sep 17 00:00:00 2001 From: Ivan Paramonau Date: Fri, 12 Feb 2016 08:09:29 -0500 Subject: [PATCH 117/320] [domains] fix nbc sports --- plugins/domains/nbcsports.com.js | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/plugins/domains/nbcsports.com.js b/plugins/domains/nbcsports.com.js index 416e14d35..b25e66915 100644 --- a/plugins/domains/nbcsports.com.js +++ b/plugins/domains/nbcsports.com.js @@ -8,20 +8,28 @@ module.exports = { "*" ], - getLink: function(twitter) { + getLink: function(twitter, cheerio) { if (twitter.player) { - return { - href: twitter.player.stream.value || twitter.player.stream, - type: CONFIG.T.maybe_text_html, // verify, it is likely a text/html rather than mp4 - rel: [CONFIG.R.player, CONFIG.R.html5], - "aspect-ratio": 16 / 9 // twitter.player width & height are incorrect + var $player = cheerio('#vod-player'); + + if ($player.length) { + + var src = $player.attr('src'); + + return { + href: src.match(/\/\/vplayer\.nbcsports\.com\/p\/[a-zA-Z0-9_]+\/nbcsports\/select\/media\/[a-zA-Z0-9_]+/i)[0], + rel: [CONFIG.R.player, CONFIG.R.html5], + type: CONFIG.T.text_html, + "aspect-ratio": 16/9 + } } } }, tests: [ - "http://www.nbcsports.com/video/redskins-team-beat-wild-card-matchup-vs-packers" + "http://www.nbcsports.com/video/redskins-team-beat-wild-card-matchup-vs-packers", + "http://www.nbcsports.com/video/alex-morgan-scores-opening-12-seconds-vs-costa-rica" ] }; \ No newline at end of file From de0b03a8349761910954f4c9517029f8fb3a5c6f Mon Sep 17 00:00:00 2001 From: Nazar Leush Date: Fri, 12 Feb 2016 15:44:32 +0200 Subject: [PATCH 118/320] [oembed] return description meta in oembed response --- lib/oembed.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/oembed.js b/lib/oembed.js index 8a93cc848..27d5d56b2 100644 --- a/lib/oembed.js +++ b/lib/oembed.js @@ -23,6 +23,9 @@ exports.getOembed = function(uri, data, options) { if (data.meta.site) { oembed.provider_name = data.meta.site; } + if (data.meta.description) { + oembed.description = data.meta.description; + } // Search only promo for thumbnails. var thumbnailLinks = htmlUtils.filterLinksByRel(CONFIG.R.promo, data.links); From 36557a0f392480fce91ac0b090f416918a4f01ad Mon Sep 17 00:00:00 2001 From: Ivan Paramonau Date: Fri, 12 Feb 2016 08:59:32 -0500 Subject: [PATCH 119/320] [domains] forgot SSL flag for 500px html embeds --- plugins/domains/500px/500px.com.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/domains/500px/500px.com.js b/plugins/domains/500px/500px.com.js index 4e4197264..e7eabc7d0 100644 --- a/plugins/domains/500px/500px.com.js +++ b/plugins/domains/500px/500px.com.js @@ -32,7 +32,7 @@ module.exports = { canonical: url }, type: CONFIG.T.text_html, - rel: [CONFIG.R.image, CONFIG.R.inline, CONFIG.R.html5], + rel: [CONFIG.R.image, CONFIG.R.inline, CONFIG.R.html5, CONFIG.R.ssl], "aspect-ratio": oembed.width / oembed.height } From ede40ba43a24a97b70c8e52a8260cf7ab8d4ab59 Mon Sep 17 00:00:00 2001 From: Ivan Paramonau Date: Fri, 12 Feb 2016 13:14:46 -0500 Subject: [PATCH 120/320] [tests] better URL scheme for myvideo.de --- plugins/domains/myvideo.de.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/plugins/domains/myvideo.de.js b/plugins/domains/myvideo.de.js index 8606e3eb8..3b28500a6 100644 --- a/plugins/domains/myvideo.de.js +++ b/plugins/domains/myvideo.de.js @@ -1,7 +1,8 @@ module.exports = { re: [ - /^https?:\/\/www\.myvideo\.de\/watch\/([0-9]+)/i + /^https?:\/\/www\.myvideo\.de\/watch\/([0-9]+)/i, + /^https?:\/\/www\.myvideo\.de[\/a-zA-Z0-9\-]+\/[a-zA-Z0-9\-]+\-m\-(\d+)/i // the rest should be covered by whitelist via embedURL - it verifies permissions etc ], @@ -19,6 +20,8 @@ module.exports = { }, tests: [ - "http://www.myvideo.de/watch/9790416/Balbina_Seife_feat_Maeckes" + "http://www.myvideo.de/watch/9790416/Balbina_Seife_feat_Maeckes", + "http://www.myvideo.de/filme/cristiano-ronaldo-feet-m-11870130", + "http://www.myvideo.de/serien/zoo/highlights/preview-folge-9-gefahr-droht-oben-m-12145697" ] }; \ No newline at end of file From abc34dfd9474ef9afa78f4d0798ce8b783161b0c Mon Sep 17 00:00:00 2001 From: Nazar Leush Date: Mon, 15 Feb 2016 17:46:15 +0200 Subject: [PATCH 121/320] [domains] return twitter api call error --- plugins/domains/twitter.status.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/plugins/domains/twitter.status.js b/plugins/domains/twitter.status.js index 6052d4f9c..08ea43ad5 100644 --- a/plugins/domains/twitter.status.js +++ b/plugins/domains/twitter.status.js @@ -73,6 +73,10 @@ module.exports = { ttl: c.cache_ttl, prepareResult: function(error, response, data, cb) { + if (error) { + return cb(error); + } + if (response.fromRequestCache) { if (blockExpireIn > 0) { sysUtils.log(' -- Twitter API limit reached (' + blockExpireIn + ' seconds left), but cache used.'); From 2ce137b86a3ffef5b63878a0aa31ec38800d1603 Mon Sep 17 00:00:00 2001 From: Ivan Paramonau Date: Mon, 15 Feb 2016 10:47:43 -0500 Subject: [PATCH 122/320] [domains] support 'share' links of newsinc --- plugins/domains/launch.newsinc.com.js | 43 +++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 plugins/domains/launch.newsinc.com.js diff --git a/plugins/domains/launch.newsinc.com.js b/plugins/domains/launch.newsinc.com.js new file mode 100644 index 000000000..31e1b562d --- /dev/null +++ b/plugins/domains/launch.newsinc.com.js @@ -0,0 +1,43 @@ +var URL = require("url"); + +module.exports = { + + re: [ + /^https?:\/\/launch\.newsinc\.com\/share\.html\?.+/i, + /^https?:\/\/launch\.newsinc\.com\/embed.html\?.+/i + ], + + mixins: ["*"], + + getLink: function(url) { + + var link = URL.parse(url, true); + var query = link.query; + var trackingGroup = query.trackingGroup; + var siteSection = query.siteSection; + var videoId = query.videoId; + + if (trackingGroup && videoId) { + + return { + href: '//launch.newsinc.com/embed.html?type=VideoPlayer/Single&widgetId=2&trackingGroup=' + trackingGroup + '&videoId=' + videoId + (siteSection ? '&siteSection=ndn' + siteSection : ''), + // embed code in player lists `widegtId=1`, but that one autoplays and no thumbnail available + type: CONFIG.T.text_html, + rel: [CONFIG.R.player, CONFIG.R.html5], + "aspect-ratio": 16 / 9 + }; + } + }, + + tests: [{ + noFeeds: true + }, + "http://launch.newsinc.com/share.html?trackingGroup=91585&siteSection=unitedpress&videoId=30060852", + "http://launch.newsinc.com/share.html?trackingGroup=91663&videoId=29926306", + "http://launch.newsinc.com/share.html?trackingGroup=91002&siteSection=latimes_hom_non_sec&videoId=29750644", + "http://launch.newsinc.com/?type=VideoPlayer/Single&widgetId=1&trackingGroup=69016&siteSection=unitedpress&videoId=28774159", + "http://launch.newsinc.com/share.html?trackingGroup=90051&siteSection=nydailynews-entertainment&videoId=28336738", + "http://launch.newsinc.com/share.html?trackingGroup=69016&siteSection=omahawh_spt_ncaa_sty_pp&videoId=28750854" + ] + +}; \ No newline at end of file From a1ea1fdc2563af864f168d8951a699499e94b09c Mon Sep 17 00:00:00 2001 From: Ivan Paramonau Date: Tue, 16 Feb 2016 08:30:43 -0500 Subject: [PATCH 123/320] [facebook] avoid 500 errors from the origin - do not request the source page should resolve #106 --- plugins/domains/facebook.com/facebook.data.js | 45 +++++------------- .../facebook.com/facebook.redirects.js | 46 +++++++++++++++++++ 2 files changed, 57 insertions(+), 34 deletions(-) create mode 100644 plugins/domains/facebook.com/facebook.redirects.js diff --git a/plugins/domains/facebook.com/facebook.data.js b/plugins/domains/facebook.com/facebook.data.js index d3cfd43ac..a98034cf6 100644 --- a/plugins/domains/facebook.com/facebook.data.js +++ b/plugins/domains/facebook.com/facebook.data.js @@ -3,50 +3,27 @@ module.exports = { // It's official: https://developers.facebook.com/docs/plugins/oembed-endpoints mixins: [ - "favicon", + "domain-favicon", "oembed-author", "oembed-canonical", "oembed-site" ], - getMeta: function(meta) { - return { - title: meta["html-title"].replace(/ \| Facebook$/, ""), - description: meta["description"] - }; - }, + getMeta: function(oembed) { - getData: function(url, meta, cb) { + if (oembed.html) { - if (meta["html-title"] === "Facebook" || meta["html-title"] === "Leaving Facebook...") { - // the content is not public - return cb({responseStatusCode: 403}); - } + var description = oembed.html.match(/

(.*?)<\/p>/i); + description = description ? description[1]: ''; - if (/^https?:\/\/(?:www|m|business)\.facebook\.com\/login\.php/i.test(url)) { - // redirect to login - return cb({responseStatusCode: 403}); - } + var title = oembed.html.match(/>([^<>]+)<\/a>

/i); + title = title ? title [1] : oembed.author_name; - - if (meta["html-title"] === "Content Not Found") { - // for mobiles pages like https://m.facebook.com/story.php?story_fbid=654911224606798 fb doesn't return 404 - return cb({responseStatusCode: 404}); - } - - - // Little hack for FB mobile URLs, as FB embeds don't recognize it's own mobile links. - if (url.indexOf("m.facebook.com/story.php") > -1) { - return cb({redirect: url.replace("m.facebook.com/story.php", "www.facebook.com/permalink.php")}); - } else if (url.indexOf("m.facebook.com/") > -1) { - return cb({redirect: url.replace("m.facebook.com", "www.facebook.com")}); + return { + title: title, + description: description + }; } - - if (url.indexOf('facebook.com/l.php?u=') > -1) { - return cb({redirect: decodeURIComponent(url.match(/u=([^&]+)/i)[1])}); - } - - cb(null); }, tests: [{ diff --git a/plugins/domains/facebook.com/facebook.redirects.js b/plugins/domains/facebook.com/facebook.redirects.js new file mode 100644 index 000000000..97942bf7f --- /dev/null +++ b/plugins/domains/facebook.com/facebook.redirects.js @@ -0,0 +1,46 @@ +module.exports = { + + re: [ + /^https?:\/\/m\.facebook\.com\/story\.php/i, + /^https?:\/\/(?:www|m|business)\.facebook\.com\/login\.php/i, + /^https?:\/\/m\.facebook\.com/i, + /^https?:\/\/facebook\.com\/l\.php\?u=/i + ], + + getData: function(url, meta, cb) { + + if (meta["html-title"] === "Facebook" || meta["html-title"] === "Leaving Facebook...") { + // the content is not public + return cb({responseStatusCode: 403}); + } + + if (/^https?:\/\/(?:www|m|business)\.facebook\.com\/login\.php/i.test(url)) { + // redirect to login + return cb({responseStatusCode: 403}); + } + + + if (meta["html-title"] === "Content Not Found") { + // for mobiles pages like https://m.facebook.com/story.php?story_fbid=654911224606798 fb doesn't return 404 + return cb({responseStatusCode: 404}); + } + + + // Little hack for FB mobile URLs, as FB embeds don't recognize it's own mobile links. + if (url.indexOf("m.facebook.com/story.php") > -1) { + return cb({redirect: url.replace("m.facebook.com/story.php", "www.facebook.com/permalink.php")}); + } else if (url.indexOf("m.facebook.com/") > -1) { + return cb({redirect: url.replace("m.facebook.com", "www.facebook.com")}); + } + + if (url.indexOf('facebook.com/l.php?u=') > -1) { + return cb({redirect: decodeURIComponent(url.match(/u=([^&]+)/i)[1])}); + } + + cb(null); + }, + + tests: [{ + noFeeds: true + }] +}; \ No newline at end of file From cd977f37e494e2c457cbab6409445fc1fe50a994 Mon Sep 17 00:00:00 2001 From: Ivan Paramonau Date: Tue, 16 Feb 2016 08:33:00 -0500 Subject: [PATCH 124/320] [facebook] favicon typo --- plugins/domains/facebook.com/facebook.data.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/domains/facebook.com/facebook.data.js b/plugins/domains/facebook.com/facebook.data.js index a98034cf6..68377dc2d 100644 --- a/plugins/domains/facebook.com/facebook.data.js +++ b/plugins/domains/facebook.com/facebook.data.js @@ -3,7 +3,7 @@ module.exports = { // It's official: https://developers.facebook.com/docs/plugins/oembed-endpoints mixins: [ - "domain-favicon", + "domain-icon", "oembed-author", "oembed-canonical", "oembed-site" From 42cf886c806760715e79ee952e4afc943cff5c16 Mon Sep 17 00:00:00 2001 From: Ivan Paramonau Date: Tue, 16 Feb 2016 08:46:59 -0500 Subject: [PATCH 125/320] [facebook] handle line breaks in the descriptions --- plugins/domains/facebook.com/facebook.data.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/domains/facebook.com/facebook.data.js b/plugins/domains/facebook.com/facebook.data.js index 68377dc2d..4a6038630 100644 --- a/plugins/domains/facebook.com/facebook.data.js +++ b/plugins/domains/facebook.com/facebook.data.js @@ -13,7 +13,7 @@ module.exports = { if (oembed.html) { - var description = oembed.html.match(/

(.*?)<\/p>/i); + var description = oembed.html.match(/

([^<>]+)<\/p>/i); description = description ? description[1]: ''; var title = oembed.html.match(/>([^<>]+)<\/a>

/i); From 7ba6796c745fb18557e5413da2ded1da148359cc Mon Sep 17 00:00:00 2001 From: Ivan Paramonau Date: Tue, 16 Feb 2016 09:50:08 -0500 Subject: [PATCH 126/320] [facebook] better title detect for pages --- plugins/domains/facebook.com/facebook.data.js | 8 ++++++-- plugins/domains/facebook.com/facebook.page.js | 13 +++++++++++++ 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/plugins/domains/facebook.com/facebook.data.js b/plugins/domains/facebook.com/facebook.data.js index 4a6038630..bebb21876 100644 --- a/plugins/domains/facebook.com/facebook.data.js +++ b/plugins/domains/facebook.com/facebook.data.js @@ -16,12 +16,16 @@ module.exports = { var description = oembed.html.match(/

([^<>]+)<\/p>/i); description = description ? description[1]: ''; + var author = oembed.html.match(/Posted by ]+)>([^<>]+)<\/a>/); + author = author ? author[1]: oembed.author_name; + var title = oembed.html.match(/>([^<>]+)<\/a>

/i); - title = title ? title [1] : oembed.author_name; + title = title ? title[1] : author; return { title: title, - description: description + description: description, + author: author }; } }, diff --git a/plugins/domains/facebook.com/facebook.page.js b/plugins/domains/facebook.com/facebook.page.js index 388435d53..0103c87ac 100644 --- a/plugins/domains/facebook.com/facebook.page.js +++ b/plugins/domains/facebook.com/facebook.page.js @@ -5,6 +5,19 @@ module.exports = { /^https?:\/\/(www|m)\.facebook\.com\/([a-zA-Z0-9\.\-]+)\/?(?:\?f?ref=\w+)?$/i ], + getMeta: function(oembed, urlMatch) { + + if (oembed.html) { + + var title = oembed.html.match(/>([^<>]+)<\/a><\/blockquote>/i); + title = title ? title[1] : urlMatch[2]; + + return { + title: title + }; + } + }, + getLink: function(oembed, meta, options) { // skip user profiles - they can not be embedded From fe3a5ba2f02471067cacd9b156e148840b0d4dea Mon Sep 17 00:00:00 2001 From: Nazar Leush Date: Thu, 18 Feb 2016 12:12:01 +0200 Subject: [PATCH 127/320] [domains] twitter.com: use oembed v 1, remove rate limits --- plugins/domains/twitter.status.js | 64 ++----------------------------- 1 file changed, 3 insertions(+), 61 deletions(-) diff --git a/plugins/domains/twitter.status.js b/plugins/domains/twitter.status.js index 08ea43ad5..58566cf3e 100644 --- a/plugins/domains/twitter.status.js +++ b/plugins/domains/twitter.status.js @@ -29,25 +29,12 @@ module.exports = { token: c.access_token, token_secret: c.access_token_secret }; - var blockExpireIn = 0; - var block_key = 'twbl:' + c.consumer_key; async.waterfall([ function(cb) { - cache.get(block_key, cb); - }, - function(expireIn, cb) { - - if (expireIn) { - var now = Math.round(new Date().getTime() / 1000); - if (expireIn > now) { - blockExpireIn = expireIn - now; - } - } - - var url = "https://api.twitter.com/1" + (blockExpireIn > 0 ? "" : ".1") + "/statuses/oembed.json"; + var url = "https://api.twitter.com/1/statuses/oembed.json"; var qs = { id: id, @@ -63,8 +50,7 @@ module.exports = { json: true })).digest("hex") + '"'; - - request(_.extend({ + request({ url: url, qs: qs, json: true, @@ -77,48 +63,6 @@ module.exports = { return cb(error); } - if (response.fromRequestCache) { - if (blockExpireIn > 0) { - sysUtils.log(' -- Twitter API limit reached (' + blockExpireIn + ' seconds left), but cache used.'); - } else { - sysUtils.log(' -- Twitter API cache used.'); - } - } - - // Do not block api if data from cache. - if (!response.fromRequestCache) { - - var remaining = parseInt(response.headers['x-rate-limit-remaining']); - - if (response.statusCode === 429 || remaining <= 7) { - var now = Math.round(new Date().getTime() / 1000); - var limitResetAt = parseInt(response.headers['x-rate-limit-reset']); - var ttl = limitResetAt - now; - - // Do not allow ttl 0. - // 5 seconds - to cover possible time difference with twitter. - if (ttl < 5) { - ttl = 5; - } - - // Block maximum for 15 minutes. - if (ttl > 15*60) { - ttl = 15*60 - } - - if (response.statusCode === 429) { - sysUtils.log(' -- Twitter API limit reached by status code 429. Disabling for ' + ttl + ' seconds.'); - } else { - sysUtils.log(' -- Twitter API limit warning, remaining calls: ' + remaining + '. Disabling for ' + ttl + ' seconds.'); - } - - // Store expire date as value to be sure it past. - var expireIn = now + ttl; - - cache.set(block_key, expireIn, {ttl: ttl}); - } - } - if (response.statusCode !== 200) { return cb('Non-200 response from Twitter API (statuses/oembed.json: ' + response.statusCode); } @@ -127,11 +71,9 @@ module.exports = { return cb('Object expected in Twitter API (statuses/oembed.json), got: ' + data); } - cb(error, data); } - }, (blockExpireIn > 0 ? null : {oauth: oauth})), cb); // add oauth if 1.1, else skip it - + }, cb); } ], function(error, oembed) { From 81d9f47a4e7fbf9c5b8befbc9bfd03753650dbb1 Mon Sep 17 00:00:00 2001 From: Nazar Leush Date: Thu, 18 Feb 2016 16:35:00 +0200 Subject: [PATCH 128/320] Revert "[domains] twitter.com: use oembed v 1, remove rate limits" This reverts commit fe3a5ba2f02471067cacd9b156e148840b0d4dea. --- plugins/domains/twitter.status.js | 64 +++++++++++++++++++++++++++++-- 1 file changed, 61 insertions(+), 3 deletions(-) diff --git a/plugins/domains/twitter.status.js b/plugins/domains/twitter.status.js index 58566cf3e..08ea43ad5 100644 --- a/plugins/domains/twitter.status.js +++ b/plugins/domains/twitter.status.js @@ -29,12 +29,25 @@ module.exports = { token: c.access_token, token_secret: c.access_token_secret }; + var blockExpireIn = 0; + var block_key = 'twbl:' + c.consumer_key; async.waterfall([ function(cb) { + cache.get(block_key, cb); + }, - var url = "https://api.twitter.com/1/statuses/oembed.json"; + function(expireIn, cb) { + + if (expireIn) { + var now = Math.round(new Date().getTime() / 1000); + if (expireIn > now) { + blockExpireIn = expireIn - now; + } + } + + var url = "https://api.twitter.com/1" + (blockExpireIn > 0 ? "" : ".1") + "/statuses/oembed.json"; var qs = { id: id, @@ -50,7 +63,8 @@ module.exports = { json: true })).digest("hex") + '"'; - request({ + + request(_.extend({ url: url, qs: qs, json: true, @@ -63,6 +77,48 @@ module.exports = { return cb(error); } + if (response.fromRequestCache) { + if (blockExpireIn > 0) { + sysUtils.log(' -- Twitter API limit reached (' + blockExpireIn + ' seconds left), but cache used.'); + } else { + sysUtils.log(' -- Twitter API cache used.'); + } + } + + // Do not block api if data from cache. + if (!response.fromRequestCache) { + + var remaining = parseInt(response.headers['x-rate-limit-remaining']); + + if (response.statusCode === 429 || remaining <= 7) { + var now = Math.round(new Date().getTime() / 1000); + var limitResetAt = parseInt(response.headers['x-rate-limit-reset']); + var ttl = limitResetAt - now; + + // Do not allow ttl 0. + // 5 seconds - to cover possible time difference with twitter. + if (ttl < 5) { + ttl = 5; + } + + // Block maximum for 15 minutes. + if (ttl > 15*60) { + ttl = 15*60 + } + + if (response.statusCode === 429) { + sysUtils.log(' -- Twitter API limit reached by status code 429. Disabling for ' + ttl + ' seconds.'); + } else { + sysUtils.log(' -- Twitter API limit warning, remaining calls: ' + remaining + '. Disabling for ' + ttl + ' seconds.'); + } + + // Store expire date as value to be sure it past. + var expireIn = now + ttl; + + cache.set(block_key, expireIn, {ttl: ttl}); + } + } + if (response.statusCode !== 200) { return cb('Non-200 response from Twitter API (statuses/oembed.json: ' + response.statusCode); } @@ -71,9 +127,11 @@ module.exports = { return cb('Object expected in Twitter API (statuses/oembed.json), got: ' + data); } + cb(error, data); } - }, cb); + }, (blockExpireIn > 0 ? null : {oauth: oauth})), cb); // add oauth if 1.1, else skip it + } ], function(error, oembed) { From 9dfd5ed8cf50ec6d9c06c5559de47a6ba0acb443 Mon Sep 17 00:00:00 2001 From: Ivan Paramonau Date: Thu, 18 Feb 2016 10:05:28 -0500 Subject: [PATCH 129/320] [twitter] remove temp cache keys - move completely to new ones --- plugins/domains/twitter.status.js | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/plugins/domains/twitter.status.js b/plugins/domains/twitter.status.js index 08ea43ad5..7295f82fe 100644 --- a/plugins/domains/twitter.status.js +++ b/plugins/domains/twitter.status.js @@ -2,7 +2,6 @@ var async = require('async'); var cache = require('../../lib/cache'); var sysUtils = require('../../logging'); var _ = require('underscore'); -var crypto = require('crypto'); // temp module.exports = { @@ -56,20 +55,11 @@ module.exports = { omit_script: c.omit_script }; - var cache_key = '"' + crypto.createHash('md5').update(JSON.stringify({ - url: 'https://api.twitter.com/1.1/statuses/oembed.json', - qs: qs, - oauth: oauth, - json: true - })).digest("hex") + '"'; - - request(_.extend({ url: url, qs: qs, json: true, - cache_key: cache_key, - new_cache_key: 'twitter:oembed:' + id, + cache_key: 'twitter:oembed:' + id, ttl: c.cache_ttl, prepareResult: function(error, response, data, cb) { From 4c5c321bca7ef32c8776cc9a65a043ba649a2784 Mon Sep 17 00:00:00 2001 From: Ivan Paramonau Date: Thu, 18 Feb 2016 10:20:28 -0500 Subject: [PATCH 130/320] [twitter] use oauth/1.1 if configured - otherwise, oEmbed 1.0 --- config.local.js.SAMPLE | 17 ++++++++--------- plugins/domains/twitter.status.js | 30 +++++++++++++++++++----------- 2 files changed, 27 insertions(+), 20 deletions(-) diff --git a/config.local.js.SAMPLE b/config.local.js.SAMPLE index c275dae1f..a80c0c51b 100644 --- a/config.local.js.SAMPLE +++ b/config.local.js.SAMPLE @@ -102,18 +102,18 @@ "twitter": { "max-width": 550, "min-width": 250, - consumer_key: 'INSERT YOUR VALUE', - consumer_secret: 'INSERT YOUR VALUE', - access_token: 'INSERT YOUR VALUE', - access_token_secret: 'INSERT YOUR VALUE', + + // Twitter rolled back to oEmbed v 1, their 1.1+oauth endpoint is no longer in the documentation + // consumer_key: 'INSERT YOUR VALUE', + // consumer_secret: 'INSERT YOUR VALUE', + // access_token: 'INSERT YOUR VALUE', + // access_token_secret: 'INSERT YOUR VALUE', + hide_media: false, hide_thread: false, omit_script: false, cache_ttl: 100 * 365 * 24 * 3600 // 100 Years. }, - "google.maps": { - // apiKey: 'INSERT YOUR VALUE' // not required, but recommended - }, readability: { enabled: false // allowPTagDescription: true // to enable description fallback to first paragraph @@ -127,8 +127,7 @@ // media_only: true // disables status embeds for images and videos - will return plain media }, google: { - // https://developers.google.com/maps/documentation/embed/guide#api_key - // yes, there is already "apiKey" option above, but I am not sure if old keys are the same as the news ones. + // https://developers.google.com/maps/documentation/embed/guide#api_key maps_key: "INSERT YOUR VALUE" }, diff --git a/plugins/domains/twitter.status.js b/plugins/domains/twitter.status.js index 7295f82fe..917f46457 100644 --- a/plugins/domains/twitter.status.js +++ b/plugins/domains/twitter.status.js @@ -22,19 +22,26 @@ module.exports = { return cb('Twitter API Disabled'); } - var oauth = { - consumer_key: c.consumer_key, - consumer_secret: c.consumer_secret, - token: c.access_token, - token_secret: c.access_token_secret - }; + var oauth = c.consumer_key + ? { + consumer_key: c.consumer_key, + consumer_secret: c.consumer_secret, + token: c.access_token, + token_secret: c.access_token_secret + } : false; + var blockExpireIn = 0; var block_key = 'twbl:' + c.consumer_key; async.waterfall([ function(cb) { - cache.get(block_key, cb); + + if (oauth) { + cache.get(block_key, cb); + } else { + cb(null, null); + } }, function(expireIn, cb) { @@ -46,7 +53,7 @@ module.exports = { } } - var url = "https://api.twitter.com/1" + (blockExpireIn > 0 ? "" : ".1") + "/statuses/oembed.json"; + var url = "https://api.twitter.com/1" + (!oauth || blockExpireIn > 0 ? "" : ".1") + "/statuses/oembed.json"; var qs = { id: id, @@ -75,10 +82,11 @@ module.exports = { } } - // Do not block api if data from cache. - if (!response.fromRequestCache) { + // Do not block 1.1 api if data from cache. + if (oauth && !response.fromRequestCache) { var remaining = parseInt(response.headers['x-rate-limit-remaining']); + console.log('x-rate-limit-remaining: ' + remaining); if (response.statusCode === 429 || remaining <= 7) { var now = Math.round(new Date().getTime() / 1000); @@ -120,7 +128,7 @@ module.exports = { cb(error, data); } - }, (blockExpireIn > 0 ? null : {oauth: oauth})), cb); // add oauth if 1.1, else skip it + }, (!oauth || blockExpireIn ? null : {oauth: oauth})), cb); // add oauth if 1.1, else skip it } From d7f36afcfdab579e448495006c6c760047db0091 Mon Sep 17 00:00:00 2001 From: Ivan Paramonau Date: Thu, 18 Feb 2016 10:27:12 -0500 Subject: [PATCH 131/320] no i didn't --- plugins/domains/twitter.status.js | 1 - 1 file changed, 1 deletion(-) diff --git a/plugins/domains/twitter.status.js b/plugins/domains/twitter.status.js index 917f46457..16c6947bb 100644 --- a/plugins/domains/twitter.status.js +++ b/plugins/domains/twitter.status.js @@ -86,7 +86,6 @@ module.exports = { if (oauth && !response.fromRequestCache) { var remaining = parseInt(response.headers['x-rate-limit-remaining']); - console.log('x-rate-limit-remaining: ' + remaining); if (response.statusCode === 429 || remaining <= 7) { var now = Math.round(new Date().getTime() / 1000); From 9bebad8cdfc2047cd377b1ff0c11f7bda4967543 Mon Sep 17 00:00:00 2001 From: Ivan Paramonau Date: Thu, 18 Feb 2016 10:33:52 -0500 Subject: [PATCH 132/320] [youtube] remove temporary cache key migration code --- plugins/domains/youtube.com/youtube.video.js | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/plugins/domains/youtube.com/youtube.video.js b/plugins/domains/youtube.com/youtube.video.js index 5c86a1280..da921750d 100644 --- a/plugins/domains/youtube.com/youtube.video.js +++ b/plugins/domains/youtube.com/youtube.video.js @@ -1,5 +1,4 @@ var cheerio = require('cheerio'); -var crypto = require('crypto'); // temp module.exports = { @@ -27,15 +26,9 @@ module.exports = { var statsUri = "https://www.googleapis.com/youtube/v3/videos?part=id%2Csnippet%2Cstatistics%2CcontentDetails%2Cplayer%2Cstatus&key=" + api_key + "&id=" + urlMatch[1]; - var cache_key = '"' + crypto.createHash('md5').update(JSON.stringify({ - uri: "https://www.googleapis.com/youtube/v3/videos?part=id%2Csnippet%2Cstatistics%2CcontentDetails%2Cplayer&key=" + api_key + "&id=" + urlMatch[1], //old_one - json: true - })).digest("hex") + '"'; - request({ uri: statsUri, - cache_key: cache_key, - new_cache_key: "youtube:gdata:" + urlMatch[1], + cache_key: "youtube:gdata:" + urlMatch[1], json: true, prepareResult: function(error, b, data, cb) { From 92961f7729340c6f1c2b4203e2769fc88fd7f199 Mon Sep 17 00:00:00 2001 From: Ivan Paramonau Date: Thu, 18 Feb 2016 12:21:56 -0500 Subject: [PATCH 133/320] what's new for v 0.9.3 --- WHATSNEW.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/WHATSNEW.md b/WHATSNEW.md index 081eb034f..74fc5cc22 100644 --- a/WHATSNEW.md +++ b/WHATSNEW.md @@ -4,6 +4,15 @@ This is the history of the Iframely changes. Updates that are older than one yea Stay tuned, either by watching [Iframely on GitHub](https://github.com/itteco/iframely) or following [Iframely on Twitter](https://twitter.com/iframely). +### 2016.02.18, Version 0.9.3 + + - Fix errors for Facebook videos where origin pages return sparadic HTTP code 500 ([#106](https://github.com/itteco/iframely/issues/106)) + - Twitter retired 1.1 API for oEmbed from their documentation. oAuth configuration is now optional + - 500px provides HTML embeds for photos now + - Fix NHL after their site's re-design + - Minor fixes for number of other domain parsers + + ### 2016.01.26, Version 0.9.2 - Domains clean up & maintenance From 0c3f0166e7d3010b84a64be7a015555ab504fd8d Mon Sep 17 00:00:00 2001 From: Nazar Leush Date: Thu, 18 Feb 2016 20:24:36 +0200 Subject: [PATCH 134/320] [domains] imgur.com: fix image link --- plugins/domains/imgur.com.js | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/plugins/domains/imgur.com.js b/plugins/domains/imgur.com.js index 12afb969e..5c835013c 100644 --- a/plugins/domains/imgur.com.js +++ b/plugins/domains/imgur.com.js @@ -18,7 +18,19 @@ module.exports = { "oembed-site" ], - getLink: function(oembed, twitter, options) { + getLinks: function(urlMatch, oembed, meta, twitter, options) { + + var links = []; + + if (twitter.image && twitter.image.indexOf && twitter.image.indexOf(urlMatch[1]) > -1) { + links.push({ + href: twitter.image, + type: CONFIG.T.image_jpeg, + rel: CONFIG.R.image, + width: meta.og && meta.og.image && meta.og.image.width, + height: meta.og && meta.og.image && meta.og.image.height + }); + } if (oembed.type == "rich") { // oembed photo isn't used as of May 18, 2015 @@ -26,23 +38,25 @@ module.exports = { var media_only = options.getProviderOptions('imgur.media_only', false); var isGallery = twitter.card == "gallery"; - if (!media_only || isGallery) { - return { + if (!media_only || isGallery) { + links.push({ html: oembed.html, width: oembed.width, type: CONFIG.T.text_html, rel: [CONFIG.R.app, CONFIG.R.oembed, CONFIG.R.html5, CONFIG.R.inline, CONFIG.R.ssl] - }; + }); } else { - return { + links.push({ href: "http://s.imgur.com/images/favicon-96x96.png", width: 96, height: 96, type: CONFIG.T.image_png, rel: CONFIG.R.icon - } + }); } } + + return links; }, getData: function (meta, urlMatch, cb) { From 3c5f3a9752065ca4cb85f1ef709dfadf0634b36c Mon Sep 17 00:00:00 2001 From: Nazar Leush Date: Thu, 18 Feb 2016 20:40:19 +0200 Subject: [PATCH 135/320] [domains] imgur.com: fix detecting gallery; fix oembed for /topic/ urls --- plugins/domains/imgur.com.js | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/plugins/domains/imgur.com.js b/plugins/domains/imgur.com.js index 5c835013c..6552f1912 100644 --- a/plugins/domains/imgur.com.js +++ b/plugins/domains/imgur.com.js @@ -18,7 +18,7 @@ module.exports = { "oembed-site" ], - getLinks: function(urlMatch, oembed, meta, twitter, options) { + getLinks: function(urlMatch, oembed, twitter, options) { var links = []; @@ -26,9 +26,7 @@ module.exports = { links.push({ href: twitter.image, type: CONFIG.T.image_jpeg, - rel: CONFIG.R.image, - width: meta.og && meta.og.image && meta.og.image.width, - height: meta.og && meta.og.image && meta.og.image.height + rel: CONFIG.R.image }); } @@ -36,7 +34,7 @@ module.exports = { // oembed photo isn't used as of May 18, 2015 var media_only = options.getProviderOptions('imgur.media_only', false); - var isGallery = twitter.card == "gallery"; + var isGallery = twitter.card !== 'player' && links.length === 0; if (!media_only || isGallery) { links.push({ @@ -59,19 +57,23 @@ module.exports = { return links; }, - getData: function (meta, urlMatch, cb) { + getData: function (meta, url, urlMatch, cb) { - var links = ['json', 'xml'].map(function(format) { + if (url.indexOf('/topic/') > -1) { + var links = ['json', 'xml'].map(function(format) { return { - href: "http://api.imgur.com/oembed." + format + "?url=http://imgur.com/" + (meta.twitter && meta.twitter.card == 'gallery' ? 'a/' : '') + urlMatch[1] , + href: "http://api.imgur.com/oembed." + format + "?url=http://imgur.com/" + urlMatch[1], rel: 'alternate', type: 'application/' + format + '+oembed' } - }); + }); - cb(null, { - oembedLinks: links - }); + cb(null, { + oembedLinks: links + }); + } else { + cb(); + } }, tests: [{ From a6a1469bc69ca9cb0ed5f33300a839db28ad6b84 Mon Sep 17 00:00:00 2001 From: Nazar Leush Date: Thu, 18 Feb 2016 21:02:32 +0200 Subject: [PATCH 136/320] [domains] imgur.com: fix test --- plugins/domains/imgur.com.js | 1 + 1 file changed, 1 insertion(+) diff --git a/plugins/domains/imgur.com.js b/plugins/domains/imgur.com.js index 6552f1912..894dbf2c1 100644 --- a/plugins/domains/imgur.com.js +++ b/plugins/domains/imgur.com.js @@ -79,6 +79,7 @@ module.exports = { tests: [{ pageWithFeed: "http://imgur.com/" }, { + skipMethods: ["getData"], skipMixins: [ "twitter-image", "twitter-stream", // works for GIFvs only From 42df17c82bc010f01a4c222ebc259527d7ea6e89 Mon Sep 17 00:00:00 2001 From: Nazar Leush Date: Thu, 18 Feb 2016 21:25:33 +0200 Subject: [PATCH 137/320] [domains] imgur.com: fix oembed url to unified --- plugins/domains/imgur.com.js | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/plugins/domains/imgur.com.js b/plugins/domains/imgur.com.js index 894dbf2c1..a3a77129a 100644 --- a/plugins/domains/imgur.com.js +++ b/plugins/domains/imgur.com.js @@ -59,27 +59,22 @@ module.exports = { getData: function (meta, url, urlMatch, cb) { - if (url.indexOf('/topic/') > -1) { - var links = ['json', 'xml'].map(function(format) { - return { - href: "http://api.imgur.com/oembed." + format + "?url=http://imgur.com/" + urlMatch[1], - rel: 'alternate', - type: 'application/' + format + '+oembed' - } - }); + var links = ['json', 'xml'].map(function(format) { + return { + href: "http://api.imgur.com/oembed." + format + "?url=http://imgur.com/" + urlMatch[1], + rel: 'alternate', + type: 'application/' + format + '+oembed' + } + }); - cb(null, { - oembedLinks: links - }); - } else { - cb(); - } + cb(null, { + oembedLinks: links + }); }, tests: [{ pageWithFeed: "http://imgur.com/" }, { - skipMethods: ["getData"], skipMixins: [ "twitter-image", "twitter-stream", // works for GIFvs only From afde3be19ef93840f3541473cb3b2b6d13ca0f4e Mon Sep 17 00:00:00 2001 From: Nazar Leush Date: Thu, 18 Feb 2016 22:29:21 +0200 Subject: [PATCH 138/320] [domains] imgur.com: better oembed urls --- plugins/domains/imgur.com.js | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/plugins/domains/imgur.com.js b/plugins/domains/imgur.com.js index a3a77129a..46f866963 100644 --- a/plugins/domains/imgur.com.js +++ b/plugins/domains/imgur.com.js @@ -57,11 +57,18 @@ module.exports = { return links; }, - getData: function (meta, url, urlMatch, cb) { + getData: function (url, urlMatch, twitter, cb) { + + var isGallery = false; + var isA = url.indexOf('/a/') > -1; + + if (twitter.image && twitter.image.indexOf && twitter.image.indexOf(urlMatch[1]) > -1) { + isGallery = twitter.card !== 'player'; + } var links = ['json', 'xml'].map(function(format) { return { - href: "http://api.imgur.com/oembed." + format + "?url=http://imgur.com/" + urlMatch[1], + href: "http://api.imgur.com/oembed." + format + "?url=http://imgur.com/" + (isGallery || isA ? 'a/' : '') + urlMatch[1], rel: 'alternate', type: 'application/' + format + '+oembed' } @@ -91,6 +98,7 @@ module.exports = { "https://imgur.com/gallery/kkEzJsa", "http://imgur.com/t/workout/HFwjGoF", "http://imgur.com/t/water/ud7YwQp", - "http://imgur.com/topic/The_Oscars_&_Movies/YFQo6Vl" + "http://imgur.com/topic/The_Oscars_&_Movies/YFQo6Vl", + "http://imgur.com/a/G1oOO" ] }; \ No newline at end of file From 6b50af2ed96e756b26212a8119f2cb75aa05d9d3 Mon Sep 17 00:00:00 2001 From: Nazar Leush Date: Thu, 18 Feb 2016 22:36:23 +0200 Subject: [PATCH 139/320] [domains] imgur.com: fix oembed links overriding --- plugins/domains/imgur.com.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/plugins/domains/imgur.com.js b/plugins/domains/imgur.com.js index 46f866963..80b3a37e6 100644 --- a/plugins/domains/imgur.com.js +++ b/plugins/domains/imgur.com.js @@ -57,11 +57,13 @@ module.exports = { return links; }, - getData: function (url, urlMatch, twitter, cb) { + getData: function (url, urlMatch, meta, cb) { var isGallery = false; var isA = url.indexOf('/a/') > -1; + var twitter = meta.twitter; + if (twitter.image && twitter.image.indexOf && twitter.image.indexOf(urlMatch[1]) > -1) { isGallery = twitter.card !== 'player'; } From 5f79376446a182c09957e617714ac34fc04fc9a3 Mon Sep 17 00:00:00 2001 From: Nazar Leush Date: Thu, 18 Feb 2016 22:45:30 +0200 Subject: [PATCH 140/320] [domains] imgur.com: logic fix --- plugins/domains/imgur.com.js | 1 + 1 file changed, 1 insertion(+) diff --git a/plugins/domains/imgur.com.js b/plugins/domains/imgur.com.js index 80b3a37e6..c450a2e3f 100644 --- a/plugins/domains/imgur.com.js +++ b/plugins/domains/imgur.com.js @@ -65,6 +65,7 @@ module.exports = { var twitter = meta.twitter; if (twitter.image && twitter.image.indexOf && twitter.image.indexOf(urlMatch[1]) > -1) { + } else { isGallery = twitter.card !== 'player'; } From 64dc2814f921c72065f391c7a896b598e02ccd4b Mon Sep 17 00:00:00 2001 From: Nazar Leush Date: Fri, 19 Feb 2016 15:07:28 +0200 Subject: [PATCH 141/320] update to 0.9.3 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 8402ee20a..b81ba32f4 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "iframely", - "version": "0.9.2", + "version": "0.9.3", "description": "oEmbed/2 gateway endpoint. Get embed data for various http links through one self-hosted API", "keywords": ["oembed", "embed", "open graph", "og", "twitter cards"], From 3bf85500d38be4296aa5ec0fa623c22ace1056c5 Mon Sep 17 00:00:00 2001 From: Ivan Paramonau Date: Fri, 19 Feb 2016 09:26:19 -0500 Subject: [PATCH 142/320] [domains] fix archive.org players --- plugins/domains/archive.org.js | 45 ++++++++++++++++++++-------------- 1 file changed, 27 insertions(+), 18 deletions(-) diff --git a/plugins/domains/archive.org.js b/plugins/domains/archive.org.js index 0fced436a..f998ad340 100644 --- a/plugins/domains/archive.org.js +++ b/plugins/domains/archive.org.js @@ -12,35 +12,44 @@ module.exports = { } else { - var player = { - href: twitter.player.value || twitter.player, - type: CONFIG.T.text_html, - rel: [CONFIG.R.player, CONFIG.R.html5] - } + var playerHref = twitter.player.value || twitter.player; + var hrefMatch = playerHref.match(/^https?:\/\/archive\.org\/embed\/([^\/]+)\/?/i); - if (/\.(mp3|wma)$/i.test(player.href)) { - player.height = 40; - player["max-width"] = 776; - } + if (hrefMatch) { + var player = { + href: 'https://archive.org/embed/' + hrefMatch[1], + type: CONFIG.T.text_html, + rel: [CONFIG.R.player, CONFIG.R.html5] + } - if (/\.(mp4|avi|mov)$/i.test(player.href)) { - player["aspect-ratio"] = twitter.player.width / twitter.player.height; - } + if (/\.(mp3|wma)$/i.test(playerHref)) { + player.height = 40; + player["max-width"] = 776; + } - if (/playlist/i.test(player.href)) { - player.height = 250; - player["max-width"] = 776; - } - return player; + if (/\.(mp4|avi|mov|mpeg)$/i.test(playerHref)) { + player["aspect-ratio"] = twitter.player.width / twitter.player.height; + } + + if (/playlist/i.test(playerHref)) { + player.height = 250; + player["max-width"] = 776; + } + + return player; + } } }, tests: [ + "https://archive.org/details/Podcast8.23GoethesIronicMephistopheles1700s1800s", + "https://archive.org/details/TheInternetArchivistsFinalCutBoostedSound", "https://archive.org/details/um2000-09-01.shnf", - "https://archive.org/details/ChronoTrigger_456" + "https://archive.org/details/ChronoTrigger_456", + "https://archive.org/details/YourFami1948" ] }; \ No newline at end of file From 4d7eb03a4824f5860112878b009a94af8f9a0d2b Mon Sep 17 00:00:00 2001 From: Ivan Paramonau Date: Wed, 24 Feb 2016 11:20:46 -0500 Subject: [PATCH 143/320] =?UTF-8?q?[domains]=20bring=20back=20support=20fo?= =?UTF-8?q?r=20Lib=C3=A9ration.fr?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugins/links/promo/twitter-youtube.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/plugins/links/promo/twitter-youtube.js b/plugins/links/promo/twitter-youtube.js index 7dcdefa97..f54b91922 100644 --- a/plugins/links/promo/twitter-youtube.js +++ b/plugins/links/promo/twitter-youtube.js @@ -43,7 +43,8 @@ module.exports = { // or DailyMotion, e.g. Liberation, Le Point, L'Express - urlMatch = video_src.match(/^https?:\/\/www\.dailymotion\.com\/(?:swf|embed)?\/?video\/([_a-zA-Z0-9\-]+)/i); + urlMatch = video_src.match(/^https?:\/\/www\.dailymotion\.com\/(?:swf|embed)?\/?video\/([_a-zA-Z0-9\-]+)/i) + || video_src.match(/^https?:\/\/dai.ly\/([_a-zA-Z0-9\-]+)/i); // e.g. Libération.fr if (urlMatch) { return { From 09945124e8029a158282e7fcec7ceb5ce6115204 Mon Sep 17 00:00:00 2001 From: Ivan Paramonau Date: Wed, 24 Feb 2016 14:25:43 -0500 Subject: [PATCH 144/320] [generic] try and fix user errors in MIME types for og:images --- plugins/links/og-image.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/links/og-image.js b/plugins/links/og-image.js index a0e4af6a4..599bd7276 100644 --- a/plugins/links/og-image.js +++ b/plugins/links/og-image.js @@ -6,7 +6,7 @@ function getImageLinks(image) { var images = [{ href: image.url || image, - type: image.type || CONFIG.T.image, + type: image.type && /^image\//i.test(image.type) ? image.type : CONFIG.T.image, rel: rel, width: image.width, height: image.height @@ -15,7 +15,7 @@ function getImageLinks(image) { if (image.secure_url) { images.push({ href: image.secure_url, - type: image.type || CONFIG.T.image, + type: image.type && /^image\//i.test(image.type) ? image.type : CONFIG.T.image, rel: rel, width: image.width, height: image.height From 60641ade392df1ccf83016163789d610f93e5822 Mon Sep 17 00:00:00 2001 From: Ivan Paramonau Date: Wed, 24 Feb 2016 15:07:46 -0500 Subject: [PATCH 145/320] [generic] follow http-equiv refresh-redirects when required --- lib/plugins/system/meta/HTMLMetaHandler.js | 11 +++++++++++ lib/plugins/system/meta/meta.js | 6 ++++++ 2 files changed, 17 insertions(+) diff --git a/lib/plugins/system/meta/HTMLMetaHandler.js b/lib/plugins/system/meta/HTMLMetaHandler.js index acbdff1b5..d5748d76b 100644 --- a/lib/plugins/system/meta/HTMLMetaHandler.js +++ b/lib/plugins/system/meta/HTMLMetaHandler.js @@ -90,6 +90,15 @@ HTMLMetaHandler.prototype.onopentag = function(name, attributes) { this._customProperties["x-frame-options"] = metaTag.content; + } else if (!this._refresh && metaTag['http-equiv'] && metaTag['http-equiv'].toLowerCase() == 'refresh') { + + // ex.: http://tv.sme.sk/v/29770/kalinak-o-ficovi-cudujem-sa-ze-vedie-vladu.html + var refresh = metaTag.content && metaTag.content.match(/url=(?:'|")?([^'"]+)(?:'|")?/i); + + if (refresh) { + this._refresh = refresh[1]; + } + } else if (metaTag.name == "description") { this._customProperties["html-description"] = metaTag.content; @@ -313,6 +322,8 @@ HTMLMetaHandler.prototype._finalMerge = function() { this._result['charset'] = this._charset || 'UTF-8'; + if (this._refresh) {this._result['refresh'] = this._refresh;} + this._callback(null, this._result); }; diff --git a/lib/plugins/system/meta/meta.js b/lib/plugins/system/meta/meta.js index d1aef427f..572cd0041 100644 --- a/lib/plugins/system/meta/meta.js +++ b/lib/plugins/system/meta/meta.js @@ -25,6 +25,12 @@ module.exports = { }); } + if (meta.refresh && !(meta['html-title'] && meta['html-title'] !== '')) { + return cb({ + redirect: meta.refresh + }); + } + var meta_key = 'meta:' + url; cache.set(meta_key, meta); From 5317bf1381cdd89222f43dab14efdfdc24467ac5 Mon Sep 17 00:00:00 2001 From: Ivan Paramonau Date: Wed, 24 Feb 2016 15:43:54 -0500 Subject: [PATCH 146/320] [generic] proper media detector for oembed video --- plugins/links/oembed-video.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/plugins/links/oembed-video.js b/plugins/links/oembed-video.js index 7cd128591..fdc421478 100644 --- a/plugins/links/oembed-video.js +++ b/plugins/links/oembed-video.js @@ -51,9 +51,12 @@ module.exports = { }, - getMeta: function(oembed) { + highestPriority: true, - if (oembed.type === "video" || oembed.type === "audio") { + getMeta: function(oembed, whitelistRecord) { + + if (oembed.type === "video" || oembed.type === "audio" + || (oembed.type === "rich" && !whitelistRecord.isDefault && whitelistRecord.isAllowed('oembed.rich') && whitelistRecord.isAllowed('oembed.rich', "player")) ) { return { media: "player" }; From c354a5dde3a45c395e81d294736f36e5a817532a Mon Sep 17 00:00:00 2001 From: Ivan Paramonau Date: Fri, 26 Feb 2016 12:56:30 -0500 Subject: [PATCH 147/320] [domains] support screenshots of hosted CloudApps --- plugins/links/promo/cloudapp-hosted.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 plugins/links/promo/cloudapp-hosted.js diff --git a/plugins/links/promo/cloudapp-hosted.js b/plugins/links/promo/cloudapp-hosted.js new file mode 100644 index 000000000..6469f1b7e --- /dev/null +++ b/plugins/links/promo/cloudapp-hosted.js @@ -0,0 +1,16 @@ +module.exports = { + + getLink: function(twitter) { + + if (twitter.card === "photo" && twitter.site === '@cloudapp' + && twitter.image && /^https?:\/\/f\.cl\.ly\//.test(twitter.image.url || twitter.image.src || twitter.image)) { + + return { + href: twitter.image.url || twitter.image.src || twitter.image, + type: CONFIG.T.image, + rel: CONFIG.R.image + }; + } + + } +}; \ No newline at end of file From c8472607f52e57ab667da4574c42b9fd77997722 Mon Sep 17 00:00:00 2001 From: Ivan Paramonau Date: Fri, 26 Feb 2016 13:15:12 -0500 Subject: [PATCH 148/320] [domains] add upload date for Vimeo --- plugins/domains/vimeo.com.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/plugins/domains/vimeo.com.js b/plugins/domains/vimeo.com.js index 9d5b4cf6a..cb13e9330 100644 --- a/plugins/domains/vimeo.com.js +++ b/plugins/domains/vimeo.com.js @@ -13,7 +13,8 @@ module.exports = { getMeta: function(oembed) { return { - canonical: "https://vimeo.com/" + oembed.video_id + canonical: "https://vimeo.com/" + oembed.video_id, + date: oembed.upload_date }; }, From e7b151ef7a0151c5ca7938605bf3da572e2eacb5 Mon Sep 17 00:00:00 2001 From: Ivan Paramonau Date: Fri, 26 Feb 2016 14:07:19 -0500 Subject: [PATCH 149/320] [domains] support for vbox7.com --- plugins/domains/vbox7.com.js | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 plugins/domains/vbox7.com.js diff --git a/plugins/domains/vbox7.com.js b/plugins/domains/vbox7.com.js new file mode 100644 index 000000000..bcde7a91f --- /dev/null +++ b/plugins/domains/vbox7.com.js @@ -0,0 +1,22 @@ +module.exports = { + + re: [ + /https?:\/\/vbox7\.com\/play:(\w+)/i + ], + + mixins: ["*"], + + getLinks: function(urlMatch) { + + return { + href: "//vbox7.com/emb/external.php?vid=" + urlMatch[1], + type: CONFIG.T.text_html, + rel: [CONFIG.R.player, CONFIG.R.html5], + "aspect-ratio": 16 / 9 + } + }, + + tests: [ + "http://vbox7.com/play:86abb51a7d?pos=src" + ] +}; \ No newline at end of file From eff4aba7561186f9384a8b32e95166023ddaa857 Mon Sep 17 00:00:00 2001 From: Ivan Paramonau Date: Fri, 26 Feb 2016 14:19:17 -0500 Subject: [PATCH 150/320] [domains] fix scrollbars in NBC News players --- plugins/domains/nbcnews.com.js | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 plugins/domains/nbcnews.com.js diff --git a/plugins/domains/nbcnews.com.js b/plugins/domains/nbcnews.com.js new file mode 100644 index 000000000..5ba7b619e --- /dev/null +++ b/plugins/domains/nbcnews.com.js @@ -0,0 +1,34 @@ +module.exports = { + + mixins: [ + "*" + ], + + highestPriority: true, + + getMeta: function (schemaVideoObject) { + + // if schemaVideoObject -> media=player + return { + media: "player" + } + + }, + + getLink: function(schemaVideoObject) { + + if (schemaVideoObject.embedURL || schemaVideoObject.embedUrl) { + + return { + href: schemaVideoObject.embedURL || schemaVideoObject.embedUrl, + rel: [CONFIG.R.player, CONFIG.R.html5], + type: CONFIG.T.text_html, + "aspect-ratio": 4/3 // Fixes it for NBC news + }; + } + }, + + tests: [ + "http://www.nbcnews.com/nightly-news/nypds-wenjian-liu-remembered-wake-n279116" + ] +}; \ No newline at end of file From 2b8a32c804ff5ca431c764cc6bd1c5d529387234 Mon Sep 17 00:00:00 2001 From: Ivan Paramonau Date: Fri, 26 Feb 2016 14:58:31 -0500 Subject: [PATCH 151/320] [domains] fix broken twitter player for Yahoo videos --- plugins/domains/yahoo.video.js | 41 ++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 plugins/domains/yahoo.video.js diff --git a/plugins/domains/yahoo.video.js b/plugins/domains/yahoo.video.js new file mode 100644 index 000000000..b3cf59dca --- /dev/null +++ b/plugins/domains/yahoo.video.js @@ -0,0 +1,41 @@ +module.exports = { + + re: [ + /https?:\/\/[\w\.]+yahoo\.com\//i + ], + + mixins: ["*"], + + highestPriority: true, + + getMeta: function(twitter) { + + if (twitter.card == 'player') { + + return { + media: "player" + } + } + }, + + getLinks: function(twitter) { + + if (twitter.card == 'player' && !/\?format=embed$/i.test(twitter.player.value || twitter.player)) { + + return { + href: (twitter.player.value || twitter.player) + '?format=embed', + type: CONFIG.T.text_html, + rel: [CONFIG.R.player, CONFIG.R.html5], + "aspect-ratio": twitter.player.width / twitter.player.height + } + } + }, + + tests: [ + "https://ca.news.yahoo.com/video/unicorn-leads-california-highway-patrol-134024517.html", + "https://uk.news.yahoo.com/video/cctv-shows-london-thieves-moped-164116329.html", + "https://br.noticias.yahoo.com/video/colombiano-cria-biblioteca-com-livros-173319839.html", + "https://screen.yahoo.com/miles-ahead-clip-gone-153000608.html", + "https://movies.yahoo.com/video/crimson-peak-clip-proper-welcome-153000548.html" + ] +}; \ No newline at end of file From 577d2162904a4442f1f69a3fa8a31db30becf192 Mon Sep 17 00:00:00 2001 From: Ivan Paramonau Date: Fri, 26 Feb 2016 15:18:19 -0500 Subject: [PATCH 152/320] [domains] support Knightlab's juxtapose and timeline.js --- plugins/domains/knightlab.js | 29 +++++++++++++++++++++++++++++ plugins/domains/storymap.js | 22 ---------------------- 2 files changed, 29 insertions(+), 22 deletions(-) create mode 100644 plugins/domains/knightlab.js delete mode 100644 plugins/domains/storymap.js diff --git a/plugins/domains/knightlab.js b/plugins/domains/knightlab.js new file mode 100644 index 000000000..69f8c25e2 --- /dev/null +++ b/plugins/domains/knightlab.js @@ -0,0 +1,29 @@ +module.exports = { + + re: [ + /^https?:\/\/s3\.amazonaws\.com\/(?:uploads|CDN)\.knightlab\.com\/(storymapjs)\/\w+\/(?:[a-zA-Z0-9\-\/]+)\.html/i, + /^https?:\/\/cdn\.knightlab\.com\/libs\/(storymapjs)\/(?:dev|latest)\/embed\//, + /^https?:\/\/cdn\.knightlab\.com\/libs\/(juxtapose|timeline3?)\/(?:dev|latest)\/embed\/index\.html\?/ + ], + + mixins: ["*"], + + getLink: function(url, urlMatch) { + + return { + href: url + (url.indexOf('?') > -1 ? '&' :'?') + 'for=iframely', + type: CONFIG.T.text_html, + rel: [CONFIG.R.app, CONFIG.R.html5], + "height": urlMatch[1] == 'storymapjs' ? 800 : urlMatch[1] == 'juxtapose' ? 360: 650 + }; + }, + + tests: [ + "https://s3.amazonaws.com/uploads.knightlab.com/storymapjs/86a5b5c6facef8e74eb685573b846f6b/civilian-deaths-evidence-of-war-crimes-in-yemen/index.html", + "http://cdn.knightlab.com/libs//latest/embed/index.html?source=1t9XBaa5oqMpwgi49smaUdk269PL0miJ-xtjsuExOZwQ&font=Default&lang=en&initial_zoom=100&height=650", + "https://cdn.knightlab.com/libs/juxtapose/latest/embed/index.html?uid=f9031656-dcc3-11e5-a524-0e7075bba956", + "http://cdn.knightlab.com/libs/juxtapose/dev/embed/index.html?uid=75ec66e0-204a-11e5-91b9-0e7075bba956", + "http://cdn.knightlab.com/libs/timeline/latest/embed/index.html?source=0Atwxho6G5yhjdEdJNU1JMzhLdjdHUTFMNnc4bHNud3c&font=PTSerif-PTSans&maptype=toner&lang=en&hash_bookmark=true&start_zoom_adjust=2&height=650#13", + "http://cdn.knightlab.com/libs/storymapjs/latest/embed/?url=https://10113115706d4ad7837a4a5dd2c4cf80328d7999.googledrive.com/host/0B91AkpxdaWYyUmFYQ1Rlbmctd1k/published.json" + ] +}; \ No newline at end of file diff --git a/plugins/domains/storymap.js b/plugins/domains/storymap.js deleted file mode 100644 index c2ad1e5fe..000000000 --- a/plugins/domains/storymap.js +++ /dev/null @@ -1,22 +0,0 @@ -module.exports = { - - re: [ - /^https?:\/\/s3\.amazonaws\.com\/(uploads|CDN)\.knightlab\.com\/storymapjs\/\w+\/([a-zA-Z0-9\-\/]+)\.html/i - ], - - mixins: ["*"], - - getLink: function(url) { - - return { - href: url + '?for=iframely', - type: CONFIG.T.text_html, - rel: [CONFIG.R.app, CONFIG.R.html5], - "height": 800 - }; - }, - - tests: [ - "https://s3.amazonaws.com/uploads.knightlab.com/storymapjs/86a5b5c6facef8e74eb685573b846f6b/civilian-deaths-evidence-of-war-crimes-in-yemen/index.html" - ] -}; \ No newline at end of file From b0fc497249d45f51a9369b1d42979ff5f44f9e94 Mon Sep 17 00:00:00 2001 From: Nazar Leush Date: Mon, 29 Feb 2016 14:52:33 +0200 Subject: [PATCH 153/320] [config] allow use proxy server for custom urls --- config.local.js.SAMPLE | 5 +++++ lib/plugins/system/oembed/oembedUtils.js | 1 + lib/utils.js | 18 ++++++++++++++++-- 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/config.local.js.SAMPLE b/config.local.js.SAMPLE index a80c0c51b..d1d242e7e 100644 --- a/config.local.js.SAMPLE +++ b/config.local.js.SAMPLE @@ -97,6 +97,11 @@ } }], + PROXY: [{ + re: [/^https?:\/\/www\.domain\.com/], + proxy_server: 'http://1.2.3.4:8080' + }] + // Customize API calls to 3rd parties. At the very least - configure required keys. providerOptions: { "twitter": { diff --git a/lib/plugins/system/oembed/oembedUtils.js b/lib/plugins/system/oembed/oembedUtils.js index 3459e0d79..581c594d1 100644 --- a/lib/plugins/system/oembed/oembedUtils.js +++ b/lib/plugins/system/oembed/oembedUtils.js @@ -123,6 +123,7 @@ module.exports.getOembed = function(uri, options, callback) { } try { + // TODO: make 'for'. var params = _.find(ADD_OEMBED_PARAMS, function (params) { return _.find(params.re, function (re) { return uri.match(re); diff --git a/lib/utils.js b/lib/utils.js index 8c64c5ea8..54ec2d37a 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -41,7 +41,7 @@ var getUrl = exports.getUrl = function(url, options) { var supportGzip = !process.version.match(/^v0\.8/); - var r = request({ + var request_options = { uri: url, method: 'GET', headers: { @@ -53,7 +53,21 @@ var getUrl = exports.getUrl = function(url, options) { timeout: options.timeout || CONFIG.RESPONSE_TIMEOUT, followRedirect: options.followRedirect, jar: jar - }) + }; + + if (CONFIG.PROXY) { + // TODO: make 'for'. + var proxy = _.find(CONFIG.PROXY, function (p) { + return _.find(p.re, function (re) { + return url.match(re); + }); + }); + if (proxy) { + request_options.proxy = proxy.proxy_server; + } + } + + var r = request(request_options) .on('error', function(error) { req.emit('error', error); }) From 7a49c788357e984060f7fc1ba8f97b3bd1e78684 Mon Sep 17 00:00:00 2001 From: Ivan Paramonau Date: Mon, 29 Feb 2016 10:32:12 -0500 Subject: [PATCH 154/320] [domains] add Deezer (requires non-US proxy) --- plugins/domains/deezer.com.js | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 plugins/domains/deezer.com.js diff --git a/plugins/domains/deezer.com.js b/plugins/domains/deezer.com.js new file mode 100644 index 000000000..2645d2da8 --- /dev/null +++ b/plugins/domains/deezer.com.js @@ -0,0 +1,32 @@ +module.exports = { + + mixins: [ + "*" + ], + + getLink: function(url, twitter) { + + if (twitter.card !== 'player' || !twitter.player) { + + return; + + } else { + + return { + href: /\/track\//i.test(url) ? twitter.player.value.replace(/&height=\d+/i, '&height=92') : twitter.player.value, + type: CONFIG.T.text_html, + rel: [CONFIG.R.player, CONFIG.R.html5], + height: /\/track\//i.test(url) ? 92 : twitter.player.height + } + + } + + }, + + tests: [ + "http://www.deezer.com/track/11523496", + "http://www.deezer.com/track/61423083", + "http://www.deezer.com/album/11417888", + "http://www.deezer.com/album/1215117" + ] +}; \ No newline at end of file From b0ea30885eaaea53c82dda599be61051b4b00ba2 Mon Sep 17 00:00:00 2001 From: Ivan Paramonau Date: Wed, 2 Mar 2016 08:29:06 -0500 Subject: [PATCH 155/320] [domains] Gfycat has fixed iFrame embeds --- plugins/{domains => .noneed}/gfycat.com.js | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename plugins/{domains => .noneed}/gfycat.com.js (100%) diff --git a/plugins/domains/gfycat.com.js b/plugins/.noneed/gfycat.com.js similarity index 100% rename from plugins/domains/gfycat.com.js rename to plugins/.noneed/gfycat.com.js From ea823c0840a1a4553d177d5097f1f268fc60baa9 Mon Sep 17 00:00:00 2001 From: Ivan Paramonau Date: Wed, 2 Mar 2016 10:12:34 -0500 Subject: [PATCH 156/320] [domains] better international URLs for Amazon --- plugins/domains/amazon.com.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/domains/amazon.com.js b/plugins/domains/amazon.com.js index 37ccaf682..d5c4f5024 100644 --- a/plugins/domains/amazon.com.js +++ b/plugins/domains/amazon.com.js @@ -3,8 +3,8 @@ var $ = require('cheerio'); module.exports = { re: [ - /^https?:\/\/www\.amazon\.(com|ca|com\.au|be|dk|de|es|fr|in|ie|it|nl|co\.nz|no|at|pt|ch|fi|se|ae|pl|co\.uk|co\.jp)\/([a-zA-Z0-9\-]+\/)?dp\/[a-zA-Z0-9\-]+/i, - /^https?:\/\/www\.amazon\.(com|ca|com\.au|be|dk|de|es|fr|in|ie|it|nl|co\.nz|no|at|pt|ch|fi|se|ae|pl|co\.uk|co\.jp)\/gp\/product\/[a-zA-Z0-9\-]+/i + /^https?:\/\/www\.amazon\.(com|ca|com\.au|be|dk|de|es|fr|in|ie|it|nl|co\.nz|no|at|pt|ch|fi|se|ae|pl|co\.uk|co\.jp)\/([a-zA-Z0-9\-%]+\/)?dp\/[a-zA-Z0-9\-]+/i, + /^https?:\/\/www\.amazon\.(com|ca|com\.au|be|dk|de|es|fr|in|ie|it|nl|co\.nz|no|at|pt|ch|fi|se|ae|pl|co\.uk|co\.jp)\/gp\/product\/[a-zA-Z0-9\-%]+/i ], provides: "__isAmazonImageNeeded", From da2d852ba3106de9fe03dcf1e052aea575b34d7f Mon Sep 17 00:00:00 2001 From: Ivan Paramonau Date: Wed, 2 Mar 2016 16:02:39 -0500 Subject: [PATCH 157/320] [domains] video.hhl.com got issues old SSL cipher --- plugins/domains/video.nhl.com.js | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 plugins/domains/video.nhl.com.js diff --git a/plugins/domains/video.nhl.com.js b/plugins/domains/video.nhl.com.js new file mode 100644 index 000000000..eb4d2599c --- /dev/null +++ b/plugins/domains/video.nhl.com.js @@ -0,0 +1,20 @@ +module.exports = { + + mixins: ["*"], + + getLink: function(twitter) { + + if (twitter.player) { + return { + href: (twitter.player.value || twitter.player).replace(/^https:\/\//, 'http://').replace(/&?twitter=true/, ''), + type: CONFIG.T.text_html, + rel: [CONFIG.R.player, CONFIG.R.html5], + "aspect-ration": twitter.player.width / twitter.player.height + }; + } + }, + + tests: [ + "http://video.nhl.com/videocenter/console?catid=917&id=263236" + ] +}; \ No newline at end of file From 4dfd8b951e3d1fe8e2e9745bd58f3aca9ebbdcde Mon Sep 17 00:00:00 2001 From: Ivan Paramonau Date: Thu, 3 Mar 2016 07:27:08 -0500 Subject: [PATCH 158/320] [domains] Pinterest allows underscores in user names --- plugins/domains/pinterest.com/pinterest.board.js | 2 +- plugins/domains/pinterest.com/pinterest.user.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/domains/pinterest.com/pinterest.board.js b/plugins/domains/pinterest.com/pinterest.board.js index bb7da9766..14af12c33 100644 --- a/plugins/domains/pinterest.com/pinterest.board.js +++ b/plugins/domains/pinterest.com/pinterest.board.js @@ -2,7 +2,7 @@ var DEFAULT_WIDTH = 600; module.exports = { - re: /^https?:\/\/(?:www\.)?pinterest\.com\/((?!pin)[a-zA-Z0-9%]+)\/([a-zA-Z0-9%\-]+)\/?(?:$|\?|#)/i, + re: /^https?:\/\/(?:www\.)?pinterest\.com\/((?!pin)[a-zA-Z0-9%_]+)\/([a-zA-Z0-9%\-]+)\/?(?:$|\?|#)/i, mixins: [ "*" diff --git a/plugins/domains/pinterest.com/pinterest.user.js b/plugins/domains/pinterest.com/pinterest.user.js index bdc9a0af1..0f2a8c375 100644 --- a/plugins/domains/pinterest.com/pinterest.user.js +++ b/plugins/domains/pinterest.com/pinterest.user.js @@ -2,7 +2,7 @@ var DEFAULT_WIDTH = 600; module.exports = { - re: /^https?:\/\/(?:www\.)?pinterest\.com\/((?!pin)[a-zA-Z0-9%]+)\/?(?:$|\?|#)/i, + re: /^https?:\/\/(?:www\.)?pinterest\.com\/((?!pin)[a-zA-Z0-9%_]+)\/?(?:$|\?|#)/i, mixins: [ "og-image", From 6bf22c722a35175f1cb97c61ad9d27240fca7d04 Mon Sep 17 00:00:00 2001 From: Ivan Paramonau Date: Wed, 9 Mar 2016 12:05:24 -0500 Subject: [PATCH 159/320] [domains] return ESPN though old twitter player --- plugins/domains/espn.com.js | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 plugins/domains/espn.com.js diff --git a/plugins/domains/espn.com.js b/plugins/domains/espn.com.js new file mode 100644 index 000000000..150a04a8c --- /dev/null +++ b/plugins/domains/espn.com.js @@ -0,0 +1,29 @@ +module.exports = { + + re: [ + /https?:\/\/espn\.go\.com\/video\/clip\?id=(espn):(\d+)/i, + /https?:\/\/xgames\.espn\.go\.com\/(xgames)\/video\/(\d+)\//i + ], + + mixins: ["*"], + + getLink: function(urlMatch) { + + // Fallback to Twitter:player as it was before March 8, 2016 + + var player_id = urlMatch[1] === 'xgmames' ? 'id=' + urlMatch[2] + '&omniReportSuite=wdgespexpn' : + 'cms=espn&id=espn:' + urlMatch[2]; + + return { + href: 'https://espn.go.com/video/iframe/twitter/?' + player_id, + type: CONFIG.T.maybe_text_html, // ping href to check that it doesn't 404 + rel: [CONFIG.R.player, CONFIG.R.html5], + "aspect-ratio": 16/9 + }; + }, + + tests: [ + "http://espn.go.com/video/clip?id=espn:14780138", + "http://xgames.espn.go.com/xgames/video/13380522/real-moto-drake-mcelroy" + ] +}; \ No newline at end of file From 1a069c5fcbc512d370e049efda1424fe209f9f3e Mon Sep 17 00:00:00 2001 From: Nazar Leush Date: Fri, 11 Mar 2016 20:14:53 +0200 Subject: [PATCH 160/320] [utils] allow generate --- lib/html-utils.js | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/lib/html-utils.js b/lib/html-utils.js index 9c181c61e..48505af37 100644 --- a/lib/html-utils.js +++ b/lib/html-utils.js @@ -212,12 +212,25 @@ }, generate: function(data, options) { - var $iframe = $('