Automating downloads with FlexGet

Media Miner

Article from Issue 181/2015

Take the strain out of downloading content from the Internet with FlexGet. Thanks to plugins, you can customize the tool to meet your requirements.

Your *nix operating system comes with a large selection of tools (e.g., cron) for handling recurring tasks, such as launching scripts at specific times; however, a number of other specialist tools can help the user in other areas as well. The FlexGet [1] Python tool specializes in automating Torrent, Usenet, podcast, comics, movie, and series downloads. To do so, it relies on RSS feeds [2], HTML pages, and CSV file sources. A graphical user interface [3] is currently on the development roadmap, but the current offering is still fairly rudimentary.

FlexGet gets much of its functionality from plugins [4]. The software tool initially requires some fairly complex configuration work, but once you have understood the principle and automated various applications, it will save you a huge amount of time. As an example, I show you how I can download episodes of a series from the German ZDF Mediathek site.


The first step is to install FlexGet. It is a good idea to type python -V upfront to make sure you have at least Python version 2.6 or 2.7 on your system. To set up FlexGet, you can then use the Python Pip tool, which you might also need to install (Listing 1).

Listing 1

Installing Pip and FlexGet


A call to flexget -V lets you check that the installation was successful and the program is up to date. In my case, the output is 1.2.324 You are on the latest release. The

pip install --upgrade flexget

command installs any updates [5].


To create a configuration file, use the following sequence of commands:

$ cd ~/.config
$ mkdir - p flexget
$ cd flexget
$ touch config.yml

The .yml extension tells you that FlexGet uses configuration files in the YAML format [6]. YAML is a simplified markup language that has been implemented for the C, C++, JavaScript, ActionScript, Perl, PHP, Java, and Ruby programming languages; the .NET platform; and, most importantly here, for Python.

The formatting features of the configuration for FlexGet are colons and indents. Indents in YAML are always exactly two spaces wide and define the relationship between the entries. The use of tabs is prohibited. As a general rule, you need to pay very close attention to the correct syntax when creating the control file because FlexGet forgives virtually no mistakes (Figure 1).

Figure 1: Even when faced with marginal syntax errors, FlexGet will refuse to cooperate.

The starting point of any configuration file is a task, which defines both the name and the plugins it contains. The three types of tasks are as follows:

  • Input defines where FlexGet looks for content.
  • Filter determines precisely which content you want from this location.
  • Output defines where the software stores this content [7].

A simple configuration file with explanatory comments is shown in Listing 2. A task in Listing 3 downloads the "Linux Action Show" podcast. The command

flexget --test execute

runs the desired action without downloading for test purposes, which means you can check the configuration file for any errors up front. The

flexget execute

command then starts the download (Figure 2). For a deeper understanding, I can recommend the excellent FlexGet documentation.

Listing 2

YAML Configuration File


Listing 3

Podcast Download


Figure 2: When working through its assigned tasks, FlexGet gives you useful feedback.

With the individual plugins, you can customize FlexGet's behavior in a granular way to suit your own needs. The parameter that provides a plugin will be listed on the wiki page for the plugin in question. Once you have familiarized yourself with the available plugins, you will have a wide range of options for fine tuning. For example, the Series [8] filter gives you many control options for retrieving precisely what you want. It makes sense to extend and successively test the configuration file gradually.

Time-Controlled with Cron

After taking care of what, you can now move on to when; that is, how often you want FlexGet to look for new entries. A weekly search is enough for the TV series in this example. The use of a Cron job is the perfect way to avoid having to trigger the program manually every week.

Start by typing which flexget to determine the path to the executable part of FlexGet: On Debian, the path is /usr/local/bin/. Now type crontab -e to open the input mask for a Cron job. If you have not yet defined an editor for the system, you will want to select Nano and type the following line as a test:

@hourly /usr/local/bin/  flexget --cron execute

After saving, you will see a confirmation that you have created a new Cron job.

By testing in this way, you can check FlexGet logfile whether the Cron job ran; the log resides in the same directory that holds the configuration file. If you want multiple tasks to run at different times, you have more clear-cut ways of managing the configuration.

Buy this article as PDF

Express-Checkout as PDF
Price $2.95
(incl. VAT)

Buy Linux Magazine

Get it on Google Play

US / Canada

Get it on Google Play

UK / Australia

Related content

  • Workspace: DokuWiki Plugins

    DokuWiki is a useful wiki system already, but you can take its functionality to a whole new level using some of the available plugins.

  • Snort Helpers

    Snort is the de facto standard for open source network intrusion detection. The developer community has kept a fairly low profile for a couple of years, but extensions like Snorby, OpenFPC, and Pulled Pork have given the old hog a new lease on life.

  • Grsecurity

    Security-conscious people dig a deep moat with crocodiles around their homes, hide their furniture in back rooms, and only let visitors into the bathroom if they know the secret password. Grsecurity follows a similarly extreme principle.

  • pstoedit

    pstoedit lets you convert Postscript and PDF files to vector-based image formats.

  • Building a Munin Plugin

    Munin collects information and plots parameters of your choice automatically and with minimal configuration. But if you can't find a plugin that captures the data you want to graph, you might have to roll your own.

comments powered by Disqus

Direct Download

Read full article as PDF:

Price $2.95