Browse Source

Update 'pluralsight.py'

master
parent
commit
a3e3b5a441
1 changed files with 32 additions and 28 deletions
  1. 32
    28
      pluralsight.py

+ 32
- 28
pluralsight.py View File

@@ -19,7 +19,7 @@ from selenium.webdriver.firefox.options import Options
# region Global Constant(s) and Readonly Variable(s)

# True/False to determine whether selenium instances will be visible or not (headless)
HIDE_SELENIUM_INSTANCES = False
HIDE_SELENIUM_INSTANCES = True

# The maximum number of courses to download from a single account
MAX_COURSE_DOWNLOAD_COUNT = 5
@@ -52,8 +52,7 @@ PROGRESS_FILE_PATH = os.path.join(MASTER_DIRECTORY, "progress.txt")
SAVE_DIRECTORY_PATH = os.path.join(MASTER_DIRECTORY, "Courses")

# JSON File (.json) containing the JSON of the paths/courses dump of Pluralsight
# JSON_FILE_URL = os.path.join(WORKING_DIRECTORY, "pluralsight.json")
JSON_FILE_URL = "https://git.teknik.io/CanWePlsRapeTheShitOuttaPluralsight/RapePluralsight/raw/branch/master/pluralsight.json"
JSON_FILE_URL = os.path.join(MASTER_DIRECTORY, "pluralsight.json")

# Options for youtube-dl. For a complete list of options, check https://github.com/ytdl-org/youtube-dl/blob/3e4cedf9e8cd3157df2457df7274d0c842421945/youtube_dl/YoutubeDL.py#L137-L312
ydl_options = {
@@ -434,37 +433,42 @@ def save_progress(path_id: int, course_index: int):
def download_all(all_pluralsight_paths: List[PluralsightPath]):
global SAVE_DIRECTORY_PATH

try:
if not os.path.isfile(PROGRESS_FILE_PATH):
save_progress(path_id=1, course_index=0)
while True:
try:
if not os.path.isfile(PROGRESS_FILE_PATH):
save_progress(path_id=1, course_index=0)

current_path_id, current_course_index = map(int, Path(PROGRESS_FILE_PATH).read_text().rstrip().split("|"))
current_path_id, current_course_index = map(int, Path(PROGRESS_FILE_PATH).read_text().rstrip().split("|"))

while current_path_id <= len(all_pluralsight_paths):
email, password = get_credential()
while current_path_id <= len(all_pluralsight_paths):
email, password = get_credential()

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)
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)

course_link = pluralsight_path.course_links[current_course_index]
download_result = download_course(course_link, email, password, save_directory_path)
course_link = pluralsight_path.course_links[current_course_index]
download_result = download_course(course_link, email, password, save_directory_path)

if not download_result:
raise Exception("Failed to download course")
if not download_result:
raise Exception("Failed to download course")

current_course_index += 1
save_progress(current_path_id, current_course_index)
current_course_index += 1
save_progress(current_path_id, current_course_index)

current_path_id += 1
current_course_index = 0
save_progress(current_path_id, current_course_index)
current_path_id += 1
current_course_index = 0
save_progress(current_path_id, current_course_index)

break
break

except Exception as exception:
print(exception)
except(KeyboardInterrupt, SystemExit):
print("EXITING PROGRAM")
break
except Exception as exception:
os.remove(CREDENTIAL_FILE_PATH)
print(exception)


def main():
@@ -490,9 +494,9 @@ def main():
for path in user_selection.selected_paths:
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)



Loading…
Cancel
Save