@@ -6,10 +6,9 @@ import ModalActions from './../components/Modal/actions';
6
6
import torrentActions from './../actions/torrentActions' ;
7
7
import Promise from 'bluebird' ;
8
8
import _ from 'lodash' ;
9
- import ytdl from 'youtube-dl ' ;
9
+ import sources from './../components/Player/utils/sources.js ' ;
10
10
import ytdlSupported from './../components/Player/utils/ytdl-extractor' ;
11
11
import plugins from './plugins' ;
12
- import ls from 'local-storage' ;
13
12
14
13
module . exports = ( inputvalue ) => {
15
14
return new Promise ( ( resolve , reject ) => {
@@ -60,36 +59,24 @@ module.exports = (inputvalue) => {
60
59
} ) , 1000 ) ;
61
60
} else {
62
61
// try youtube-dl with it, use media scanner as a fallback
63
- var ytdlArgs = [ '-g' ] ;
64
-
65
- if ( ls ( 'ytdlQuality' ) < 4 ) {
66
- var qualities = [ 360 , 480 , 720 , 1080 ] ;
67
- ytdlArgs . push ( '-f' ) ;
68
- ytdlArgs . push ( '[height <=? ' + qualities [ ls ( 'ytdlQuality' ) ] + ']' ) ;
69
- }
70
-
71
- var video = ytdl ( parsed . url , ytdlArgs ) ;
72
-
73
- video . on ( 'error' , function ( err ) {
74
- ModalActions . close ( ) ;
75
- console . log ( 'ytdl ending error' ) ;
76
- reject ( new Error ( 'Error: Invalid URL' ) ) ;
77
- } ) ;
78
-
79
- video . on ( 'info' , function ( info ) {
62
+ sources . youtubeDL ( parsed . url , function ( info ) {
80
63
if ( info . url ) {
81
64
ModalActions . close ( ) ;
82
65
console . log ( info ) ;
83
66
PlayerActions . addPlaylist ( [ {
84
67
originalURL : inputvalue ,
85
- uri : parsed . url ,
68
+ uri : info . url ,
86
69
youtubeDL : true ,
87
70
image : info . thumbnail ,
88
71
title : info . fulltitle
89
72
} ] ) ;
90
73
resolve ( parsed . url ) ;
91
74
} else parseLinks ( plugin && plugin . checkFor ? plugin : null ) ;
92
- } ) ;
75
+ } , function ( err ) {
76
+ ModalActions . close ( ) ;
77
+ console . log ( 'ytdl ending error' ) ;
78
+ reject ( new Error ( 'Error: Invalid URL' ) ) ;
79
+ } )
93
80
}
94
81
95
82
}
@@ -110,26 +97,22 @@ module.exports = (inputvalue) => {
110
97
if ( perfectMatch || ytdlSupported ( parsed . url ) ) {
111
98
// a perfect match or a youtube-dl regex match should be
112
99
// sent directly to youtube-dl for processing
113
- var video = ytdl ( parsed . url , [ '-g' ] ) ;
114
-
115
- video . on ( 'error' , function ( err ) {
116
- parseLinks ( plugin && plugin . checkFor ? plugin : null ) ;
117
- } ) ;
118
-
119
- video . on ( 'info' , function ( info ) {
100
+ sources . youtubeDL ( parsed . url , function ( info ) {
120
101
if ( info . url ) {
121
102
ModalActions . close ( ) ;
122
103
console . log ( info ) ;
123
104
PlayerActions . addPlaylist ( [ {
124
105
originalURL : inputvalue ,
125
- uri : parsed . url ,
106
+ uri : info . url ,
126
107
youtubeDL : true ,
127
108
image : info . thumbnail ,
128
109
title : info . fulltitle
129
110
} ] ) ;
130
111
resolve ( parsed . url ) ;
131
112
} else parseLinks ( plugin && plugin . checkFor ? plugin : null ) ;
132
- } ) ;
113
+ } , function ( err ) {
114
+ parseLinks ( plugin && plugin . checkFor ? plugin : null ) ;
115
+ } )
133
116
134
117
} else {
135
118
parseLinks ( plugin && plugin . checkFor ? plugin : null ) ;
0 commit comments