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

Set Timeout to 3 Minutes #42

Open
wants to merge 1 commit 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
7 changes: 5 additions & 2 deletions scripts/download_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
from .pyDes import *
from .helper import argManager

REQUEST_TIMEOUT = 180

class Manager():
def __init__(self):
self.unicode = str
Expand Down Expand Up @@ -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

Expand Down
16 changes: 8 additions & 8 deletions scripts/saavnaccount.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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)
Expand All @@ -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)
Expand Down Expand Up @@ -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)
Expand All @@ -175,21 +175,21 @@ 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:
playlists = []
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)
Expand All @@ -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)
Expand Down