Cheap podcast download using cmd.exe and wget
Par Olivier Mengué le jeudi 22 février 2007, 23:39 - Code - Lien permanent
Why use huge and intrusive software such as iTunes when a small script is just enough?
I own a NDEO Equinox² OGG/MP3/FM player/recorder which appears in the PC as a simple 512 Mb flash drive. Besides listening to music and radio it is very convenient to move files to/from work and it recharge itself from the USB. It works on any operating system which support USB storage without a special driver and help to stay away from DRM.
I'm also using the storage feature for scripts directly useful for the main usage of this particular flash drive: retrieving podcasts. I have installed GNU wget on all my Windows PCs (this is an invaluable tool that is particularly useful to download big files (see --continue
and --limit-rate
options) and for mirroring of web sites) so with the following 10 lines cmd.exe script I can download the latest Radio France podcats of the broadcast I missed.
Here is the generic Windows script for any Radio France MP3:
@echo off setlocal :: Le numero de podcast est soit sur la ligne de commande :: soit dans le nom de ce script get-<numero>.cmd if not "%1"=="" (set n=%1) else ( for /F "delims=-_ tokens=2" %%i in ("%~n0") do set n=%%i ) set rss=rss_%n%.xml wget -O %rss% http://radiofrance-podcast.net/podcast/%rss% || goto :EOF for /F "tokens=2" %%f in ('findstr "enclosure" %rss%') do set URL=%%f set URL=%URL:~5,-1% echo %URL% wget -c %URL% && del %rss%
It fetches the RSS file, extracts the URL of the MP3 file and downloads it. The podcast number must be either given file as a command line argument or in the name of the file itself. For example to retrieve "France Info - Chronique Jeux Vidéo, just save the script as radiofrance-18963.cmd
. Run it today and it will download 18963-18.02.2007-ITEMA_20059064-0.mp3
.
Note: I you are behind an HTTP proxy, you have to set the http{,s}_proxy
environment variables. For example:
set http_proxy=http://myproxy:3128 set https_proxy=http://myproxy:3128
You can define them once for all in the Windows Control Panel.