Skip to main content

How to Install, Configure and Run Flexget

Introduction

FlexGet is a multi-purpose automation tool for content like torrents, NZBS, podcasts, comics, series, movies, etc and is able to handle different kinds of sources like RSS feeds, HTML pages and CSV files.


Installation of Flexget via python's virtual environment

Creating a virtual environment

  • First, login to your seedbox's SSH
  • Create a python virtual environment by running the command below
    • This creates a folder named flexget and it includes the prerequisites needed to run python apps locally.
    • This is much recommended because it is isolated from the rest of the server and can be easily deleted and recreated if needed.
python3 -m venv ~/flexget/

Installation

  • To install, navigate to your created folder by doing
cd flexget
  • Then, install flexget by running the following command
"$HOME"/flexget/bin/pip3 install flexget
  • Then make a symbolic link of the flexget binary by running the following command.
    • This allows you to call flexget whenever you are in your SSH
ln -s ~/flexget/bin/flexget ~/bin/flexget

Configuring Flexget

  • Here, we will now create your first flexget YAML. Start by creating flexget's config folder by running the following command
mkdir -p ~/.config/flexget
  • Navigate to ityour with created folder by doing
cd
.config/flexget
  • Open up your fave text editor with nano config.yml

In this part, depending on what you want to achieve your configuration may vary but take note that:

  • Flexget config uses YAML. Indentation and spacing is critical so take care when writing your config.
  • YAML uses spaces, not tabs.

For this example, I'll be configuring flexget to monitor RSS feeds every minute and filters out the results using regex I set. Those that are accepted in my regex will be fed directly to deluge for it to download. The config is shown below.

# Example YAML Config

tasks:
  test-1:
    rss:
      url: https://rss.to/any/f4lt3r-h4h4
      all_entries: no
    regexp:
      accept:
        - .*1080p.*
    deluge:
      host: 127.0.0.1
      port: 11123
      username: xan
      password: somepassword
      label: flexget
# YAML config with explanation

tasks: # A flexget config's main component are tasks, so we start here.
  test-1: # This is the first task. Here, we name our first task "test-1"
 
# Now, we will now add plugins. There are three main types of plugins we normally want in a task in order: an input, a  filter, and an output.
 
    rss: # This is an example of an input plugin, the first one to run in a task. This tells flexget where do you want it to look for things. In this example, we tell to look into rss feeds.
      url: https://rss.to/any/f4lt3r-h4h4
      all_entries: no # This entry tells flexget to have each entry only created on the first run it is seen.
 
    regexp: # This is an example of a filter plugin. This tells flexget which of the entries the input plugin has that you want. Here, we're using the regexp plugin to filter out entries that you want using regex.
      accept:
        - .*1080p.* # Here, we tell flexget to accept all torrents with the word 1080p in it.
 
# TL;DR regex I used is .*, which matches any characters, including line breaks. I added it in the start and the end of 1080p.
# You may refer to https://regexr.com/ to help you learn and build your own regex.
 
    deluge: # This is an output plugin. This is to tell flexget what do with those things you want. Here, I want to use Deluge as my torrent client. Before I run this tho, I need to install another instance of deluge for flexget by running pip3 install --user deluge-client. You'll only need this to communicate to your actual Deluge installation (The one you installed via UCP). Your preferred torrent client's setup may vary so you may look up to flexget's wiki for that.
      host: 127.0.0.1
      port: 11123
      username: xan
      password: somepassword
      label: flexget

After that, save your work with CTRL + O, press ENTER then CTRL + X.

To check if you config is correctly formatted and configured, you may have to do the following commands:

  • flexget check to check the config file for any errors
  • flexget --test execute to test run your configuration.

In my example, when you run it the first time, it may grab and download multiple torrents which may affect your ratio. To save the headache:

1. Remove the output plugins from your config
2. Run flexget execute
3. After it finishes put back the output plugins.

This will save the entries accepted so it won't download again in the future.

You may refer to https://flexget.com/Configuration for more information about making your own config as well as https://flexget.com/Cookbook for some of the basic automation tasks that you can do with Flexget.


Running Flexget

