mirror of
https://cdm-project.com/Download-Tools/udemy-downloader.git
synced 2025-05-04 14:14:27 +02:00
Updates and bug fixes
+ Fixed mis-named variable + Removed unused ``working_dir`` code + Fixed issue with course info feature not working + Added versioning system to help with debugging + Updated requirements file
This commit is contained in:
parent
5b592923dc
commit
5ec615e4e3
1
_version.py
Normal file
1
_version.py
Normal file
@ -0,0 +1 @@
|
|||||||
|
__version__ = "1.1.0"
|
30
main.py
30
main.py
@ -6,23 +6,22 @@ import re
|
|||||||
import subprocess
|
import subprocess
|
||||||
import sys
|
import sys
|
||||||
import time
|
import time
|
||||||
from html.parser import HTMLParser as compat_HTMLParser
|
|
||||||
|
|
||||||
import cloudscraper
|
import cloudscraper
|
||||||
import m3u8
|
import m3u8
|
||||||
import requests
|
import requests
|
||||||
import yt_dlp
|
import yt_dlp
|
||||||
|
import git
|
||||||
|
from html.parser import HTMLParser as compat_HTMLParser
|
||||||
from dotenv import load_dotenv
|
from dotenv import load_dotenv
|
||||||
from requests.exceptions import ConnectionError as conn_error
|
from requests.exceptions import ConnectionError as conn_error
|
||||||
from tqdm import tqdm
|
from tqdm import tqdm
|
||||||
|
|
||||||
from sanitize import sanitize, slugify, SLUG_OK
|
from sanitize import sanitize, slugify, SLUG_OK
|
||||||
from utils import extract_kid
|
from utils import extract_kid
|
||||||
from vtt_to_srt import convert
|
from vtt_to_srt import convert
|
||||||
|
from _version import __version__
|
||||||
|
|
||||||
home_dir = os.getcwd()
|
home_dir = os.getcwd()
|
||||||
download_dir = os.path.join(os.getcwd(), "out_dir")
|
download_dir = os.path.join(os.getcwd(), "out_dir")
|
||||||
working_dir = os.path.join(os.getcwd(), "working_dir")
|
|
||||||
keyfile_path = os.path.join(os.getcwd(), "keyfile.json")
|
keyfile_path = os.path.join(os.getcwd(), "keyfile.json")
|
||||||
retry = 3
|
retry = 3
|
||||||
downloader = None
|
downloader = None
|
||||||
@ -777,9 +776,6 @@ class UdemyAuth(object):
|
|||||||
return None, None
|
return None, None
|
||||||
|
|
||||||
|
|
||||||
if not os.path.exists(working_dir):
|
|
||||||
os.makedirs(working_dir)
|
|
||||||
|
|
||||||
if not os.path.exists(download_dir):
|
if not os.path.exists(download_dir):
|
||||||
os.makedirs(download_dir)
|
os.makedirs(download_dir)
|
||||||
|
|
||||||
@ -1081,7 +1077,7 @@ def process_lecture(lecture, lecture_path, lecture_file_name, quality, access_to
|
|||||||
f"{concurrent_connections}", "--downloader",
|
f"{concurrent_connections}", "--downloader",
|
||||||
"aria2c", "-o", f"{temp_filepath}", f"{url}"
|
"aria2c", "-o", f"{temp_filepath}", f"{url}"
|
||||||
]).wait()
|
]).wait()
|
||||||
if retVal:
|
if ret_code == 0:
|
||||||
os.rename(temp_filepath, lecture_path)
|
os.rename(temp_filepath, lecture_path)
|
||||||
print(" > HLS Download success")
|
print(" > HLS Download success")
|
||||||
else:
|
else:
|
||||||
@ -1218,7 +1214,7 @@ def parse_new(_udemy, quality, skip_lectures, dl_assets, dl_captions,
|
|||||||
keep_vtt)
|
keep_vtt)
|
||||||
|
|
||||||
|
|
||||||
def course_info(course_data):
|
def _print_course_info(course_data):
|
||||||
print("\n\n\n\n")
|
print("\n\n\n\n")
|
||||||
course_title = course_data.get("title")
|
course_title = course_data.get("title")
|
||||||
chapter_count = course_data.get("total_chapters")
|
chapter_count = course_data.get("total_chapters")
|
||||||
@ -1287,6 +1283,16 @@ def course_info(course_data):
|
|||||||
print("\n\n")
|
print("\n\n")
|
||||||
|
|
||||||
|
|
||||||
|
def get_version_string():
|
||||||
|
repo = git.Repo(search_parent_directories=True)
|
||||||
|
if repo:
|
||||||
|
sha = repo.head.object.hexsha
|
||||||
|
branch = repo.active_branch.name
|
||||||
|
return sha + "-git-" + branch + " (" + __version__ + ")"
|
||||||
|
else:
|
||||||
|
return __version__
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
parser = argparse.ArgumentParser(description='Udemy Downloader')
|
parser = argparse.ArgumentParser(description='Udemy Downloader')
|
||||||
parser.add_argument("-c",
|
parser.add_argument("-c",
|
||||||
@ -1372,6 +1378,8 @@ if __name__ == "__main__":
|
|||||||
action="store_true",
|
action="store_true",
|
||||||
help=argparse.SUPPRESS,
|
help=argparse.SUPPRESS,
|
||||||
)
|
)
|
||||||
|
parser.add_argument("-v", "--version", action="version",
|
||||||
|
version='You are running version {version}'.format(version=get_version_string()))
|
||||||
|
|
||||||
dl_assets = False
|
dl_assets = False
|
||||||
skip_lectures = False
|
skip_lectures = False
|
||||||
@ -1482,7 +1490,7 @@ if __name__ == "__main__":
|
|||||||
_udemy = json.loads(
|
_udemy = json.loads(
|
||||||
open(os.path.join(os.getcwd(), "saved", "_udemy.json")).read())
|
open(os.path.join(os.getcwd(), "saved", "_udemy.json")).read())
|
||||||
if args.info:
|
if args.info:
|
||||||
course_info(_udemy)
|
_print_course_info(_udemy)
|
||||||
else:
|
else:
|
||||||
parse_new(_udemy, quality, skip_lectures, dl_assets, dl_captions,
|
parse_new(_udemy, quality, skip_lectures, dl_assets, dl_captions,
|
||||||
caption_locale, keep_vtt, access_token,
|
caption_locale, keep_vtt, access_token,
|
||||||
@ -1717,7 +1725,7 @@ if __name__ == "__main__":
|
|||||||
print("Saved parsed data to json")
|
print("Saved parsed data to json")
|
||||||
|
|
||||||
if args.info:
|
if args.info:
|
||||||
course_info(_udemy)
|
_print_course_info(_udemy)
|
||||||
else:
|
else:
|
||||||
parse_new(_udemy, quality, skip_lectures, dl_assets, dl_captions,
|
parse_new(_udemy, quality, skip_lectures, dl_assets, dl_captions,
|
||||||
caption_locale, keep_vtt, access_token,
|
caption_locale, keep_vtt, access_token,
|
||||||
|
@ -12,3 +12,4 @@ yt-dlp
|
|||||||
bitstring
|
bitstring
|
||||||
cloudscraper
|
cloudscraper
|
||||||
unidecode
|
unidecode
|
||||||
|
gitpython
|
Loading…
x
Reference in New Issue
Block a user