|
|
|
@ -28,10 +28,10 @@ MAX_COURSE_DOWNLOAD_COUNT = 5
@@ -28,10 +28,10 @@ MAX_COURSE_DOWNLOAD_COUNT = 5
|
|
|
|
|
SELENIUM_SLEEP_DURATION = 5 |
|
|
|
|
|
|
|
|
|
# Minimum number of seconds to wait between consecutive video downloads |
|
|
|
|
MIN_VIDEO_DOWNLOAD_DELAY = 10 |
|
|
|
|
MIN_VIDEO_DOWNLOAD_DELAY = 1 |
|
|
|
|
|
|
|
|
|
# Minimum number of seconds to wait between consecutive video downloads |
|
|
|
|
MAX_VIDEO_DOWNLOAD_DELAY = 20 |
|
|
|
|
MAX_VIDEO_DOWNLOAD_DELAY = 10 |
|
|
|
|
|
|
|
|
|
# Check if current OS/platform is Windows |
|
|
|
|
IS_WINDOWS = platform.startswith("win") |
|
|
|
@ -287,7 +287,7 @@ def create_pluralsight_account(credential_file_path: str) -> Dict[str, str]:
@@ -287,7 +287,7 @@ def create_pluralsight_account(credential_file_path: str) -> Dict[str, str]:
|
|
|
|
|
return {'email': disposable_email, 'password': password} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def download_course(course_link: str, username: str, password: str) -> bool: |
|
|
|
|
def download_course(course_link: str, username: str, password: str, save_directory_path: str) -> bool: |
|
|
|
|
""" |
|
|
|
|
Download the given course using the provided credential |
|
|
|
|
|
|
|
|
@ -295,6 +295,7 @@ def download_course(course_link: str, username: str, password: str) -> bool:
@@ -295,6 +295,7 @@ def download_course(course_link: str, username: str, password: str) -> bool:
|
|
|
|
|
course_link: The link of the course to download |
|
|
|
|
username: Username (Email) of the Pluralsight account to be used for download |
|
|
|
|
password: Password of the Pluralsight account to be used for download |
|
|
|
|
save_directory_path: Absolute path of Root save directory |
|
|
|
|
|
|
|
|
|
Returns: True/False bool value denoting the success status of the download |
|
|
|
|
""" |
|
|
|
@ -305,10 +306,10 @@ def download_course(course_link: str, username: str, password: str) -> bool:
@@ -305,10 +306,10 @@ def download_course(course_link: str, username: str, password: str) -> bool:
|
|
|
|
|
|
|
|
|
|
if IS_WINDOWS: |
|
|
|
|
ydl_options[ |
|
|
|
|
'outtmpl'] = f"{SAVE_DIRECTORY_PATH}\\%(playlist)s\\%(chapter_number)s - %(chapter)s\\%(playlist_index)s - %(title)s.%(ext)s" |
|
|
|
|
'outtmpl'] = f"{save_directory_path}\\%(playlist)s\\%(chapter_number)s - %(chapter)s\\%(playlist_index)s - %(title)s.%(ext)s" |
|
|
|
|
else: |
|
|
|
|
ydl_options[ |
|
|
|
|
'outtmpl'] = f"{SAVE_DIRECTORY_PATH}/%(playlist)s/%(chapter_number)s - %(chapter)s/%(playlist_index)s - %(title)s.%(ext)s" |
|
|
|
|
'outtmpl'] = f"{save_directory_path}/%(playlist)s/%(chapter_number)s - %(chapter)s/%(playlist_index)s - %(title)s.%(ext)s" |
|
|
|
|
|
|
|
|
|
with youtube_dl.YoutubeDL(ydl_options) as ydl: |
|
|
|
|
ydl.download([course_link]) |
|
|
|
@ -445,10 +446,10 @@ def download_all(all_pluralsight_paths: List[PluralsightPath]):
@@ -445,10 +446,10 @@ def download_all(all_pluralsight_paths: List[PluralsightPath]):
|
|
|
|
|
for pluralsight_path in all_pluralsight_paths: |
|
|
|
|
if int(current_path_id) == pluralsight_path.id: |
|
|
|
|
while current_course_index < len(pluralsight_path.course_links): |
|
|
|
|
SAVE_DIRECTORY_PATH = get_directory_full_path(SAVE_DIRECTORY_PATH, pluralsight_path) |
|
|
|
|
save_directory_path = get_directory_full_path(SAVE_DIRECTORY_PATH, pluralsight_path) |
|
|
|
|
|
|
|
|
|
course_link = pluralsight_path.course_links[current_course_index] |
|
|
|
|
download_result = download_course(course_link, email, password) |
|
|
|
|
download_result = download_course(course_link, email, password, save_directory_path) |
|
|
|
|
|
|
|
|
|
if not download_result: |
|
|
|
|
raise Exception("Failed to download course") |
|
|
|
@ -486,9 +487,12 @@ def main():
@@ -486,9 +487,12 @@ def main():
|
|
|
|
|
download_course(course_link=user_selection.selected_course_link, username=email_address, password=password) |
|
|
|
|
else: |
|
|
|
|
for path in user_selection.selected_paths: |
|
|
|
|
SAVE_DIRECTORY_PATH = get_directory_full_path(SAVE_DIRECTORY_PATH, path) |
|
|
|
|
save_directory_path = get_directory_full_path(SAVE_DIRECTORY_PATH, path) |
|
|
|
|
for course_link in path.course_links: |
|
|
|
|
download_course(course_link=course_link, username=email_address, password=password) |
|
|
|
|
download_course(course_link=course_link, |
|
|
|
|
username=email_address, |
|
|
|
|
password=password, |
|
|
|
|
save_directory_path=save_directory_path) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__': |
|
|
|
|