diff --git a/download_reloaded.py b/download_reloaded.py index 91e9a60..2917c85 100644 --- a/download_reloaded.py +++ b/download_reloaded.py @@ -7,6 +7,15 @@ from scripts.content.artist import Artist from scripts.content.song import Song from scripts.saavnaccount import Account +# https://www.jiosaavn.com/album/vinayagar-murugan-songs---tamil-devotional/UFPWAMwxX38_ +# https://www.jiosaavn.com/album/tamil-hindu-devotional-songs/d9Tny456ayc_ +# https://www.jiosaavn.com/album/deivam-thiruvarul/EZ60Zr-SVMc_ +# https://www.jiosaavn.com/album/deivam-thiruvarul/EZ60Zr-SVMc_ +# https://www.jiosaavn.com/featured/muruga-muruga/1m1Gmji50rQ_ +# https://www.jiosaavn.com/album/skantha-shasti-kavacham---sumangalam-sisters/TTeIUfdSZXs_ +# https://www.jiosaavn.com/album/ullam-urugudayyaa/pyv6olifcFc_ +# https://www.jiosaavn.com/featured/t-m-soundararajan-hits-/1Fb7PO-OUs4_ +# https://www.jiosaavn.com/album/agathiyar-aathi-parasakthi/ligcQao8OHA_ class Download(): def __init__(self): @@ -58,7 +67,7 @@ def run(self): for dl_url in dl_urls: dl_type = scan_url(url=dl_url) - if dl_type == 'playlist': + if dl_type == 'playlist': playlist = Playlist(proxies, headers, dl_url) playlist.start_download() elif dl_type == 'album': diff --git a/requirements.txt b/requirements.txt index ebabf7c..896f3ab 100644 --- a/requirements.txt +++ b/requirements.txt @@ -6,7 +6,7 @@ chardet==3.0.4 deprecation==2.1.0 eyeD3==0.9.5 filetype==1.0.7 -get==2019.4.13 +#get==2019.4.13 idna==2.9 idna-ssl==1.1.0 importlib-metadata==1.6.0 @@ -16,14 +16,14 @@ mutagen==1.44.0 packaging==20.3 pathlib==1.0.1 pluggy==0.13.1 -post==2019.4.13 -public==2019.4.13 +#post==2019.4.13 +#public==2019.4.13 py==1.8.1 pyparsing==2.4.7 pySmartDL==1.3.3 pytest==5.4.2 -query-string==2019.4.13 -request==2019.4.13 +#query-string==2019.4.13 +#request==2019.4.13 requests==2.23.0 six==1.14.0 soupsieve==2.0 @@ -32,3 +32,4 @@ urllib3==1.25.9 wcwidth==0.1.9 yarl==1.4.2 zipp==3.1.0 +beautifulsoup4 diff --git a/scripts/content/album.py b/scripts/content/album.py index 6d684f0..19a4bf7 100644 --- a/scripts/content/album.py +++ b/scripts/content/album.py @@ -56,9 +56,9 @@ def downloadAlbum(self, artist_name=''): manager = Manager() self.getAlbum() if artist_name: - manager.downloadSongs(self.songs_json, self.album_name, artist_name=artist_name) + manager.downloadSongs(None, self.songs_json, self.album_name, artist_name=artist_name) else: - manager.downloadSongs(self.songs_json, self.album_name) + manager.downloadSongs(None, self.songs_json, self.album_name) def start_download(self): self.getAlbumID() diff --git a/scripts/content/artist.py b/scripts/content/artist.py index 7a33ae2..334f152 100644 --- a/scripts/content/artist.py +++ b/scripts/content/artist.py @@ -103,7 +103,7 @@ def downloadArtistAllSongs(self): self.artist_json = json.loads(self.artist_json) songs_json = self.artist_json['topSongs'] # A dict with key songs having at most 10 songs manager = Manager() - manager.downloadSongs(songs_json, artist_name=artist_name) + manager.downloadSongs(None, songs_json, artist_name=artist_name) except Exception as e: print(str(e)) print('No songs found for the artist') diff --git a/scripts/content/playlist.py b/scripts/content/playlist.py index 58e6d9d..71437ac 100644 --- a/scripts/content/playlist.py +++ b/scripts/content/playlist.py @@ -11,10 +11,12 @@ def __init__(self, proxies, headers, url=None): self.proxies = proxies self.headers = headers self.playlistID = None + self.playlistTitle = None + self.playlistObj = [] self.songs_json = [] self.url = url - def getPlaylistID(self, url=None): + def getPlaylistObj(self, url=None): if url: input_url = url else: @@ -26,13 +28,15 @@ def getPlaylistID(self, url=None): except Exception as e: print('Error accessing website error: {0}'.format(e)) exit() + self.playlistObj = res.json() self.playlistID = res.json()["id"] - return self.playlistID + self.playlistTitle = res.json()["title"] + return self.playlistObj def setPlaylistID(self, playlistID=None): self.playlistID = playlistID - def getPlaylist(self, playlistID=None): + def getPlaylistDetails(self, playlistID=None): if playlistID is None: playlistID = self.playlistID response = requests.get( @@ -44,10 +48,12 @@ def getPlaylist(self, playlistID=None): def downloadPlaylist(self): if self.playlistID is not None: - print("Initiating Playlist Downloading") + print("Initiating Playlist Downloading of:" + self.playlistTitle) manager = Manager() - manager.downloadSongs(self.getPlaylist()) + manager.downloadSongs(self.playlistTitle, self.getPlaylistDetails()) def start_download(self): - self.getPlaylistID() + self.getPlaylistObj() + # self.getPlaylistObj() + # print(self.playlistObj) self.downloadPlaylist() \ No newline at end of file diff --git a/scripts/content/podcast.py b/scripts/content/podcast.py index bceb20e..6957d4c 100644 --- a/scripts/content/podcast.py +++ b/scripts/content/podcast.py @@ -46,7 +46,7 @@ def downloadPodcast(self, show_json): except Exception as e: print('Download Error: {0}'.format(e)) try: - location = manager.get_download_location(show_name, season_name, filename) + location = manager.get_download_location(None, show_name, season_name, filename) has_downloaded = manager.start_download("Show: {} - Season: {} - Episode: {}".format( show_name, season_name, filename), location, dec_url) diff --git a/scripts/content/song.py b/scripts/content/song.py index aeef5a9..a47a1db 100644 --- a/scripts/content/song.py +++ b/scripts/content/song.py @@ -77,7 +77,7 @@ def downloadSong(self, album_name='songs', artist_name='Non-Artist'): except Exception as e: print('Download Error : {0}'.format(e)) try: - location = manager.get_download_location(artist_name, album_name, filename) + location = manager.get_download_location(None, artist_name, album_name, filename) has_downloaded = manager.start_download(filename, location, dec_url) if has_downloaded: name = song.get('subtitle', '') diff --git a/scripts/download_manager.py b/scripts/download_manager.py index d221abe..e363445 100644 --- a/scripts/download_manager.py +++ b/scripts/download_manager.py @@ -26,7 +26,7 @@ def get_dec_url(self, enc_url): return dec_url def format_filename(self, filename): - filename = html.unescape(filename) + '.m4a' + filename = html.unescape(filename) filename = filename.replace("\"", "'") filename = filename.replace(":", "-") filename = filename.replace('"', "-") @@ -44,7 +44,8 @@ def get_download_location(self, *args): else: location = self.args.outFolder for folder in args: - location = os.path.join(location, folder) + if folder != None: + location = os.path.join(location, folder) return location def start_download(self, filename, location, dec_url): @@ -57,15 +58,19 @@ def start_download(self, filename, location, dec_url): obj.start() return True - def downloadSongs(self, songs_json, album_name='songs', artist_name='Non-Artist'): + def downloadSongs(self, playlistTitle, songs_json, album_name='songs', artist_name=None): for song in songs_json['songs']: try: dec_url = self.get_dec_url(song['encrypted_media_url']) - filename = self.format_filename(song['song']) + filename = self.format_filename(song['song']) + '.m4a' + album_name = self.format_filename(song["album"]) + # album_name = self.format_filename(song["year"]) + "-" + self.format_filename(song["album"]) except Exception as e: print('Download Error: {0}'.format(e)) try: - location = self.get_download_location(artist_name, album_name, filename) + location = self.get_download_location(playlistTitle, artist_name, album_name, filename) + # print("downloadSongs:" + location) + # print(song) has_downloaded = self.start_download(filename, location, dec_url) if has_downloaded: try: diff --git a/scripts/saavnaccount.py b/scripts/saavnaccount.py index 93242f3..86911d4 100644 --- a/scripts/saavnaccount.py +++ b/scripts/saavnaccount.py @@ -273,7 +273,7 @@ def start_download_playlist(self): playlistID = pl['id'] manager = Manager() songs_json = playlist.getPlaylist(playlistID) - manager.downloadSongs(songs_json) + manager.downloadSongs(playlist.playlistTitle, songs_json) def start_download_album(self): library_json, session = self.getLibrarySession()