Package: mediathekDownloader
mediathekDownloaderWhat it doesDownloads 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.SetupPrepare your NASMake 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 libraryOpen Video Station. In settings, select the library you want to use. Click onExport Metadata. This will write.vsmetafiles 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 (-Soption) or movies (-Moption). So, make sure your library is set-up correctly. Otherwise, media information provided by the.vsmetafile 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 appSteps 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-mvenvmediathekDLcdmediathekDLsourcescripts/activateInstall pip.Install the mediathekdownloader:pip--installmediathekdownloaderTest your installationStill at the SSH shell, enter this command:python3-mnediathekDownloader-hAs a result, you should get a help text, as shown below. You are done with the setup.How to use the appPrinciplesThe app useshttps://mediathekviewweb.deto 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 calleddownload.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 downloadUsing the search term: Go tohttps://mediathekviewweb.deand search for your download.Example:!ARD #Maus >10to 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 commandpython3 -m nediathekDownloader -s '!ARD #Maus >10' -[S/M] directorywill download based on the search string.Using the feed. Same procedure, but now generate a feed athttps://mediathekviewweb.deand use the feed URL for retrieval. Example:python3 -m nediathekDownloader -f 'https://mediathekviewweb.de/feed?query=!ard%20%23maus%20%3E10' -[S/M] directorywill do the job.Command line$:>python-mmediathekDownloader-h
Usage:mediathekDwnld.py[OPTIONS]PATHTheappallowstoretrievevideosfromGerman,AustrianandSuisseTVstationmedialibraries("Mediathek").Centralaccesspointtotheseresourcesishttps://mediathekviewweb.de/.EitherthesearchstringusedthereortheprovidedRSS-feedpassedtothescriptusingoptions--searchor--feed.IdeaistowritethefiletoaSynologyNASwithDSVideoappinstalled.Thisiswhya.vsmetafileisbeinggeneratedwiththemedia,tofeedSynology'sindexer.

Options:-f,--feedTEXTSpecifyeitherthefeedURL(RSS)orthesearchstringfrommediathekviewweb.-s,--searchTEXTSpecifyeitherthefeedURL(RSS)orthesearchstringfrommediathekviewweb.-p,--threadsINTEGERTheappsupportsmultithreading.Howmanythreadsshouldbestarted?[default:1]-m,--maxfilesINTEGERWhencollectingasearchresult,severallargerfilesmightbedownloaded.Here,specifymax=0todownloadall,orthemaximumnumbertodownload.[default:8]-v,--verbousPrintprogramoutputatlowestlevel.[default:False]-V,--veryverbousPrintprogramoutputatlowestlevelplusfeeditems.[default:False]-t,--testDonotreallydownloadorwritefiles.[default:False]-S,--seriesFirstoptiontosetthemediatype:useitwhendownloadingepisodesofaseries.-M,--movieSecondoptiontosetthemediatype:useitwhendownloadingmovies.-h,--helpShowthismessageandexit.Example scriptTo be used in your NAS' task scheduler#!/bin/sh#encoding: utf8#Go to the directory of the venv - where this script should be locatedcd/volumeX/[path]#Download using the venvbin/python3-mmediathekDownloader-S-m20-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 lineTo download series, I use this script:#!/bin/sh#encoding: utf8cd/volume2/nas-processes/mediathek-dl
bin/python3-mmediathekDownloader-S-p2-s"$1"-m4/volume1/video/Serien-Mediathek-DL

/usr/syno/bin/synoindex-R/volume1/video/Serien-Mediathek-DL&ApendixScreen shots of the property screens for the media typesHere 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).ReferencesSynology Video Station:Help in Support CenterProduct Page