Skip to main content

How to Install, Configure and Run Flexget

Introduction

FlexGet is a multi-purpose automation tool for content like torrents, NZBS,NZBs, podcasts, comics, series, movies, etc and is able to handle different kinds of sources like RSS feeds, HTML pages and CSV files. This allows you to integrate and create powerful automation between your downloaders, organizers and your media servers.

This guide shows you the following:

  • Install FlexGet to your seedbox slot
  • Create your first FlexGet configuration
  • Running FlexGet
  • Scheduling your FlexGet tasks
  • Upgrading and Removing FlexGet

Installation of Flexget via python's virtual environment

Creating a virtualPython environment

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 flexgetFlexGet binary by running the following command.
    • This allows you to call flexgetFlexGet whenever you are in your SSH
ln -s ~/flexget/bin/flexget ~/bin/flexget

Configuring Flexget

FlexGet

Creating config.yml

  • Here, we will now create your first flexgetFlexGet YAML. Start by creating flexget'FlexGet's config folder by running the following command
mkdir -p ~/.config/flexget
  • Navigate to your created folder by doing
cd ~/.config/flexget
  • Create a config.yml with the following:following
nano config.yml

Editing 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 flexgetFlexGet 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 flexgetFlexGet 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 flexgetFlexGet 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 flexgetFlexGet to have each entry only created on the first run it is seen.
     
    regexp: # This is an example of a filter plugin. This tells flexgetFlexGet 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 flexgetFlexGet 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 flexgetFlexGet 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 flexgetFlexGet by running "$HOME"/flexget/bin/pip3 install deluge-client && ln -s ~/flexget/bin/deluge-client ~/bin/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'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 --testtest execute 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 tracker ratio. To mitigate this:

1. Remove the output plugins from your config 
2. Run `flexget executeexecute`
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/FlexGet 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'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/username/bin/flexget
usbdocs@lw975:~$ which flexget
/home7/usbdocs/bin/flexget
usbdocs@lw975:~$ 
  • 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

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

You may refer to https://crontab.guru/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 flexgetFlexGet (which happens quite alot) and will flood your SSH inbox (accessible by typing mail in ssh), append > /dev/null 2>&1 right after execute

  • 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/schedulerFlexGet Scheduler. For running your own systemd services, refer to How to run your own services with systemd

  • Open up your flexgetFlexGet config and add the scheduler plugin before tasks
#YAML

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.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/username/.config/systemd/user/ by typing cd /homexx/username/.config/systemd/user/
  • Create a service file (nano flexget-daemon.service) and add the following:
[Unit]
Description=Flexget Daemon

[Service]
Type=simple
ExecStart=/homexx/xxxxx/bin/flexget daemon start
ExecStop=/homexx/xxxxx/bin/flexget daemon stop
ExecReload=/homexx/xxxxx/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,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,FlexGet, just run the following command:
"$HOME"/flexget/bin/pip3 install flexget --upgrade

Removing Flexget

  • To remove flexget,FlexGet, simply delete the flexget folder and your symbolic link.
rm -rfv ~/flexget
rm ~/bin/flexget