Automating downloads with FlexGet
Media Miner
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.
Installation
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].
Configuration
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).
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
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
(incl. VAT)
Buy Linux Magazine
Subscribe to our Linux Newsletters
Find Linux and Open Source Jobs
Subscribe to our ADMIN Newsletters
Support Our Work
Linux Magazine content is made possible with support from readers like you. Please consider contributing when you’ve found an article to be beneficial.
News
-
So Long Neofetch and Thanks for the Info
Today is a day that every Linux user who enjoys bragging about their system(s) will mourn, as Neofetch has come to an end.
-
Ubuntu 24.04 Comes with a “Flaw"
If you're thinking you might want to upgrade from your current Ubuntu release to the latest, there's something you might want to consider before doing so.
-
Canonical Releases Ubuntu 24.04
After a brief pause because of the XZ vulnerability, Ubuntu 24.04 is now available for install.
-
Linux Servers Targeted by Akira Ransomware
A group of bad actors who have already extorted $42 million have their sights set on the Linux platform.
-
TUXEDO Computers Unveils Linux Laptop Featuring AMD Ryzen CPU
This latest release is the first laptop to include the new CPU from Ryzen and Linux preinstalled.
-
XZ Gets the All-Clear
The back door xz vulnerability has been officially reverted for Fedora 40 and versions 38 and 39 were never affected.
-
Canonical Collaborates with Qualcomm on New Venture
This new joint effort is geared toward bringing Ubuntu and Ubuntu Core to Qualcomm-powered devices.
-
Kodi 21.0 Open-Source Entertainment Hub Released
After a year of development, the award-winning Kodi cross-platform, media center software is now available with many new additions and improvements.
-
Linux Usage Increases in Two Key Areas
If market share is your thing, you'll be happy to know that Linux is on the rise in two areas that, if they keep climbing, could have serious meaning for Linux's future.
-
Vulnerability Discovered in xz Libraries
An urgent alert for Fedora 40 has been posted and users should pay attention.