anime-media-centre/README.md

155 lines
6.4 KiB
Markdown
Raw Permalink Normal View History

2022-12-08 21:44:08 +01:00
# Media Server
Eases the setup of a media server that requires as little manual input as possible.
## Modules
### Jellyfin
For displaying and streaming your media
### ShokoAnime
For sorting your anime after downloading them
### qBittorrent
For downloading media
### Caddy
For securing your connection over HTTPS/TLS and handling incoming requests
### Cloudflare Tunnel (Cloudflared)
For securing your local router, preventing your IP from being exposed and eliminating the need for opening up a port in your router
## Scripts
- `./caddy` - lets you quickly reload your Caddy config if you made changes to the Caddyfile by running `./caddy reload`
- `./qBittorrent/scripts/hardlink-torrent.sh` - used with qBittorrent to create hardlinks to your torrents on successfully completed download. This allows you to keep seeding after Shoko moves the files elsewhere. Files can be deleted from the downloads folder if you no longer wish to seed. All hardlinks to a file has to be deleted for the file to be deleted.
- `./update.sh` will force rebuild (and update) all containers.
## Setup
### Dependencies
Install Docker on your system. Easiest way is to just download [Docker Desktop](https://docs.docker.com/desktop/troubleshoot/overview/) and let it handle it.
If you're using an Nvidia GPU and want GPU transcoding, you should also follow [these steps](https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/nvidia-docker.html) to install the Nvidia container dependencies. For Fedora, try [this guide](https://gist.github.com/JuanM04/fcbed16d0f4405a286adebee5fd31cb2) instead.
### Cloudflare
Make sure you setup Cloudflare with your domain. Log into [cloudflare](https://www.cloudflare.com/) and follow the setup in the domains tab.
You need to setup `cloudflared` once and copy over some files to get the tunnel working. You can follow [this](https://developers.cloudflare.com/cloudflare-one/connections/connect-apps/install-and-setup/tunnel-guide/local/#set-up-a-tunnel-locally-cli-setup) guide to set it up locally. I'll summarise it here quickly but will skip how to install the `cloudflared` package as that varies by distro.
Run this command to generate required files
```sh
cloudflared tunnel login
```
Then this one to create a tunnel. The name can be anything you want that helps you recognise the server.
```sh
cloudflared tunnel create <NAME>
```
Run this for each of the subdomains, `jellyfin.domain.tld`, `shoko.domain.tld`, `torrent.domain.tld`, `files.domain.tld` and if you want a way to quickly test if Caddy is working, you can also add `ping.domain.tld`. Replace `domain.tld` with your domain. You can use different subdomains by changing them in the `.env` file.
```sh
cloudflared tunnel route dns <UUID or NAME> <hostname>
```
An example of the command above could be
```sh
cloudflared tunnel route dns example-pc ping.example.com
```
Copy the credentials file to `./Cloudflared/config/` (it should be stored in `~/.cloudflared/`). Example:
```sh
sudo cp ~/.cloudflared/<UUID>.json ~/Documents/media-server/Cloudflared/config/
```
The name of the credentials file above is the UUID of the tunnel, put that in the `.env` file as instructed in the next step.
### Environment Variables
Create a `.env` file based on the content in `.env.example`. The example will include comments that will help with what value is needed there.
The CF_API_TOKEN requires you to follow [this guide](https://samjmck.com/en/blog/using-caddy-with-cloudflare/). You can either follow the second step or the third step. If you follow the second step, you can skip the part about downloading some Caddy packages as the Dockerfile handles that already. Just skip to the part about generating an API token
### Passwords
**Use strong passwords for all services!!** A strong password is one that is long, not one that uses lots of weird symbols.
qBittorrent defaults to username 'admin' and password 'adminadmin'. Make sure you go into the settings under WebUI and change that immediately!
### ShokoAnime
After going through the setup (or potentially during setup) set the import folders like this
`Anime Source -> /mnt/import` using drop type "source" and enabling "watch for new files"<br>
`Anime Destination -> /mnt/anime` using drop type "Destination"
Go to settings and adjust these settings
```
# Import
Rename on Import = true
Move on Import = true
Move after rename = true
# Relation
Auto Group Series = true
```
### Jellyfin
#### Shokofin
You'll have to add the Shokofin plugin to Jellyfin. Do that by going to `Settings -> Dashboard -> Plugins`. In there go to the `Repositories` tab at the top. Add new
Repository Name: `Shokofin Stable`<br>
Repository URL: `https://raw.githubusercontent.com/ShokoAnime/Shokofin/master/manifest.json`
Now you have to go to the `Catalog` tab and install Shokofin (might be named Shoko). Restart Jellyfin after this.
Go back to the Plugins list and click Shoko/Shokofin to configure.
Host: `http://shoko_server:8111`
This lets Jellyfin talk to Shoko directly rather than going through Cloudflare for each request.
For Library settings I recommend using these settings
Series/Season Grouping: Group series into Seasons based on Shoko's Groups<br>
Box-Sets/Movie Grouping: Create Box-sets based upon Shoko's Groups and Series entries
Finally the advanced settings
Public Shoko host URL: `shoko.domain.tld`<br>
Add AniDB ID to items: enabled
#### Transcoding
You should enable transcoding to offload work from the CPU to the GPU. This process varies from GPU to GPU and detailed setup can be found [here](https://jellyfin.org/docs/general/administration/hardware-acceleration.html). The current config is based on using an Nvidia GPU, in which case you only have to select the Nvidia NVENC option under Hardware Accelleration.
### qBittorrent
For this, you need to set the hardlinker script to run after download.
Set the default downloads folder to /base/downloads. At the top of the downloads settings, set the `Torrent content layout` setting to `Create subfolder`.
Enable `Run external program on torrent completion` and put this in the input field<br>
`/scripts/hardlink-torrent.sh "%R" "/base/import/%N"`
Also set download category as Anime for anime, Music for music, and Movies for movies. You can add more categories in the `hardlink-torrent.sh` script
## Notes
Shoko server has a local interface for use with Shoko Desktop in case you need that. The URL for that is `http://localhost:8111`.