diff --git a/pvdl.py b/pvdl.py index 642a892..72fe090 100755 --- a/pvdl.py +++ b/pvdl.py @@ -153,7 +153,7 @@ def get_chapters(vid_id, limit_rate): print_err("Error: Wrong link. No video found.") title = details["title"] - title = re.sub(r"[<>|/\\?*]", "_" ,title); + title = re.sub(r"[^\w\s\d.,\+\$\%\#\@\!\(\)\[\]\-\{\}]", "_" ,title); os.makedirs(title, 0o755, exist_ok=True) url = 'https://static.packt-cdn.com/products/{}/toc'.format(vid_id) @@ -166,18 +166,19 @@ def get_chapters(vid_id, limit_rate): all_chapters = details['chapters'] for x,i in enumerate(all_chapters): section = i['title'] - section = re.sub(r"[<>|/\\?*]", "_" , section) + section = re.sub(r"[^\w\s\d.,\+\$\%\#\@\!\(\)\[\]\-\{\}]", "_" , section) s_path = "{}{}{:02}-{}".format(title, os.sep, x+1, section) os.makedirs(s_path, 0o755, exist_ok=True) - print(bcolors.OKGREEN + "\nChapter {}/{}:".format(x+1, len(all_chapters)), section, "\n" + bcolors.ENDC) + print(bcolors.OKGREEN + "\nChapter {}/{} ({} videos):".format(x+1, len(all_chapters), len(i['sections'])), section, "\n" + bcolors.ENDC) for y,c in enumerate(i['sections']): chapter = c['title'] - chapter = re.sub(r"[<>|/\\?*]", "_" , chapter) + chapter = re.sub(r"[^\w\s\d.,\+\$\%\#\@\!\(\)\[\]\-\{\}]", "_" , chapter) c_path = "{}{}{:02}-{}.mp4".format(s_path, os.sep , y+1, chapter) video_id = i['id'] + '/' + c['id'] video_url = get_video_url(vid_id, video_id) download_url(video_url, c_path, limit_rate) + def start_download(username, password, vid_id, limit_rate): login(username, password)