Skip to main content

Download BBC radio show tracklistings

Project description

A Python script that downloads radio tracklistings from BBC’s website and tags MP3 or M4A audio files or outputs to a text file. Licensed under GPL v3 (see COPYING).

Usage examples

Run bbc_tracklist.py from the command line.

Required arguments are an action: one of tag, text or both and a BBC programme id, the 8 characters that are found at the end of iPlayer URLs such as:http://www.bbc.co.uk/iplayer/episode/<programme id>/<programme name> or programme information URLs such as: http://www.bbc.co.uk/programmes/<programme id>, e.g. b03d0wk8

text will save the tracklisting to a text file, tag will tag an audio file and (unsurprisingly) both will perform both of these actions.

Optional arguments are --directory DIRECTORY and --fileprefix FILEPREFIX. The --fileprefix is the filename prefix: e.g. for some_bbc_audio.mp3, the filename prefix is some_bbc_audio.

If either of these are omitted, output will be to the current path. If no filename is specified, any audio file you want tagging should be named as the pid. Any text file generated without a filename will be called pid.txt.

First, if tag or both actions are chosen, the script tries to tag an M4A file, then an MP3. If it fails to find (or write to) an appropriate audio file, it falls back to creating a text file.

The script generates an output formatted as:

Programme title
Programme first broadcast date

Artist
Title
Record label

***

get_iplayer usage

If downloading a radio programme with get_iplayer, adding an argument of the form --command "python /home/scripts/bbc_tracklist.py action <pid> --directory <dir> --fileprefix <fileprefix>" should result in a text file containing the tracklisting in the same directory as your downloaded audio file where action is text, tag or both.

(Change /home/scripts to point to wherever the script is located.)

In Windows, you may need to quote the placeholders (presumably if there are spaces in them; thanks JackDandy) bbc_tracklist.py <pid> "<dir>" "<fileprefix>"

Installation requirements

  • Tested on Python 2.7.3 on Windows (Windows 7 64-bit) and Linux (Raspbian and Ubuntu 12.04). (I suspect it doesn’t work with Python versions earlier than this due to improvements in Python’s HTMLParser introduced in 2.7.3.)

  • Not compatible with Python 3.4 as yet. This code shouldn’t be hard to port, but beets is not yet Python 3 compatible.

  • Requires beets, requests and lxml.

Install module directly

pip install git+https://github.com/StevenMaude/bbc_radio_tracklisting_downloader.git should install the module and its dependencies. However, lxml may be an issue if you’re on Windows (see below); make sure that’s installed first.

bbc_tracklist should be available as a command. (Tested on Linux only.)

Installing by hand

pip install -r requirements.txt may work for you on Linux.

If you’re on Windows and have pip installed, pip install beets requests should work. lxml requires compiling, so the easiest way is to install it is by downloading the latest installer version for Python 2.7 from PyPI.

Even on Linux, compiling lxml may require more build dependencies. See this discussion for details. Otherwise, there may be a version of lxml in your distribution’s package manager (e.g. python-lxml).

You can then grab a copy of the Python scripts from here or git clone the repository.

Known issue (don’t think there’s an easy fix)

  • Printing tracklisting in Windows doesn’t play nicely with non-ASCII characters; these are ignored. (Printing occurs if directory and fileprefix are invalid.) You can try running cmd /u in a command prompt if you find this an issue (not tested).

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

Built Distribution

File details

Details for the file bbc_radio_tracklisting_downloader-0.0.1.tar.gz.

File metadata

File hashes

Hashes for bbc_radio_tracklisting_downloader-0.0.1.tar.gz
Algorithm Hash digest
SHA256 f3cb33a90407455a6706be808cc71ada0ccc01032fa82f9781cf2ba29ce27a15
MD5 8f3d52a6738ef5b65e0e7183eaf919ff
BLAKE2b-256 99e8962492156fe535d82432c421c90cfff63818a3b03193d023fcc8dd2ffe06

See more details on using hashes here.

File details

Details for the file bbc_radio_tracklisting_downloader-0.0.1-py2-none-any.whl.

File metadata

File hashes

Hashes for bbc_radio_tracklisting_downloader-0.0.1-py2-none-any.whl
Algorithm Hash digest
SHA256 0ca8d2211e31b2cdcaa65a8e836ad3e9622c0ac93134caf4e25cb5577950e3ff
MD5 58c77f7c2c3e6e032be8886cb7a4bce1
BLAKE2b-256 0f8e062ef63b34fc12cd9d543f3dd9f987211b6988b60b6cdd63eb9d2bd2e206

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page