@@ -423,19 +423,25 @@ def downloadSongs(songs_json, album_name='songs', artist_name='Non-Artist'):
423423 downloadArtistAllSongs (artistId , artist_json )
424424 else :
425425 input_url = input ('Enter album/playlist url: ' ).strip ()
426+ proxies , headers = setProxy ()
426427 try :
427- proxies , headers = setProxy ()
428- res = requests .get (input_url , proxies = proxies , headers = headers )
429- soup = BeautifulSoup (res .text , "lxml" )
430- playlist_id = soup .find_all ("script" )[39 ].string [1969 :][:12 ]
431- album_id = soup .find_all ("script" )[39 ].string [687 :][:12 ]
432428 if re .search ("album" , input_url ):
429+ album_hash = input_url .split ("/" )[- 1 ]
430+ url = "https://www.jiosaavn.com/api.php?__call=webapi.get&token={0}&type=album&p=1&n=20&includeMetaTags=0&ctx=wap6dot0&api_version=4&_format=json&_marker=0" .format (album_hash )
431+ res = requests .get (url , proxies = proxies , headers = headers )
432+ album_json = [x for x in res .text .splitlines ()
433+ if x .strip ().startswith ('{' )][0 ]
434+ album_json = json .loads (album_json )
433435 print ("Downloading Album" )
434- album_id = '' .join ([s for s in album_id if s .isdigit ()])
435- downloadAlbum (album_id )
436+ downloadAlbum (album_json ["id" ])
436437 else :
437438 print ("Downloading Playlist" )
438- playlist_id = '' .join ([s for s in playlist_id if s .isdigit ()])
439- downloadSongs (getPlayList (playlist_id ))
439+ playlist_hash = input_url .split ("/" )[- 1 ]
440+ url = "https://www.jiosaavn.com/api.php?__call=webapi.get&token={0}&type=playlist&p=1&n=20&includeMetaTags=0&ctx=wap6dot0&api_version=4&_format=json&_marker=0" .format (playlist_hash )
441+ res = requests .get (url , proxies = proxies , headers = headers )
442+ playlist_json = [x for x in res .text .splitlines ()
443+ if x .strip ().startswith ('{' )][0 ]
444+ playlist_json = json .loads (playlist_json )
445+ downloadSongs (getPlayList (playlist_json ["id" ]))
440446 except Exception as e :
441447 print ("Please paste album/playlist url" )
0 commit comments