Skip to content
This repository has been archived by the owner on Aug 1, 2021. It is now read-only.

Commit

Permalink
fixed #529
Browse files Browse the repository at this point in the history
  • Loading branch information
r0oth3x49 committed Jul 24, 2020
1 parent 59b3efc commit ee6391b
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions udemy/_extract.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,10 +228,13 @@ def _extract_course_info(self, url):
sys.stdout.write(fc + sd + "[" + fm + sb + "+" + fc + sd + "] : " + fg + sb + "Logged out successfully.\n")
sys.exit(0)

def _extract_large_course_content(self, url):
url = url.replace('10000', '300') if url.endswith('10000') else url
def _extract_large_course_content(self, url, current_size=10000, page_size=300):
data = {}
url = url.replace(str(current_size), str(page_size)) if url.endswith(str(current_size)) else url
try:
data = self._session._get(url).json()
except (Exception, ValueError) as error:
data = self._extract_large_course_content(url, current_size=300, page_size=50)
except conn_error as e:
sys.stdout.write(fc + sd + "[" + fr + sb + "-" + fc + sd + "] : " + fr + sb + "Connection error : make sure your internet connection is working.\n")
time.sleep(0.8)
Expand All @@ -251,7 +254,7 @@ def _extract_large_course_content(self, url):
if results and isinstance(results, list):
for d in resp['results']:
data['results'].append(d)
return data
return data

def _extract_course_json(self, url, course_id, portal_name):
self._session._headers.update({'Referer' : url})
Expand Down

0 comments on commit ee6391b

Please sign in to comment.