@@ -46,20 +46,6 @@ if (fallArg === '-f' || fallArg === '--fun') {
4646process . exit ( 1 ) ;
4747}
4848
49- // Functions, because I'm planning to add few more features.
50-
51- const detectFile = arg => {
52- return arg . split ( `twitter:player:stream:content_type" content="` ) [ 1 ] . split ( '">' ) [ 0 ] . replace ( '/mp4' , '' ) ;
53- } ;
54-
55- const detectMediaSource = arg => {
56- return arg . split ( `twitter:player:stream" content="` ) [ 1 ] . split ( '">' ) [ 0 ] ;
57- } ;
58-
59- const decodeMediaScript = source => {
60- return source . replace ( / a m p ; / g, '' ) ;
61- } ;
62-
6349const songName = arg => {
6450return arg . split ( '/' ) [ 4 ] ;
6551} ;
@@ -75,9 +61,9 @@ if (isURL(fallArg) === true) {
7561spinner . start ( ) ;
7662got ( fallArg ) . then ( res => {
7763const $ = res . body ;
78- const mediaType = detectFile ( $ ) ;
79- const mediaSource = detectMediaSource ( $ ) ;
80- const fetchMainSource = decodeMediaScript ( mediaSource ) ;
64+ const mediaType = $ . split ( `twitter:player:stream:content_type" content="` ) [ 1 ] . split ( '">' ) [ 0 ] . replace ( '/mp4' , '' ) ;
65+ const mediaSource = $ . split ( `twitter:player:stream" content="` ) [ 1 ] . split ( '">' ) [ 0 ] ;
66+ const fetchMainSource = mediaSource . replace ( / a m p ; / g , '' ) ;
8167logUpdate ( ) ;
8268spinner . text = chalk . dim ( 'Fetching downloadable link' ) ;
8369
@@ -107,6 +93,8 @@ if (isURL(fallArg) === true) {
10793} ) ;
10894} ) . catch ( err => {
10995if ( err ) {
96+ logUpdate ( `\n ${ pre } ${ chalk . dim ( 'Broken link or maybe the song has been removed!' ) } \n` ) ;
97+ spinner . stop ( ) ;
11098process . exit ( 1 ) ;
11199}
112100} ) ;
0 commit comments