Whatbox Logo
Login for certain variables to be updated with your slot's information

Wiki > Mylar

Mylar is an automated comic book (cbr/cbz) downloader for Usenet and BitTorrent users. It keeps a watchlist of series, checks the weekly pull list for new issues, sends them to your download client, then sorts, renames and tags the downloaded files. It can also track story arcs and fill in missing issues from your existing collection.

14063 was randomly generated for this article; you may use any 5-digit port between 10000 and 32767. Mylar's default port, 8090, can't be used on Whatbox.

You will need a free ComicVine API key, which Mylar uses to look up series and issues. Sign in to ComicVine and copy the key from that page before you start.

Custom installations of Mylar do not have authentication enabled by default. Follow every installation step, including the username and password in step 5, or Mylar will be publicly accessible with full access to your files.
# Installation
  1. Connect to your slot via SSH.

  2. Download Mylar: git clone https://github.com/mylar3/mylar3.git ~/mylar3

  3. Create a virtual environment for Mylar and install its requirements: python3 -m venv ~/mylar3/venv ~/mylar3/venv/bin/python -m pip install -r ~/mylar3/requirements.txt

    This takes a minute or two.

  4. Create the folders for Mylar's settings and your comics, then create the configuration file: mkdir -p ~/.config/Mylar ~/files/Comics touch ~/.config/Mylar/config.ini chmod 600 ~/.config/Mylar/config.ini nano ~/.config/Mylar/config.ini

  5. Paste in the following. Replace YOUR_COMICVINE_API_KEY with your ComicVine key, and replace changeme with a unique password for Mylar (do not reuse your Whatbox password). You can change the comic library folder in destination_dir too: [Interface] http_port = 14063 http_host = 0.0.0.0 http_username = user http_password = changeme authentication = 2

     [General]
     launch_browser = False
     destination_dir = /home/user/files/Comics
    
     [CV]
     comicvine_api = YOUR_COMICVINE_API_KEY
    

    Save with Ctrl + S and exit with Ctrl + X. Mylar adds the rest of its settings to this file the first time it starts.

  6. Start Mylar in a screen session: screen -dmS mylar /home/user/mylar3/venv/bin/python /home/user/mylar3/Mylar.py --datadir /home/user/.config/Mylar --nolaunch

    The first start takes a minute while Mylar creates its database and downloads the weekly pull list.

  7. Visit http://server.whatbox.ca:14063 and log in with the username and password from step 5. You can watch Mylar's output with screen -r mylar, and detach again with Ctrl + A, then D.

Configuration

Configure Mylar from its web interface, under the gear icon at the top right. The Mylar documentation covers every setting; these are the first ones to set up:

  • Comic Location: under Web Interface → Comic Location. It's already set to /home/user/files/Comics by step 5.
  • Download client: under Download Settings, choose SABnzbd, NZBGet or a torrent client and enter its connection details. Mylar must be able to read the folder your download client saves finished files to.
  • Search providers: under Search Providers, add your Usenet indexers and trackers. Prowlarr and Jackett indexers can be added as Newznab or Torznab providers.
  • Login: change your username or password under Web Interface → Authentication. Leave the method set to Forms (Login Page).
  • Existing collection: to add comics you already have, use Manage → Import a directory. Click Save Changes at the bottom of each page. Settings marked as needing a restart only apply after you restart Mylar, using Restart under the gear icon.

Mylar's settings, database and logs are kept in ~/.config/Mylar, with the logs in ~/.config/Mylar/logs/. For help, read the logs under Logs in the web interface, then ask on the Mylar forum or on Mylar's Discord server, linked from the Mylar website.

Automatically Restart (optional)

  1. Create a restart script: touch ~/mylar_restart.cron nano -w ~/mylar_restart.cron

  2. Paste in the following: #!/bin/bash if pgrep -fx "/home/user/mylar3/venv/bin/python /home/user/mylar3/Mylar.py --datadir /home/user/.config/Mylar --nolaunch" > /dev/null then echo "Mylar is running." else echo "Mylar is not running, starting Mylar" screen -dmS mylar /home/user/mylar3/venv/bin/python /home/user/mylar3/Mylar.py --datadir /home/user/.config/Mylar --nolaunch fi exit

    Save and exit.

  3. Make the script executable: chmod +x ~/mylar_restart.cron

  4. Open your crontab: EDITOR=nano crontab -e

  5. Add these lines, then save and exit: @reboot /home/user/mylar_restart.cron >/dev/null 2>&1 */5 * * * * /home/user/mylar_restart.cron >/dev/null 2>&1

  1. On the Manage Links page, click Add a custom app.

  2. Name it mylar and enter port 14063.

  3. Visit https://mylar.example.box.ca and log in.

  4. Once the link works, make the plain HTTP port private by setting the bind address to 127.0.0.1. Stop Mylar first, as it can rewrite config.ini while it's running: pkill -fx "/home/user/mylar3/venv/bin/python /home/user/mylar3/Mylar.py --datadir /home/user/.config/Mylar --nolaunch" sleep 5 sed -i 's|^http_host = 0.0.0.0|http_host = 127.0.0.1|' ~/.config/Mylar/config.ini screen -dmS mylar /home/user/mylar3/venv/bin/python /home/user/mylar3/Mylar.py --datadir /home/user/.config/Mylar --nolaunch

    Apps on your slot that talk to Mylar keep working if they use http://127.0.0.1:14063.

