[[ coldCLOUD ]]

2012.06 plPodder

A simple command-line podcatcher.

Description

plPodder derives from BashPodder, but it's written entirely in perl and features additional command-line options.

It simply reads a list of podcast URL's from a file, retrieves the individual XML feeds, and downloads newly posted files of these feeds.

Prerequisites

The following perl modules are necessary for running plPodder,

  • GetOpt::Long
  • Pod::Usage
  • File::Basename
  • File::Path
  • XML::Simple
  • LWP::Simple

Please note, since perl use UTF-8 encoding internally. Running it on Windows, non-US ASCII characters in created directories / files might not show up properly due to encoding mismatch.

Usage

Command-line options,

plPodder FILE [OPTIONS]

Here FILE is the path to a file containing a list of podcasts URL's - one per line.

The available OPTIONS are,

--help|-?                 the help menu
--verbose|-v              make the script be verbose (0 is silent, 4 is most). Default: 0.
--dirstruct|--ds|-d       the directory structure to use: date, title or author/title. Default: author/title.
--fs|-f                   the file system to be expected: ext, ext2, ext3, ext4, fat16, fat32 or ntfs. Default: ext.
--downloaddir|--dd|-t     the directory where to put the downloaded files. Default: "directory of podcast list file".
--dryrun|--dr|-n          make the script do a dry run - i.e. do nothing. Default: off.
--mapfile|--mf|-m         the path to a file containing some directory mappings. Default: none.
--getonly|--get|--dl|-g   the maximum number of URLs from each podcast to download (0 means all). Default: 0.
--verify                  verify the downloaded file size against the size posted in feed. Default: off.

downloaddir

Specify the directory in which to place the podcast directories and downloaded podcast files.

mapfile

A file containing - per line - one perl regular expression (REGEXP) and one destination directory name separated by a TAB.

If the regexp is found in a podcast URL, all files download from this podcast feed will be placed under a directory name so - i.e.,

downloaddir
  |- dest. dir. name 1
    |- (all files from URLs matching regexp 1)
    ...
  |- dest. dir. name 2
    |- (all files from URLs matching regexp 2)
    ...
  ...

An example, having this mapping file,

video.podcast.com      Video
audio.podcast.com      Audio

places all files downloaded from video.podcast.com into the subfolder Video, whereas all files from audio.podcast.com goes into the Audio subfolder.

dirstruct

The directory structure for storing downloaded podcast files. It may name the directories according to the run-time date, podcast title, or podcast author/title.

We may have directory structures like so,

downloaddir
  |- date 1
    |- files
  |- date 2
    |- files
  ...

or

downloaddir
  |- title 1
    |- files
  |- title 2
    |- files
  ...

or

downloaddir
  |- author 1
    |- title 1
      |- files
    |- title 2
      |- files
  |- author 2
  ...

Please note, using a mapping file (–mapfile) precedes the directory structure option - i.e. the mapping directories are added before the directory structures.

fs

Depending on the local filesystem it may be convenient to remove illegal characters from the directory and file names. Setting this option removes these illegal characters depending on the given filesystem.

getonly

The maximum number of files to download from a podcast feed at any given time.

verify

Verify the downloaded file against the size reported by the podcast feed. If the downloaded file is less the 20 % from that value it's verified, otherwise plPodder will delete it and try to download it again next time run. It will retry 3 times before ignoring the file completely.

Download

Click link below to download.

Installation on a QNAP NAS

The preparation for running plPodder on a QNAP NAS is pretty straightforward.

IPKG

First, use the Application ServersQPKG center in the admin web interface to install the Optware IPKG package management system.

IPKG is a command-line package management system so you'll need to connect to the QNAP NAS via SSH.

SSH

Second, connect to the QNAP NAS via SSH and log in as admin.

If you're on Windows, consider using PuTTY.

Please note, SSH must be enabled - see Network ServicesTelnet / SSH in the admin web interface.

Perl and modules

Install perl and necessary modules using the IPKG utility,

ipkg update
ipkg install perl perl-xml-parser perl-xml-dom expat perl-libwww

where perl-xml-parser, expat, and perl-xml-dom are required by XML::Simple, and perl-libwww delivers LWP::Simple.

Now, install the XML::Simple module using the perl CPAN module,

ipkg install ncftp lynx make gcc
perl -MCPAN -e shell

here ncftp, lynx, make, and gcc are used by the CPAN module - although not strictly necessary.

Within the CPAN module install XML::Simple,

cpan[1]> install XML::Simple

The rest of the required modules GetOpt::Long, Pod::Usage, File::Basename, and File::Path are all included in the IPKG perl package by default.

plPodder and crontab

Transfer plPodder to QNAP NAS - say, to folder,

/opt/bin/

and add - say - the following line,

45 * * * * /opt/bin/plPodder PATH_TO/podcast_feeds.cnf

to the permanent crontab file,

/etc/config/crontab

and restart the server.

This executes the given plPodder command 45 minutes past every hour.

Test System

This script was tested on a QNAP TS-219P, firmware version 3.6.1 build 0302T, IPKG version 0.99.163, and perl version 5.10.0-6.