1. Core Functionality

This consists of functionality to grab episodes from NPR Fresh Air, NPR Wait Wait..Don’t Tell Me, and This American Life.

1.1. CONFIGURATION

The command line tool nprconfig shows the following core functionality configuration settings.

  • the NPR API key.

  • The default download directory for NPR Fresh Air episodes.

  • The default download directory for NPR Wait Wait episodes.

It has two modes of operation: show displays nprstuff core functionality settings; and set sets any or all of the three configuration settings. The top level help is,

usage: nprconfig [-h] [--level {DEBUG,ERROR,INFO,NONE}] {show,set} ...

positional arguments:
  {show,set}            Choose one of these options: (show) shows the NPR core functionality settings. (set) sets the default download directory for
                        NPR Fresh Air and NPR Wait Wait episodes.
    show                Just show the NPR core functionality settings.
    set                 Set the default download directories for NPR Fresh Air and NPR Wait Wait episodes.

optional arguments:
  -h, --help            show this help message and exit
  --level {DEBUG,ERROR,INFO,NONE}
                        choose the debug level for. Default is NONE.

You can show the core functionality settings by running nprconfig show. In my case it shows this. I have blocked out my NPR API key.

NPR CONFIGURATION
----------------------  -------------------------------------
NPR API KEY             XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
NPR Fresh Air download  /mnt/media/freshair
NPR Wait Wait download  /mnt/media/waitwait
----------------------  -------------------------------------

Here is the help when running nprconfig set -h,

usage: nprconfig set [-h] [--freshair FRESHAIR] [--waitwait WAITWAIT] [--api API]

optional arguments:
  -h, --help           show this help message and exit
  --freshair FRESHAIR  Sets the default download directory for NPR Fresh Air episodes.
  --waitwait WAITWAIT  Sets the default download directory for NPR Wait Wait episodes.
  --api API            Sets the NPR API key.

1.2. NPR Fresh Air

These four executables handle NPR Fresh Air downloads: freshair, freshair_crontab, freshair_fix_crontab, and freshair_by_year.

1.2.1. freshair

freshair is the main executable that downloads NPR Fresh Air episodes, converts them to M4A format, and then applies correct metadata. The help screen for this command line tool is here,

usage: freshair [-h] [--dirname DIRNAME] [-d DATE] [--mp3exist] [-D] [-L {DEBUG,ERROR,INFO,NONE}] [-r]

optional arguments:
  -h, --help            show this help message and exit
  --dirname DIRNAME     Name of the directory to store the file. Default is /mnt/media/freshair.
  -d DATE, --date DATE  The date, in the form of "January 1, 2014." The default is today's date, January 05, 2022.
  --mp3exist            If chosen, then do not download the transitional mp3 files. Use the ones that already exist.
  -D, --debug           If chosen, dump out NPR Freshair webpage as XML.
  -L {DEBUG,ERROR,INFO,NONE}, --level {DEBUG,ERROR,INFO,NONE}
                        choose the debug level for downloading NPR Fresh Air episodes or their XML representation of episode info. Can be one of ['DEBUG', 'ERROR', 'INFO', 'NONE'].
                        Default is NONE.
  -r, --relax           If chosen, then do NOT do a date check validation of NPR URL articles.

1.2.2. freshair_crontab

freshair_crontab downloads an NPR Fresh Air episode on a given weekday. It should be called by a cron job or a systemd service that runs every weekday.

1.2.3. freshair_fix_crontab

freshair_fix_crontab tries to re-download NPR Fresh Air episodes that may be incomplete – defined as shorter than 30 minutes – and which are 90 days or older. This executable searches through the library of all NPR Fresh Air episodes, and tries to re-download older, possibly incomplete episodes.

1.2.4. freshair_by_year

freshair_by_year downloads all the NPR Fresh Air episodes in a given year. The help screen for this command line tool is here,

usage: freshair_by_year [-h] [--year YEAR] [--inputdir INPUTDIR] [--quiet] [--coverage] [--audit] [--level {DEBUG,ERROR,INFO,NONE}]

