Skip to content

Commit

Permalink
removed --location flag , made subtitles optional
Browse files Browse the repository at this point in the history
  • Loading branch information
jenslys committed Mar 6, 2022
1 parent 2553233 commit ffa9c17
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 18 deletions.
16 changes: 11 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# nrkdl

<a href="https://github.com/jenslys/nrkdl/releases/"><img src="https://img.shields.io/github/v/release/jenslys/nrkdl.svg" alt="Releases"></a>

Download shows and movies from tv.nrk.no

**Disclaimer:** This is for educational purposes ONLY. Use at your own risk.
Expand All @@ -10,6 +12,11 @@ Download shows and movies from tv.nrk.no
pip install nrkdl
```

#### System requirements

- python3
- ffmpeg

## Options

```
Expand All @@ -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:
Expand Down
21 changes: 10 additions & 11 deletions nrkdl/nrkdl.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import os
import yt_dlp
import argparse
import re

parser = argparse.ArgumentParser()
parser.add_argument(
Expand All @@ -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()


Expand All @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down

0 comments on commit ffa9c17

Please sign in to comment.