-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Start of version 3, complete rewrite * Replace tests * Update dependencies * Update tox config * Update CLI * Add type hints * Update docs 1st pass * Change version * Remove old notebooks * Ignore VS Code settings * Change entrypoint * Update documentation * Add return type * Add README to PyPi
- Loading branch information
Showing
36 changed files
with
2,015 additions
and
6,570 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
[flake8] | ||
# Make flake8 compatible with black | ||
max-line-length = 88 | ||
extend-ignore = E203, W503 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
repos: | ||
- repo: https://github.com/psf/black | ||
rev: 22.3.0 | ||
hooks: | ||
- id: black | ||
|
||
- repo: https://gitlab.com/pycqa/flake8 | ||
rev: 3.9.2 | ||
hooks: | ||
- id: flake8 | ||
|
||
- repo: https://github.com/pre-commit/mirrors-mypy | ||
rev: v0.942 | ||
hooks: | ||
- id: mypy | ||
additional_dependencies: | ||
- pydantic | ||
- types-requests | ||
- types-setuptools | ||
|
||
- repo: https://github.com/PyCQA/isort | ||
rev: 5.10.1 | ||
hooks: | ||
- id: isort | ||
|
||
# - repo: https://github.com/PyCQA/pydocstyle | ||
# rev: 6.1.1 | ||
# hooks: | ||
# - id: pydocstyle | ||
# files: ^src/ | ||
# additional_dependencies: | ||
# - toml | ||
|
||
- repo: https://github.com/pre-commit/pre-commit-hooks | ||
rev: v4.2.0 | ||
hooks: | ||
- id: check-added-large-files | ||
|
||
- repo: https://github.com/Lucas-C/pre-commit-hooks | ||
rev: "v1.1.13" | ||
hooks: | ||
- id: remove-crlf | ||
|
||
- repo: https://github.com/kynan/nbstripout | ||
rev: 0.5.0 | ||
hooks: | ||
- id: nbstripout |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
For information on how to contribute, [see the documentation](https://nrkdownload.readthedocs.io/en/latest/90_contributing.html). | ||
For information on how to contribute, [see the | ||
documentation](https://nrkdownload.readthedocs.io/en/latest/90_contributing.html). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,33 @@ | ||
# nrkdownload | ||
![Supports python 2.7, 3.6, 3.7, 3.8](https://img.shields.io/badge/python-2.7%2C%203.6%2C%203.7%2C%203.8-brightgreen.svg "Supported Python versions") | ||
|
||
This is a commandline tool to download programs and series from NRK (Norwegian public broadcaster). It supports both TV, Radio and Podcast content. The tool is written in Python, and is compatible with Python 2.7 and 3.x. It has been tested under Linux, Mac OS X and Windows. | ||
!["Latest version"](https://img.shields.io/github/v/release/marhoy/nrk-download?include_prereleases) | ||
|
||
!["Supported Python versions"](https://img.shields.io/pypi/pyversions/nrkdownload) | ||
|
||
This is a commandline tool to download programs and series from NRK (Norwegian public | ||
broadcaster). It supports both TV, Radio and Podcast content. The tool is written in | ||
Python, and is compatible with Python 3.7 or newer. It has been tested under Linux, Mac | ||
OS X and Windows. | ||
|
||
# Documentation | ||
The documentation for nrkdownload is availabe here: | ||
https://nrkdownload.readthedocs.org | ||
|
||
The documentation for nrkdownload is availabe here: https://nrkdownload.readthedocs.org | ||
|
||
# Setting up a development environment | ||
Install [poetry](https://python-poetry.org/), and a recent Python version (>=3.6). | ||
If you want to run tests with multiple Python versions, install [pyenv](https://github.com/pyenv/pyenv). | ||
Set up the development environment: | ||
|
||
Install [poetry](https://python-poetry.org/), and a recent Python version (>=3.7). If | ||
you want to run tests with multiple Python versions, install | ||
[pyenv](https://github.com/pyenv/pyenv). Set up the development environment: | ||
|
||
```bash | ||
poetry install | ||
``` | ||
|
||
|
||
# Making a new release | ||
|
||
- Make sure all tests are ok by running `tox` | ||
- Make a pull requst on GitHub | ||
- Use the "new release" functionallity of GitHub. Make a new tag. | ||
- Update `pyproject.toml` to match the new version number. | ||
- Update `pyproject.toml` and `__init__.py` to match the new version number. | ||
- `poetry build` | ||
- `poetry publish` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,52 +1,38 @@ | ||
Features | ||
======== | ||
|
||
This is a commandline tool to download content from NRK | ||
(Norwegian public broadcaster). It supports downloading TV, radio and podcasts. | ||
The tool is written in Python, and is compatible with Python 2.7 | ||
and 3.x. It has been tested under Linux, Mac OS X and Windows. | ||
This is a commandline tool for downloading content from NRK (Norwegian public | ||
broadcaster). It supports downloading TV series and programs. The tool is written in | ||
Python, and is compatible with Python 3.8 or newer. It has been tested under Linux, Mac | ||
OS X and Windows. | ||
|
||
As of autumn 2018, NRK has started to require a secret key in the header of | ||
the API requests. This download-tool works even after those restrictions. | ||
Users outside of Norway should note that some of the content is | ||
geo-restricted. | ||
Please only use this tool for personal purposes. You are responsible for not breaking | ||
any Intellectual Property Rights. Users outside of Norway should note that some of the | ||
content is geo-restricted. | ||
|
||
|
||
How is this tools different than others? | ||
---------------------------------------- | ||
Downloading media and metadata | ||
------------------------------ | ||
|
||
When you download a program with this tool, it doesn't just download one | ||
file. If the program is part of a series, directories for the series and | ||
season is created. And the file is automatically named according to its | ||
episode and season number. Subtitles and additional images are also | ||
automatically downloaded. The subtitles are automatically embedded in the | ||
.m4v-file, so you could decide to delete the .srt-file. (I have found that in | ||
some tools (like VLC), the support for included subtitles is not perfect. | ||
That's why the separate .srt-file is also there.) | ||
The idea behind the tool is that the downloaded programs should integrate seamlessly | ||
into you favorite media server, e.g. Plex. If you for example download all the episodes | ||
of the popular series Førstegangstjenesten, you would get a directory-structure like | ||
this:: | ||
|
||
The idea behind all of this is that the downloaded programs should integrate | ||
seamlessly into you favorite media server, e.g. Plex. If you for example | ||
download all the episodes of the popular series SKAM, you would get a | ||
directory-structure like this:: | ||
|
||
SKAM | ||
├── poster.jpg | ||
Førstegangstjenesten | ||
├── banner.jpg | ||
├── Season 01 | ||
│ ├── SKAM - S01E01 - 1of11.jpg | ||
│ ├── SKAM - S01E01 - 1of11.m4v | ||
│ ├── SKAM - S01E01 - 1of11.no.srt | ||
⋮ | ||
├── Season 02 | ||
│ ├── SKAM - S02E01 - 1of12.jpg | ||
│ ├── SKAM - S02E01 - 1of12.m4v | ||
│ ├── SKAM - S02E01 - 1of12.no.srt | ||
│ ├── Førstegangstjenesten - s01e01 - 1. Pilot - del 1.jpg | ||
│ ├── Førstegangstjenesten - s01e01 - 1. Pilot - del 1.m4v | ||
│ ├── Førstegangstjenesten - s01e01 - 1. Pilot - del 1.no.srt | ||
⋮ | ||
└── Season 03 | ||
├── SKAM - S03E01 - 1of10.jpg | ||
├── SKAM - S03E01 - 1of10.m4v | ||
├── SKAM - S03E01 - 1of10.no.srt | ||
└── Season 02 | ||
├── Førstegangstjenesten - s02e01 - 1. episode.jpg | ||
├── Førstegangstjenesten - s02e01 - 1. episode.m4v | ||
├── Førstegangstjenesten - s02e01 - 1. episode.no.srt | ||
⋮ | ||
├── SKAM - S03E10 - 10of10.jpg | ||
├── SKAM - S03E10 - 10of10.m4v | ||
└── SKAM - S03E10 - 10of10.no.srt | ||
├── Førstegangstjenesten - s02e08 - 8. episode.jpg | ||
├── Førstegangstjenesten - s02e08 - 8. episode.m4v | ||
├── Førstegangstjenesten - s02e08 - 8. episode.no.srt | ||
└── Season02.jpg | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,64 +1,37 @@ | ||
Usage | ||
================== | ||
|
||
Before NRK restricted the API, it was possible to search for content. With | ||
the current restrictions, you will need to specify an URL for the content you | ||
want to download: Start by browsing https://tv.nrk.no (possibly | ||
https://tv.nrksuper.no/) or https://radio.nrk.no | ||
until you find what you want. Copy the URLs and give it as arguments for this | ||
tool. You can list several URLs on the command line (separated by space), | ||
or line by line in a file. Content that are already downloaded will be skipped. | ||
Start by browsing https://tv.nrk.no until you find what you want. Copy the URLs and give | ||
it as an argument for this tool. You can list several URLs on the command line | ||
(separated by space). Content that are already downloaded will be skipped. | ||
|
||
|
||
Options | ||
------- | ||
|
||
usage: nrkdownload [-h] [--version] [-d DIRECTORY] [-v] [-c] [-a | -l] | ||
[-f FILE] | ||
[URL [URL ...]] | ||
Usage: nrkdownload [OPTIONS] URLS... | ||
|
||
Download series or programs from NRK, complete with images and subtitles. | ||
Arguments: | ||
URLS... One or more valid URLs from https://tv.nrk.no/ [required] | ||
|
||
positional arguments: | ||
URL Specify download source(s). Browse https://tv.nrk.no/ | ||
or https://radio.nrk.no/ and copy the URL. The URL can | ||
point to a whole series, or just one episode. | ||
Options: | ||
-d, --download-dir PATH Download directory. Can also be specified by | ||
setting the environment variable NRKDOWNLOAD_DIR | ||
[default: /Users/marhoy/Downloads/nrkdownload] | ||
--version Print version string | ||
-v Increase logger verbosity. Can be repeated up to | ||
four times. [default: 0; x<=4] | ||
--help Show this message and exit. | ||
|
||
optional arguments: | ||
-h, --help show this help message and exit | ||
--version show program's version number and exit | ||
-d DIRECTORY The directory where the downloaded files will be | ||
placed | ||
-v, --verbose Increase verbosity. Can be repeated up to two times. | ||
-c, --cache Enable persistent caching of the API requests. | ||
-a, --all If URL matches several episodes: Download all episodes | ||
without asking. | ||
-l, --last If URL matches several episodes: Download the latest | ||
without asking. | ||
-f FILE, --file FILE Specify a file containing URLs, one URL per line. | ||
Specifying urls from a file will automatically enable | ||
--all and download all episodes from series. | ||
|
||
The files are by default downloaded to ~/Downloads/nrkdownload. This can be | ||
changed by using the option -d as described above, or you can define the | ||
environment variable NRKDOWNLOAD_DIR | ||
The files are by default downloaded to ~/Downloads/nrkdownload. This can be changed by | ||
using the option -d as described above, or you can define the environment variable | ||
NRKDOWNLOAD_DIR | ||
|
||
|
||
URL Parsing and actions | ||
----------------------- | ||
|
||
Configurable download directory | ||
------------------------------- | ||
|
||
If you don't specify anything, the files and directories will be created | ||
inside ``~/Downloads/nrkdownload``, where ``~`` means your home directory. | ||
If you want the downloads somewhere else, there are two ways to specify a | ||
different download directory: | ||
|
||
* Define an environment variable named ``NRKDOWNLOAD_DIR`` | ||
* Specify the download directory on the command line with the option | ||
``-d download_dir`` | ||
|
||
If you do both at the same time, the option from the command line will take | ||
precedence. | ||
|
||
If you don't know how to define an environment variable under your operating system, try to Google create environment variable and the name of you operating system. (Under Linux and macOS, you would want to edit your ~/.bash_profile) | ||
|
||
If the URL points to the top-level of a series, all episodes in all seasons will be | ||
downloaded. If the URL points to a specific season, only the episodes within that season | ||
will be downloaded. |
Oops, something went wrong.