diff --git a/scripts/download_manager.py b/scripts/download_manager.py index d221abe..f2e4227 100644 --- a/scripts/download_manager.py +++ b/scripts/download_manager.py @@ -10,6 +10,8 @@ from .pyDes import * from .helper import argManager +REQUEST_TIMEOUT = 180 + class Manager(): def __init__(self): self.unicode = str @@ -52,8 +54,9 @@ def start_download(self, filename, location, dec_url): print("Downloaded {0}".format(filename)) return False else : - print("Downloading {0}".format(filename)) - obj = SmartDL(dec_url, location) + print("Downloading {0} : URL : {1}".format(filename, dec_url)) + + obj = SmartDL(dec_url, location, threads=1, timeout=REQUEST_TIMEOUT) obj.start() return True diff --git a/scripts/saavnaccount.py b/scripts/saavnaccount.py index 93242f3..1c05604 100644 --- a/scripts/saavnaccount.py +++ b/scripts/saavnaccount.py @@ -52,7 +52,7 @@ def getAccountSession(self, email=None, password=None, action=None): } self.session = requests.Session() - response = self.session.post(self.url, headers=self.headers, data=payload) + response = self.session.post(self.url, headers=self.headers, data=payload, timeout=180) return self.session, response def createAccount(self, email=None, password=None): @@ -78,7 +78,7 @@ def activateLibrary(self, email=None, password=None): return False elif data.get('data').get('uid'): try: - response = session.get("https://www.saavn.com/api.php?_marker=0&cc=&ctx=android&state=login&v=224&app_version=6.8.2&api_version=4&_format=json&__call=library.getAll") + response = session.get("https://www.saavn.com/api.php?_marker=0&cc=&ctx=android&state=login&v=224&app_version=6.8.2&api_version=4&_format=json&__call=library.getAll", timeout=180) library_json = [x for x in response.text.splitlines() if x.strip().startswith('{')][0] library_json = json.loads(library_json) # print(library_json) @@ -101,7 +101,7 @@ def getLibrarySession(self, email=None, password=None): return False elif data.get('data').get('uid'): try: - response = session.get("https://www.saavn.com/api.php?_marker=0&cc=&ctx=android&state=login&v=224&app_version=6.8.2&api_version=4&_format=json&__call=library.getAll", headers=self.headers) + response = session.get("https://www.saavn.com/api.php?_marker=0&cc=&ctx=android&state=login&v=224&app_version=6.8.2&api_version=4&_format=json&__call=library.getAll", headers=self.headers, timeout=180) self.library_json = [x for x in response.text.splitlines() if x.strip().startswith('{')][0] self.library_json = json.loads(self.library_json) # print(self.library_json) @@ -159,7 +159,7 @@ def cloneAccount(self, nEmail, nPassword, createNewAcc): for playlist in np: songs_json = [] response = requests.get( - 'https://www.jiosaavn.com/api.php?listid={0}&_format=json&__call=playlist.getDetails'.format(playlist['id'])) + 'https://www.jiosaavn.com/api.php?listid={0}&_format=json&__call=playlist.getDetails'.format(playlist['id']), timeout=180) if response.status_code == 200: songs_json = [x for x in response.text.splitlines() if x.strip().startswith('{')][0] songs_json = json.loads(songs_json) @@ -175,13 +175,13 @@ def cloneAccount(self, nEmail, nPassword, createNewAcc): if songs is None: songs = [] for song in songs: - session.get('https://www.saavn.com/api.php?_marker=0&entity_type=song&entity_ids={0}&_format=json&__call=library.add'.format(song)) + session.get('https://www.saavn.com/api.php?_marker=0&entity_type=song&entity_ids={0}&_format=json&__call=library.add'.format(song), timeout=180) print('Adding adding albums to new account') albums = olibrary_json.get('album') if albums is None: albums = [] for album in albums: - session.get('https://www.saavn.com/api.php?_marker=0&entity_type=album&entity_ids={0}&_format=json&__call=library.add'.format(album)) + session.get('https://www.saavn.com/api.php?_marker=0&entity_type=album&entity_ids={0}&_format=json&__call=library.add'.format(album), timeout=180) print('Adding playlists to new account') playlists = olibrary_json.get('playlist') if playlists is None: @@ -189,7 +189,7 @@ def cloneAccount(self, nEmail, nPassword, createNewAcc): for playlist in playlists: songs_json = [] response = requests.get( - 'https://www.jiosaavn.com/api.php?listid={0}&_format=json&__call=playlist.getDetails'.format(playlist['id'])) + 'https://www.jiosaavn.com/api.php?listid={0}&_format=json&__call=playlist.getDetails'.format(playlist['id']), timeout=180) if response.status_code == 200: songs_json = [x for x in response.text.splitlines() if x.strip().startswith('{')][0] songs_json = json.loads(songs_json) @@ -215,7 +215,7 @@ def cloneAccount(self, nEmail, nPassword, createNewAcc): 'network_subtype': '', 'model': 'Samsung Galaxy S10' } - res = n_session.post('https://www.jiosaavn.com/api.php', headers=self.headers, data=p_copy) + res = n_session.post('https://www.jiosaavn.com/api.php', headers=self.headers, data=p_copy, timeout=180) print(playlist['id']) print(res) print(res.text)