Updating

  1. If you set up the restart script, comment out its two lines in your crontab (EDITOR=nano crontab -e) so it doesn't restart Mylar mid-update.

  2. Stop Mylar: pkill -fx "/home/user/mylar3/venv/bin/python /home/user/mylar3/Mylar.py --datadir /home/user/.config/Mylar --nolaunch"

  3. Download the latest version and update its requirements: cd ~/mylar3 && git pull ~/mylar3/venv/bin/python -m pip install -r ~/mylar3/requirements.txt

  4. Start Mylar again with the command from step 6 of Installation, and uncomment the crontab lines. Your settings and database in ~/.config/Mylar are kept. Check the release notes before updating.

Upgrading from the previous version of this article

The previous instructions used a shared virtualenv in ~/virtualenv and kept Mylar's settings and database inside ~/mylar3. Moving them to ~/.config/Mylar keeps them separate from the program files.

  1. If you set up automatic restarts, remove the old mylar_restart.cron lines from your crontab (EDITOR=nano crontab -e).

  2. Stop Mylar: pkill -f mylar3/Mylar.py

  3. Move your settings, database, cover cache, logs and backups, and update Mylar: mkdir -p ~/.config/Mylar cd ~/mylar3 && mv config.ini mylar.db cache logs backup ~/.config/Mylar/ chmod 600 ~/.config/Mylar/config.ini git pull

    If mv says one of these doesn't exist, that's fine; move the others.

  4. Repeat step 3 of Installation to create Mylar's own virtual environment.

  5. Check the port and login settings: grep -E '^(http_port|authentication|http_username)' ~/.config/Mylar/config.ini

    The new start command no longer sets the port with -p, so http_port must be the port you use, not 8090. If it isn't, change it with nano ~/.config/Mylar/config.ini. If authentication is 0 or http_username is empty, anyone can open your Mylar: add the lines from step 5 of Installation under [Interface] before continuing.

  6. Start Mylar with the command from step 6 of Installation, and log in as before.

  7. If you want automatic restarts, follow Automatically Restart from the start. The old script doesn't match the new command, and would start a second copy of Mylar. If nothing else on your slot uses ~/virtualenv, you can delete it with rm -r ~/virtualenv.

Uninstalling

  1. If you set up automatic restarts, remove the two mylar_restart.cron lines from your crontab (EDITOR=nano crontab -e).

  2. Stop Mylar and delete its files: pkill -fx "/home/user/mylar3/venv/bin/python /home/user/mylar3/Mylar.py --datadir /home/user/.config/Mylar --nolaunch" rm -rf ~/mylar3 ~/.config/Mylar rm -f ~/mylar_restart.cron

  3. If you set up a Managed Link, delete it from the Manage Links page. Your comic library in ~/files/Comics is left in place; delete it separately if you no longer need it.

Troubleshooting

  • Mylar exits immediately complaining that the port is in use: another program is using 14063. Pick a different port for http_port in ~/.config/Mylar/config.ini and start Mylar again. Don't use the default 8090.
  • ModuleNotFoundError: No module named ...: the requirements aren't installed in Mylar's virtual environment, or Mylar was started with the system python3. Repeat step 3 of Installation and always start Mylar with ~/mylar3/venv/bin/python.
  • The page doesn't load at http://server.whatbox.ca:14063: check http_host in config.ini. It must be 0.0.0.0 for direct access; 127.0.0.1 only allows the Managed Link.
  • Forgot your Mylar password: stop Mylar, set a new http_password under [Interface] in ~/.config/Mylar/config.ini, and start Mylar again.
  • Two copies of Mylar are running, or the restart script never starts it: the command in mylar_restart.cron must match the command you start Mylar with exactly. Stop both with pkill -f mylar3/Mylar.py, fix the script, and start Mylar once.
  • Output does not look like a hash, not using it in the log: harmless. Mylar logs this on every start when it's installed from git.