Skip to content

Commit

Permalink
Bug fixes
Browse files Browse the repository at this point in the history
- Remove user agent to fix 403 errors when fetching courses
- Fix ``saved`` folder not being created if it doesnt exist
  • Loading branch information
Puyodead1 committed Oct 16, 2021
1 parent 2c2e0a5 commit f6918e4
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import cloudscraper
import m3u8
import requests
from pathlib import Path
import yt_dlp
from html.parser import HTMLParser as compat_HTMLParser
from dotenv import load_dotenv
Expand All @@ -21,13 +22,14 @@

home_dir = os.getcwd()
download_dir = os.path.join(os.getcwd(), "out_dir")
saved_dir = os.path.join(os.getcwd(), "saved")
keyfile_path = os.path.join(os.getcwd(), "keyfile.json")
retry = 3
downloader = None
HEADERS = {
"Origin": "www.udemy.com",
"User-Agent":
"Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:90.0) Gecko/20100101 Firefox/90.0",
# "User-Agent":
# "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:90.0) Gecko/20100101 Firefox/90.0",
"Accept": "*/*",
"Accept-Encoding": None,
}
Expand All @@ -39,6 +41,9 @@
MY_COURSES_URL = "https://{portal_name}.udemy.com/api-2.0/users/me/subscribed-courses?fields[course]=id,url,title,published_title&ordering=-last_accessed,-access_time&page=1&page_size=10000"
COLLECTION_URL = "https://{portal_name}.udemy.com/api-2.0/users/me/subscribed-courses-collections/?collection_has_courses=True&course_limit=20&fields[course]=last_accessed_time,title,published_title&fields[user_has_subscribed_courses_collection]=@all&page=1&page_size=1000"

Path(download_dir).mkdir(parents=True, exist_ok=True)
Path(saved_dir).mkdir(parents=True, exist_ok=True)


def _clean(text):
ok = re.compile(r'[^\\/:*?!"<>|]')
Expand Down

0 comments on commit f6918e4

Please sign in to comment.