Now, depending on your config you can either run it using cron or flexget's daemon mode.

Cron

  • Type in your SSH window: which flexget. Take note of the output. This is the absolute path of flexget. Here, the absolute path is /homexx/xxx/bin/flexget
usbdocs@lw976:~$ which flexget
/home19/usbdocs/bin/flexget
usbdocs@lw976:~$ 
  • Then type crontab -e. If it's your first time running this command, there would be an option asking for your text editor. Select the editor you want but I would suggest selecting 1

image2019-5-3_15-16-12[1].png

  • Since I want it to run every minute, I set it as * * * * * then the absolute path of flexget, which is /homexx/xxx/.local/bin/flexget. Then the arguments of flexget which is  --cron execute. If we put it together, we get * * * * * /homexx/xxx/.local/bin/flexget --cron execute

image2019-5-3_15-36-41[1].png

You may refer to https://crontab.guru/ which is an quick and simple editor for cron schedule expressions.

  • If you don't want cron to message you whenever there's an error in flexget (which happens quite alot) and will flood your SSH inbox (accessible by typing mail in ssh), append > /dev/null 2>&1 right after execute

image2019-5-3_15-37-24[1].png

  • Save your work with CTRL + O, press ENTER then CTRL + X

Systemd/Daemon mode

For more information, please refer to https://flexget.com/Plugins/Daemon/scheduler. For running your own systemd services, refer to How to run your own services with systemd

  • Open up your flexget config and add the scheduler plugin before tasks
#YAML config with Scheduler Plugin

schedules:
  - tasks: [list, of, tasks]
    schedule:
      minute: X
      hour: X
      day: X
      day_of_week: X
      week: X
      month: X
      year: X
 
tasks:
  test-1:
    rss:
      url: https://rss.to/any/f4lt3r-h4h4
      all_entries: no
    regexp:
      accept:
        - .*1080p.*
    deluge:
      host: 127.0.0.1
      port: 11123
      username: xan
      password: somepassword
      label: flexget
  • Say, I want to run test-1 at 22:05, 22:45, 23:05, 23:45 everyday and test-2 every minute, you'll set it as it is below.
    • Take note that the scheduler plugin also supports cron expressions.
schedules:
  - tasks: [test-1]
    schedule:
      minute: 5,45
      hour: 22,23
  - tasks: [test-2]
    interval:
      minute: 1
 
tasks:
  test-1:
    rss:
      url: https://rss.to/any/f4lt3r-h4h4
      all_entries: no
    regexp:
      accept:
        - .*1080p.*
    deluge:
      host: 127.0.0.1
      port: 11123
      username: xan
      password: somepassword
      label: flexget
 
  test-2:
    rss:
      url: https://rss.to/any/s4h3rz-d1cz
      all_entries: no
    regexp:
      accept:
        - .*2160p.*
    deluge:
      host: 127.0.0.1
      port: 11123
      username: xan
      password: somepassword
      label: flexget
  • Save your work with CTRL + O, press ENTER then CTRL + X
  • Then navigate to /homexx/xxxxx/.config/systemd/user/ by typing cd /homexx/xxxxx/.config/systemd/user/
  • Create a service file (nano flexget-daemon.service) and add the following:
[Unit]
Description=Flexget Daemon
After=network.target
 
[Service]
Type=simple
ExecStart=/homexx/xxxxx/.local/bin/flexget daemon start
ExecStop=/homexx/xxxxx/.local/bin/flexget daemon stop
ExecReload=/homexx/xxxxx/.local/bin/flexget daemon reload
 
[Install]
WantedBy=default.target
  • Save your work with CTRL + O, press ENTER then CTRL + X
  • Run systemctl --user daemon-reload
  • Run systemctl --user enable --now flexget-daemon.service to immediately start the daemon and to automatically restart whenever the daemon crashed or if there's a server restart,
  • To check if the daemon is running, run flexget daemon status

image2019-5-3_16-29-0[1].png


Upgrading Flexget

  • To upgrade flexget, just run the following command:
"$HOME"/flexget/bin/pip3 install flexget --upgrade

Removing Flexget

  • To remove flexget,