optional arguments:
  -h, --help            show this help message and exit
  --year YEAR           Year in which to write out all Fresh Air episodes. Default is 2020.
  --inputdir INPUTDIR   Directory into which to store the NPR Fresh Air episodes. Default is /mnt/media/freshair.
  --quiet               If chosen, do not print verbose output from the action of this script. By default this is false.
  --coverage            If chosen, just give the list of missing Fresh Air episodes and nothing else.
  --audit               If chosen, do the audit picture here.
  --level {DEBUG,ERROR,INFO,NONE}
                        choose the debug level for downloading NPR Fresh Air episodes or their XML representation of episode info. Can be one of
                        ['DEBUG', 'ERROR', 'INFO', 'NONE']. Default is NONE.

1.3. NPR Wait Wait

These three executables handle NPR Wait Wait downloads: waitwait, waitwait_crontab, and waitwait_by_year.

1.3.1. waitwait

waitwait is the main executable that downloads NPR Wait Wait episodes, converts them to M4A format, and then applies correct metadata. waitwait_realmedia is a Python module that allows one to download NPR Wait Wait episodes older than 2004, which are in RealMedia format. The help screen for this command line tool is here,

usage: waitwait [-h] [--dirname DIRNAME] [--date DATE] [--dump] [--level {DEBUG,ERROR,INFO,NONE}] [--justfix]

optional arguments:
  -h, --help            show this help message and exit
  --dirname DIRNAME     Name of the directory to store the file. Default is /mnt/media/waitwait.
  --date DATE           The date, in the form of "January 1, 2014." The default is last Saturday, August 15, 2020.
  --dump                If chosen, download the NPR XML data sheet for this Wait Wait episode.
  --level {DEBUG,ERROR,INFO,NONE}
                        choose the debug level for downloading NPR Wait Wait episodes or their XML representation of episode info. Can be one of
                        ['DEBUG', 'ERROR', 'INFO', 'NONE']. Default is NONE.
  --justfix             If chosen, just fix the title of an existing NPR Wait Wait episode's file.

1.3.2. waitwait_crontab

waitwait_crontab downloads an NPR Wait Wait episode on a given Saturday. It should be called by a cron job or systemd service that is run every Saturday.

1.3.3. waitwait_by_year

waitwait_by_year downloads all the NPR Wait Wait episodes in a given year. The help screen for this command line tool is here,

usage: waitwait_by_year [-h] [--year YEAR] [--inputdir INPUTDIR] [--quiet] [--level {DEBUG,ERROR,INFO,NONE}]

optional arguments:
  -h, --help            show this help message and exit
  --year YEAR           Year in which to write out all Fresh Air episodes. Default is 2010.
  --inputdir INPUTDIR   Directory into which to store the NPR Wait Wait episodes. Default is /mnt/media/waitwait.
  --quiet               If chosen, do not print verbose output from the action of this script. By default this is false.
  --level {DEBUG,ERROR,INFO,NONE}
                        choose the debug level for downloading NPR Wait Wait episodes or their XML representation of episode info. Can be one of
                        ['DEBUG', 'ERROR', 'INFO', 'NONE']. Default is NONE.

1.4. This American Life

The executable thisamericanlife manually downloads a given episode number of This American Life. The help screen for this command line tool is here,

usage: thisamericanlife [-h] [-e EPISODE] [-d DIRECTORY] [-E EXTRASTUFF] [--noverify] [--dump]
                        [--level {DEBUG,ERROR,INFO,NONE}]

optional arguments:
  -h, --help            show this help message and exit
  -e EPISODE, --episode EPISODE
                        Episode number of This American Life to download. Default is 150.
  -d DIRECTORY, --directory DIRECTORY
                        Directory into which to download This American Life episodes. Default is
                        /mnt/media/thisamericanlife.
  -E EXTRASTUFF, --extra EXTRASTUFF
                        If defined, some extra stuff in the URL to get a This American Life episode.
  --noverify            If chosen, then do not verify the SSL connection.
  --dump                If chosen, just download the TAL episode XML into a file into the specified directory.
  --level {DEBUG,ERROR,INFO,NONE}
                        choose the debug level for downloading NPR Fresh Air episodes or their XML representation
                        of episode info. Can be one of ['DEBUG', 'ERROR', 'INFO', 'NONE']. Default is NONE.

Running with the --dump flag helps the user or myself debug any broken functionality that thisamericanlife experiences.