File tree Expand file tree Collapse file tree 1 file changed +9
-10
lines changed
plugins/domains/youtube.com Expand file tree Collapse file tree 1 file changed +9
-10
lines changed Original file line number Diff line number Diff 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 ( / a u t o p l a y ; ? \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 ( / a u t o p l a y ; ? \s ? / ig , '' ) . split ( / \s ? ; \s ? / g ) ) ;
268+ }
270269 }
271270 }
272271 // End of widescreen & allow check
You can’t perform that action at this time.
0 commit comments