Downloads series and movies from German public media libraries (Öffentlich-Rechtliche Sender) to your Synology NAS, for use with Synology Video Station.
Project description
mediathekDownloader
What it does
Downloads series and movies from German public media libraries (Öffentlich-Rechtliche Sender) to your Synology NAS, for use with Synology Video Station. It works from the command line and should be used from scripts.
Setup
Prepare your NAS
Make sure these packages are installed:
- Python 3.8 package is installed.
- Video Station This can be done in the package center ('Paket-Zentrum').
Prepare your media library
-
Open Video Station. In settings, select the library you want to use. Click on
Export Metadata
. This will write.vsmeta
files into the directories it's using, but triggers as well to use such file format to retrieve information about new videos the indexer finds. -
When downloading videos, you will have to specify if you are either downloading episodes of a series (
-S
option) or movies (-M
option). So, make sure your library is set-up correctly. Otherwise, media information provided by the.vsmeta
file won't be interpreted. Important to remember: the path you are downloading to isn't the library - but needs to be assigned to your library. So, all directories below a library share the same media type setting implicitely.
Install the python app
Steps to install via SSH (and currently, there is no other):
-
Access your NAS via SSH.
-
Choose a folder, e.g. home (
cd ~
), and create a virtual environment. Activate it.python3 -m venv mediathekDL cd mediathekDL source scripts/activate
-
Install pip.
-
Install the mediathekdownloader:
pip --install mediathekdownloader
Test your installation
Still at the SSH shell, enter this command:
python3 -m nediathekDownloader -h
As a result, you should get a help text, as shown below. You are done with the setup.
How to use the app
Principles
The app uses https://mediathekviewweb.de to retrieve a list of files for download (more exactly: a feed). It sorts out any special emissions for disabled (sorry for that, but I tried to minimize download and will add an option to override this if necessary - just mail me).
Then, it starts multiple threads for downloading, writes a metadata file for Synology's videostation and triggers a re-indexing for the upload directory. To download only relevant file, I check for files already downloaded (saved in a history file called download.txt
) and existing files. If either exists, the download is skipped. Then, for episodes, it tries to detect strings saying something about the season and episode. If nothing can be found, then it takes the current year as season and the calendar week number * 10 + weekday (with Monday = 1, Sunday = 7) as episode number. Please mail me if you think you have a better method to set it for your downloads.
Methods to tell how to find the media for download
-
Using the search term: Go to https://mediathekviewweb.de and search for your download.
Example:
!ARD #Maus >10
to search for all episodes of "Die Sendung mit der Maus" at station "ARD" that are longer than 10 minutes (they provide a lot of short cuts for each episode, which is not really helpful if you want to retrieve an episode as broadcasted each Sunday morning).The command
python3 -m nediathekDownloader -s '!ARD #Maus >10' -[S/M] directory
will download based on the search string. -
Using the feed. Same procedure, but now generate a feed at https://mediathekviewweb.de and use the feed URL for retrieval. Example:
python3 -m nediathekDownloader -f 'https://mediathekviewweb.de/feed?query=!ard%20%23maus%20%3E10' -[S/M] directory
will do the job.
Command line
$:>python -m mediathekDownloader -h
Usage: mediathekDwnld.py [OPTIONS] PATH
The app allows to retrieve videos from German, Austrian and Suisse TV
station media libraries ("Mediathek"). Central accesspoint to these
resources is https://mediathekviewweb.de/. Either the search string used
there or the provided RSS-feed passed to the script using options
--search or --feed. Idea is to write the file to a Synology NAS with DS
Video app installed. This is why a .vsmeta file is being generated with
the media, to feed Synology's indexer.
Options:
-f, --feed TEXT Specify either the feed URL (RSS) or the search
string from mediathekviewweb.
-s, --search TEXT Specify either the feed URL (RSS) or the search
string from mediathekviewweb.
-p, --threads INTEGER The app supports multithreading. How many threads
should be started? [default: 1]
-m, --maxfiles INTEGER When collecting a search result, several larger
files might be downloaded. Here, specify max=0 to
download all, or the maximum number to download.
[default: 8]
-v, --verbous Print program output at lowest level. [default:
False]
-V, --veryverbous Print program output at lowest level plus feed
items. [default: False]
-t, --test Do not really download or write files. [default:
False]
-S, --series First option to set the media type: use it when
downloading episodes of a series.
-M, --movie Second option to set the media type: use it when
downloading movies.
-h, --help Show this message and exit.
Example script
To be used in your NAS' task scheduler
#!/bin/sh
#encoding: utf8
#Go to the directory of the venv - where this script should be located
cd /volumeX/[path]
#Download using the venv
bin/python3 -m mediathekDownloader -S -m 20 -v -s '!ARD #Maus >10 <40' /volume1/video/Maus
#Rebuild video station's index
/usr/syno/bin/synoindex -R /volume1/video/Maus &
To be used at the command line
To download series, I use this script:
#!/bin/sh
#encoding: utf8
cd /volume2/nas-processes/mediathek-dl
bin/python3 -m mediathekDownloader -S -p 2 -s "$1" -m 4 /volume1/video/Serien-Mediathek-DL
/usr/syno/bin/synoindex -R /volume1/video/Serien-Mediathek-DL &
Apendix
Screen shots of the property screens for the media types
Here are the screenshots of the supported media types in German English (I did not had English screenshots at hand - please add them if you have).
References
- Synology Video Station:
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for mediathekDownloader-1.0.2.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 23b4830687961088526ae951a5c3f93378f53b3f62ca6bc072fb747a6f2bb45f |
|
MD5 | 8ae9cebbf0d43891b645f0ba76b629c6 |
|
BLAKE2b-256 | cf483ab47e3884db80d3a8c1a9f3ae69e00dcdec1142bd64d7bc27622080200b |
Hashes for mediathekDownloader-1.0.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e94d5e7f08d2f1fe226b7af4a1ff92b38a616bf23d37b293b32f17a1687226c9 |
|
MD5 | 25c0a73bcb075e70e8d1316a316f1638 |
|
BLAKE2b-256 | 027ecffe2dfaad32c371cc8a8c9cfb700f603214d141c1cc6778700b9c63ad83 |