diff --git a/llvd/__init__.py b/llvd/__init__.py index d21cb99..ddd3e86 100755 --- a/llvd/__init__.py +++ b/llvd/__init__.py @@ -1,3 +1,3 @@ # -*- encoding: utf-8 -*- """Linkedin Learning Video Downloader.""" -__version__ = "3.0.7" +__version__ = "3.0.8" diff --git a/llvd/app.py b/llvd/app.py index 9234d8e..6d3f302 100644 --- a/llvd/app.py +++ b/llvd/app.py @@ -16,6 +16,8 @@ import sys from llvd import config import subprocess + + class App: def __init__( self, email, password, course_slug, resolution, caption, exercise, throttle @@ -77,11 +79,11 @@ def run(self, cookies=None, headers={}): self.cookies["JSESSIONID"] = cookies.get("JSESSIONID") self.cookies["li_at"] = cookies.get("li_at") - self.headers=headers + self.headers = headers self.headers["Csrf-Token"] = cookies.get("JSESSIONID") - + # remove empty files - command = 'find . -depth -type f -size 0 -exec rm {} +' + command = "find . -depth -type f -size 0 -exec rm {} +" subprocess.run(command, shell=True) # proceed to download @@ -203,7 +205,11 @@ def download_courses_from_path(self): self.download_entire_course(skip_done_alert=suppress) except EmptyCourseList as e: - click.echo(click.style(f"EmptyCourseList: Error parsing learning path.\n{e}", fg="red")) + click.echo( + click.style( + f"EmptyCourseList: Error parsing learning path.\n{e}", fg="red" + ) + ) except Exception as e: click.echo( @@ -248,11 +254,13 @@ def fetch_chapter(self, chapter, chapters_pad_length, delay): current_files = [] for file in os.listdir(chapter_path): if file.endswith(".mp4") and ". " in file: - ff = re.split("\d+\. ", file)[1].replace(".mp4", "") + ff = re.split(r"\d+\. ", file)[1].replace(".mp4", "") current_files.append(ff) # unique videos by checking if the video name is in the current files - videos = [video for video in videos if clean_name(video["title"]) not in current_files] + videos = [ + video for video in videos if clean_name(video["title"]) not in current_files + ] for video in videos: self.current_video_index = video_index + len(current_files) @@ -356,7 +364,9 @@ def download_entire_course(self, *args, **kwargs): ) except requests.exceptions.TooManyRedirects: - click.echo(click.style(f"TooManyRedirects: Your cookie is expired", fg="red")) + click.echo( + click.style(f"TooManyRedirects: Your cookie is expired", fg="red") + ) except KeyError as e: click.echo(click.style(f"KeyError: That course is not found {e}", fg="red")) @@ -375,11 +385,12 @@ def download_entire_course(self, *args, **kwargs): fg="red", ) ) - except json.decoder.JSONDecodeError as e: - click.echo(click.style( - f"The course is locked, you probably " - f"need a premium account", - fg="red") + except json.decoder.JSONDecodeError as e: + click.echo( + click.style( + f"The course is locked, you probably " f"need a premium account", + fg="red", + ) ) except Exception as e: if os.path.exists(