The Perfect Media Server with Docker: Plex and Automatic Bittorrent

Disclaimer: Obviously be mindful of the laws in your country and we strictly advise only downloading content you are legally allowed to.

I know, I know... streaming Netflix and Youtube are great. They've changed how people watch tv. If you have a chromecast or a roku you just beam all your favorite shows from your phone to the screen. It's so convenient.

But what about your old media collection. What about those alphabet soup of video files lying around? Those mp4's, avi's, m4v's, mvk's, and who knows what else. You know, the ones you legally bought. Well those guys just take up space on your computer, until now.

For the solution, we'll turn to Docker. If you aren't familiar with Docker I offer an intro in my previous article about using Jenkins to build Maven and NodeJS projects.


Plex

The real key to this setup is the Plex Media Server. It's free to use and lets you stream from desktop, Chromecast, as well Android and iOS, giving a Netflix-like experience. It organizes shows by season, finds artwork as well as remembering where you left off.

You can even share access with your friends or use it from your desktop.

You could download it directly, but I've found it is either quite a memory hog or just flat out leaks like a sieve. The quickest way to safely get setup is to launch this lovely dockerized version. Simply fire up this command.

docker run --restart=always -d --name=plex \  
    --net=host \
    -e VERSION=latest \
    -e PUID=<UID> -e PGID=<GID> \
    -m 500m \
    -v ~/plex:/config \
    -v /<MYDOWNLOAD_FOLDER>/tvshows:/data/tvshows \
    -v /<MYDOWNLOAD_FOLDER>/movies:/data/movies \
    -p 32400:32400 \
    linuxserver/plex

You're going to want to replace <UID> and <GID> as suggested in their docs. And of course change <MYDOWNLOAD_FOLDER> to your local media directory.

As you can see I've limited the memory to 500MiB for Plex. It runs great for me at that limit. If you're having trouble you may want to increase it slightly, but I'd recommend instead checking your local wifi setup to ensure you are getting enough speed between your computer and your TV as that is another common problem.

Need help with Docker?

Work with Quantum Mob.

Filebot

One thing you may notice is Plex can be overly particular with naming conventions, especially on TV shows. The best solution for this is the handy Filebot renamer. Go for the command line version. It's fun to manually fiddle around with file renaming (not really), but automating it is probably a little more fun.

When you're all setup there, move all the shows that need renaming into the folder /<MYDOWNLOAD_FOLDER>/toProcess and run the command

filebot -rename "/<MYDOWNLOAD_FOLDER>/toProcess" --format "/<MYDOWNLOAD_FOLDER>/tvshows/{n}/Season {s.pad(2)}/{n} - {s00e00} - {t}" -non-strict -r --db TheTVDB  

What does Filebot do?

It goes through all the files in your toProcess folder, performs a lookup on the site TheTVDB and uses that information to properly rename in a way Plex will be happy with and moves the files under /<MYDOWNLOAD_FOLDER>/tvshows/.

Whew, nice and easy. If you go to Plex at this point and nothing is there, try going to your tvshows library and doing a refresh. Alternatively, you can setup automatic refreshing from the library settings.

BitTorrent

BitTorrent shouldn't be news to most of you. This peer-to-peer sharing protocol has been around for quite a while. What is newer, is the super stripped down and dockerized versions.

Today we're going to go with ruTorrent. It provides a nice web dashboard so you're able to manage your torrents from your browser (either http://localhost/ or the local IP of the machine you installed it on).

Note: just be a little security minded about opening port 80 to the whole world

docker run --restart=always -d --name rutorrent \  
    -e PUID=<UID> -e PGID=<GID> \
    -m 700m \
    -v ~/rutorrent:/config \
    -v /<MYDOWNLOAD_FOLDER>:/downloads \
    -p 80:80 -p 5000:5000 \
    -p 51413:51413 -p 6881:6881/udp \
    linuxserver/rutorrent

Again you're going to want to replace <MYDOWNLOAD_FOLDER> before running this as well as the <UID> and <GID>. I've gone ahead and limited the memory to 700MiB. It boots up at 43MiB usage, so 700 is plenty of space. If you don't limit it, I've seen it balloon to several gigs. Thankfully again, docker was able to keep these apps from making our fans spin wildly. This is one of the benefits of using Docker.

Automating BitTorrent

A lot of people use BitTorrent to download torrents one by one. Again, fun but we love automating things. Also, I don't know about you but the less of those spammy clickbait ads I see the better my day is.

RSS feeds. They give you great things like the latest articles from us, but they can also be used by that ruTorrent we just setup so you can get shows as soon as they're posted. There are a few options out there for this but the ones I find pretty useful are yts.ag and showrss.info. From these sites you can create a feed and ruTorrent will happily get to work after you add it into them. Again, please see our disclaimer and ensure you are only downloading content you own.

Conclusion

Automating is fun. RSS feeds reduce the manual effort of downloading while filebot makes Plex play nicely. Plex, in turn, is a great media server and doesn't hog your machine when configured correctly. Have another setup you like? Let me know!

Erich Reich

Erich is a co-founder and consultant with Quantum Mob

Toronto, Canada https://qmo.io

Need help with docker?

Let's work together.

Subscribe to Quantum Blog

Get the latest posts delivered right to your inbox.

or subscribe via RSS with Feedly!