def download(url, cookie_path, course_folder): ''' This function downloads all the videos in course folder''' os.chdir(course_folder) COOKIE = install.read_settings_json('credentials', 'use_cookie_for_download') SUBTITLE = install.read_settings_json('preferences', 'download_subtitles') EXTERNAL_DOWNLOADER = install.read_settings_json( 'preferences', 'ext-downloader-aria2-installed') USERNAME = install.read_settings_json('credentials', 'username') PASSWORD = install.read_settings_json('credentials', 'password') try: subtitles = ' --all-subs ' if SUBTITLE else ' ' # Checking subtitle preferences # Output name of videos/subtitles output = ' -o ' + '"' + course_folder + "/%(playlist_index)s - %(title)s.%(ext)s" + '"' # Extername downloader option ext_downloader = ' --external-downloader aria2c' if EXTERNAL_DOWNLOADER else '' cookie = ' --cookies ' + '"' + cookie_path + '"' #cookie username = '******' + USERNAME #username password = '******' + PASSWORD #password # Checking cookie preferences if COOKIE: cookies.edit_cookie(cookie_path, message.NETSCAPE) # Edit cookie file os.system('youtube-dl' + cookie + output + subtitles + url + ext_downloader) else: os.system('youtube-dl' + username + password + output + subtitles + url + ext_downloader) except KeyboardInterrupt: sys.exit('Program Interrupted')
def schedule_download(url): ''' Look for the scheduled time in settings.json ''' scheduled_time = install.read_settings_json('preferences', 'download_time') if scheduled_time == '': tip = '☝🏻 Tip: You can schedule download time in settings.json' message.carriage_return_animate(tip) download_course(url) return else: counter = True message.colored_message( Fore.LIGHTGREEN_EX, 'Download time set to: ' + scheduled_time + '\ in settings.json, you can change or remove this time in settings.json\n') try: while counter: if time.strftime("%H:%M") == scheduled_time: download_course(url) return print('Download will start at: ' + scheduled_time + ', leave this window open.') time.sleep(60) except KeyboardInterrupt: sys.exit( message.colored_message(Fore.LIGHTRED_EX, "\n- Program Interrupted!!\n"))
def read_bulk_download(): ''' Read Bulk Download.txt ''' os.chdir(install.read_settings_json('preferences', 'location')) bulk_download = open('Bulk Download.txt', 'r') urls = bulk_download.readlines() return urls
''' Download exercise file ''' from selenium import webdriver from selenium.webdriver.common.keys import Keys import install, message import os import sys import time import shutil username = install.read_settings_json('credentials', 'username') password = install.read_settings_json('credentials', 'password') web_browser = install.read_settings_json('preferences', 'web_browser_for_exfile') def download(url, course_folder): ''' Download exercise file ''' if web_browser.lower() == 'firefox': driver = webdriver.Firefox() else: driver = webdriver.Chrome() driver.get("https://www.lynda.com/signin/") # launch lynda.com/signin # enter username email = driver.find_element_by_css_selector("#email-address") email.clear() email.send_keys(username) driver.find_element_by_css_selector('#username-submit').click() print('\nusername successfully entered ....') time.sleep(2)
def download_course(url): ''' download course ''' # Check for a valid url if url.find('.html') == -1: sys.exit( message.animate_characters(Fore.LIGHTRED_EX, draw.ANONYMOUS, 0.02)) url = url[:url.find(".html") + 5] #strip any extra text after .html in the url # Folder/File paths lynda_folder_path = install.read_settings_json('preferences', 'location') + '/' course_folder_path = save.course_path(url, lynda_folder_path) desktop_folder_path = install.folder_path("Desktop") download_folder_path = install.folder_path("Downloads") # Read preferences download_exercise_file = install.read_settings_json( 'preferences', 'download_exercise_file') use_cookie_for_download = install.read_settings_json( 'credentials', 'use_cookie_for_download') if use_cookie_for_download: cookie_path = cookies.find_cookie(desktop_folder_path, download_folder_path) else: cookie_path = '' usr_pass_message = message.return_colored_message( Fore.LIGHTGREEN_EX, 'Using username and password combination for download\n') message.carriage_return_animate(usr_pass_message) try: save.course(url, lynda_folder_path) # Create course folder save.info_file(url, course_folder_path) # Gather information save.chapters( url, course_folder_path) # Create chapters inside course folder videos.download( url, cookie_path, course_folder_path) # Downloading lynda videos to course folder rename.videos(course_folder_path) rename.subtitles(course_folder_path) move.vid_srt_to_chapter( url, course_folder_path) # Move videos and subtitles to chapter folders # Download exercise file if download_exercise_file: # check if user wants to download exercise file if not use_cookie_for_download: # make sure user is downloading via user + password if save.check_exercise_file(url): exercise_file.download( url, course_folder_path) # Download exercise-file else: print('\n-> Exercise file not available.') else: print( '\nExercise file downloads for organizational login is not supported, please download manually.' ) except KeyboardInterrupt: sys.exit( message.colored_message(Fore.LIGHTRED_EX, "\n- Program Interrupted!!\n"))
def download_course(url): ''' download course ''' # Check for a valid url if url.find('.html') == -1: sys.exit( message.animate_characters(Fore.LIGHTRED_EX, draw.ANONYMOUS, 0.02)) url = url[:url.find(".html") + 5] #strip any extra text after .html in the url # Folder/File paths lynda_folder_path = install.read_settings_json('preferences', 'location') + '/' course_folder_path = save.course_path(url, lynda_folder_path) desktop_folder_path = install.folder_path("Desktop") download_folder_path = install.folder_path("Downloads") if install.read_settings_json('credentials', 'use_cookie_for_download'): cookie_path = cookies.find_cookie(desktop_folder_path, download_folder_path) else: cookie_path = '' usr_pass_message = message.return_colored_message( Fore.LIGHTGREEN_EX, 'Using username and password combination for download\n') message.carriage_return_animate(usr_pass_message) try: save.course(url, lynda_folder_path) # Create course folder save.info_file(url, course_folder_path) # Gather information save.chapters( url, course_folder_path) # Create chapters inside course folder videos.download( url, cookie_path, course_folder_path) # Downloading lynda videos to course folder # Download exercise file # check for organizational login, should be false to download. if not install.read_settings_json('credentials', 'use_cookie_for_download'): if save.check_exercise_file(url): exercise_file.download( url, course_folder_path) # Download exercise-file else: print('\n-> Exercise file not available.') else: print( '\nExercise file downloads for organizational login is not supported, please download manually.' ) except KeyboardInterrupt: sys.exit( message.colored_message(Fore.LIGHTRED_EX, "\n- Program Interrupted!!\n")) # Rename files try: path = rename_files.assign_folder(course_folder_path) except KeyboardInterrupt: sys.exit( message.colored_message(Fore.LIGHTRED_EX, "\n- Program Interrupted!!\n")) except: sys.exit('error in assigning path') try: rename_files.execute(path) except KeyboardInterrupt: sys.exit( message.colored_message(Fore.LIGHTRED_EX, "\n- Program Interrupted!!\n")) except: sys.exit(message.RENAMING_ERROR)