Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removed malicious and redundant dependencies, and added missed one #35

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion download_reloaded.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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':
Expand Down
11 changes: 6 additions & 5 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -32,3 +32,4 @@ urllib3==1.25.9
wcwidth==0.1.9
yarl==1.4.2
zipp==3.1.0
beautifulsoup4
4 changes: 2 additions & 2 deletions scripts/content/album.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion scripts/content/artist.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
18 changes: 12 additions & 6 deletions scripts/content/playlist.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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(
Expand All @@ -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()
2 changes: 1 addition & 1 deletion scripts/content/podcast.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion scripts/content/song.py
Original file line number Diff line number Diff line change
Expand Up @@ -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', '')
Expand Down
15 changes: 10 additions & 5 deletions scripts/download_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -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('"', "-")
Expand All @@ -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):
Expand All @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion scripts/saavnaccount.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down