Skip to content

Commit 5149524

Browse files
committed
fix youtube.video
1 parent 579f1ce commit 5149524

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

plugins/domains/youtube.com/youtube.video.js

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -254,19 +254,18 @@ export default {
254254
var rels = [CONFIG.R.player];
255255

256256
if (youtube_video_gdata.playerHtml) { // maybe still widescreen. plus detect 'allow' from html
257-
// TODO: fix using cheerio
258-
var $container = cheerio('<div>');
257+
var $iframe = null;
259258
try {
260-
$container.html(youtube_video_gdata.playerHtml);
259+
$iframe = cheerio.load(youtube_video_gdata.playerHtml)('iframe');
261260
} catch (ex) {}
262261

263-
var $iframe = $container.find('iframe');
264-
265-
if (!widescreen && $iframe.length == 1 && $iframe.attr('width') && $iframe.attr('height') && $iframe.attr('height') > 0) {
266-
widescreen = $iframe.attr('width') / $iframe.attr('height') > 1.35;
267-
}
268-
if ($iframe.attr('allow')) {
269-
rels = rels.concat($iframe.attr('allow').replace(/autoplay;?\s?/ig, '').split(/\s?;\s?/g));
262+
if ($iframe && $iframe.length) {
263+
if (!widescreen && $iframe.length == 1 && $iframe.attr('width') && $iframe.attr('height') && $iframe.attr('height') > 0) {
264+
widescreen = $iframe.attr('width') / $iframe.attr('height') > 1.35;
265+
}
266+
if ($iframe.attr('allow')) {
267+
rels = rels.concat($iframe.attr('allow').replace(/autoplay;?\s?/ig, '').split(/\s?;\s?/g));
268+
}
270269
}
271270
}
272271
// End of widescreen & allow check

0 commit comments

Comments
 (0)