diff --git a/README.md b/README.md index 3b7f0f8..ac2eb95 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,7 @@ # nrkdl +Releases + Download shows and movies from tv.nrk.no **Disclaimer:** This is for educational purposes ONLY. Use at your own risk. @@ -10,6 +12,11 @@ Download shows and movies from tv.nrk.no pip install nrkdl ``` +#### System requirements + +- python3 +- ffmpeg + ## Options ``` @@ -18,23 +25,22 @@ pip install nrkdl --url URL URL for the Movie/TV-show (e.g: https://tv.nrk.no/program/KOID75006720) - --location LOCATION Desired download location (Default is the current - working directory) + --write-subtitles Download subtitles ``` ### Example usage -#### Download an entire tv-show: +#### Download an entire tv-show with subtitles: ```bash -nrkdl --url https://tv.nrk.no/serie/exit +nrkdl --url https://tv.nrk.no/serie/exit --write-subtitles ``` #### Download a single tv-show episode: ```bash -nrkdl --url https://tv.nrk.no/serie/exit/sesong/2/episode/6/avspiller +nrkdl --url https://tv.nrk.no/serie/exit/sesong/2/episode/6/ ``` #### Download a movie: diff --git a/nrkdl/nrkdl.py b/nrkdl/nrkdl.py index 3db2837..db55910 100644 --- a/nrkdl/nrkdl.py +++ b/nrkdl/nrkdl.py @@ -2,6 +2,7 @@ import os import yt_dlp import argparse +import re parser = argparse.ArgumentParser() parser.add_argument( @@ -10,13 +11,7 @@ required=True, help="URL for the Movie/TV-show (e.g: https://tv.nrk.no/program/KOID75006720) ", ) -parser.add_argument( - "--location", - type=str, - required=False, - help="Desired download location (Default is the current working directory)", - default=os.getcwd(), -) +parser.add_argument("--write-subtitles", action="store_true", required=False, help="Download subtitles") args = parser.parse_args() @@ -36,22 +31,26 @@ def my_hook(d): file_tuple = os.path.split(os.path.abspath(d["filename"])) print("Done downloading {}".format(file_tuple[1])) if d["status"] == "downloading": - print(d["filename"], d["_percent_str"], d["_eta_str"]) + print("Downloading:", d["filename"]) + print("Progress:", d["_percent_str"]) + print("ETA:", d["_eta_str"]) + print() def download(): try: - pattern = r"[0-9]+[.]+[ ]" # Will be used for removing x. episodetitle from the filename + _pattern = r"[0-9]+[.]+[ ]" video_title = "%(series)s" # Title of show/movie movie = "%(title)s.%(ext)s" # Moviename.mp4 tvshow = "%(series)s - %(season_number)sx%(episode_number)s - %(episode)s.%(ext)s" # Exit - 1x2 - Horer og hummer på Hankø - folder_name = args.location + "/" + video_title + download_path = os.getcwd() + folder_name = download_path + "/" + video_title if "/serie/" in args.url: # Identify if its a tvshow or movie filename = tvshow else: filename = movie ydl_opts = { - "writesubtitles": True, + "writesubtitles": args.write_subtitles, "outtmpl": folder_name + "/" + filename, "quiet": True, "skip_download": False, diff --git a/setup.py b/setup.py index ec9c549..a54597e 100755 --- a/setup.py +++ b/setup.py @@ -5,9 +5,9 @@ setuptools.setup( name="nrkdl", - version="1.0.1", + version="1.0.2", author="jenlys", - description="Download videos from tv.nrk.no", + description="Download movies/tv-shows from nrk.no", long_description=long_description, long_description_content_type="text/markdown", packages=setuptools.find_packages(),