Svtplay-dl in Docker
As I was fiddling with Docker I made this simple Dockerfile to wrap and execute svtplay-dl.
FROM jfloff/alpine-python:2.7-slim MAINTAINER dodgydudes RUN apk add --update py-requests ffmpeg && pip install svtplay-dl VOLUME /tmp WORKDIR /tmp ENTRYPOINT ["/usr/bin/python2.7", "/usr/bin/svtplay-dl", "--remux", "--merge-subtitle", "--exclude=teckentolkat,syntolkat"]
First of I needed a small image that had python preinstalled. I found jfloff's alpine-python image and decided to use the 2.7-slim version for my build.
Then I installed ffmpeg from the Alpine repository, it's only needed if you want to remux the downloaded streams. Then I installed the latest version of svtplay-dl using pip.
To make the image easier to use I added /tmp as a mountable volume and also changed the workdir to /tmp as the files will end up in the directory in which the svtplay-dl command is executed.
In the ENTRYPOINT you can specify whatever options you want to use as a baseline. Options can be added when the docker image is executed as well. I want to remux the audio and video to one single file this will be done with the --remux option. I also want to download and merge subtitles to this single file if there are any, this is done with --merge-subtitle. If you want to download a whole series you might want to exclude episodes which are made for the hearing disabled, easily fixed with the --exclude option. List of all options is available here.
Now build the image.
docker build -t svtplay:alpine .
And if you want to make sure you rebuild the image with the latest version of svtplay-dl just add the --no-cache to your command.
docker build --no-cache -t svtplay:alpine .
Once the image is build it's time to use it. Specify the directory in which you want the downloaded files to appear and paste the URL to the episode or series you want to grab.
docker run -it --rm -v </my/dl/directory>:/tmp svtplay:alpine -A https://www.svtplay.se/grotesco
It is possible to add options to the run command as you can see in the example above in which I have added the -A to download all available episodes.
I also use the --rm option in my docker run command, this will remove the container once it has finished running. This is good practice or else you will get loads of zombie containers on your system.
I had some issues with permissions of the downloaded files. To mitigate this I pass along the UID of the user that I want to have ownership of the files.
docker run -it --rm -v </my/dl/directory>:/tmp -u 1000:1000 svtplay:alpine -A https://www.svtplay.se/grotesco
That's about it, happy hoarding!