If you want to link right to this information, please link to http://ipod.mauricewalton.com just in case the hosting changes, thanks.

DVB/Freeview Radio Recording Utilities - Windows & Linux

These scripts etc. were developed for my own use, they are aimed at recording from Radio stations on DVB/Radio for use with iTunes/iPod (although it would be rather simple to adapt them for video use). They are reasonably well commented and you'll need to look at them to see how they are used and what they depend on. The information needed was gathered from various sources including the MythTV wiki and the Ubuntu forums, hopefully the code here will act as a starting point for things you want to do...

Please read the scripts/code for for information, really, most of it is explained there... You will almost cerainly need to change them, even if only to suit the directories you want to use.

If you are looking for video support, try myth2ipod - I've not tried it myself but it looks good...

Windows Hauppauge Scheduler DVB/Freeview Radio Recording to iTunes / iPod (scripted using Groovy, JavaScript, and a Windows Batch file)

The Hauppauge scheduler software is a bit basic, but does the job and produces mpeg file name like this: programme001.mpg. Although these files play OK in iTunes, they will not play on the iPod and iTunes cannot convert them. However, dbPowerAmp (www.dbpoweramp.com) can convert them. The good news is that dbPowerAmp and iTunes both have a programmable interface. So it was possible to write code to automate the conversion of the mpg files into Apple Lossless or AAC for playing on the iPod and to automate importing the converted files into iTunes. As I wanted an excuse to use Groovy (groovy.codehaus.org), that's what I used for most of it.

The result was HauppeTunes.groovy which will also set the tags to sensible values given the information available. See the source for what you need to get this going, you'd just use it like this (depending on how you have your system set up):

HauppeTunes.groovy L:\MyVideos C:\temp /aac

The script processes one file at a time, in date order, moving the file across, converting it, setting the tags it can, then importing it into iTunes and finally deleting the file, when the files are all done it triggers a iPod synchronisation. I had the Hauppauge scheduler running on an old laptop, and iTunes running on my desktop - so this script suited me quite well, keeping the laptop clear of old recording as they were moved into iTunes.

It seems a bit wierd using Groovy and a batch file and javascript for the iTunes imports but it seemed to be the only way I could find that made sure that the iTunes imports happened synchronously and so be sure the import had completed before moving on and deleting the file I guess this is something to do with call-backs not being supported by the Groovy com code. I like my files in iTunes to be in date order so I don't need to manually sort them which is why I do them one at a time.

MythTV DVB/Freeview Radio Recording and iTunes / iPod (scripted using bash with a dash of perl)

MythTV is great, really great. It took a while to figure out how I could use the DVB radio recordings on my iPod, an answer is to use those fantastic tools mplayer and faac:

Convert the MythTv recording to a wav / PCM file:

mplayer -quiet -vc null -vo null -ao pcm:fast:file="/tmp/$FILE.wav" "$DIR/$FILE"

Convert the wav/PCM file to m4a

faac -q 200 -o "/tmp/$NEWFILENAME" -w "/tmp/$FILE.wav"

The bash script mythradiopodcast wraps these commands into a script that MythTV can call as a user job when the recording has finished. The script will also update a Podcast RSS feed file using Java (see the next section), but you can comment that out. The script will also complete the tags for you, see the comments in the script for details - it does not use the MythTV database at all, but will attempt to use the title, subtitle and description fields to work out the series title (used as the album name), the episode (used for the track name), while the dash of perl is used to try and determine which episode of however many the recording is (used for track x of y) as I couldn't figure out the bash regexp required (it was easier for me to figure out how to do it in perl even though I'd never really used it before, the perl is embedded in the bash script all on one line (snigger)). The script will also try and put in album art using file names matching the channel number, see the script for details.

The MythTV Ubuntu Installation guide was pretty helpful in getting MythTV up and running in the first place.

To do

Figure out how to do the audio conversion in a single step rather than via a temporary file (if possible)

Work out how to do the regular expression in bash, or convert the entire script into perl or groovy

MythTV DVB/Freeview Radio Recording and Podcasting (Using bash, a touch of perl, and Java)

It's pretty simple to make a Podcast feed for iTunes, you just need to maintain an XML file (on a web server) and point iTunes at it through Advanced -> Subscribe to Podcast...

The bash script mythradiopodcast (see above) will convert MythTV recordings into an iPod friendly format (actually it just takes the audio from the MythTV recordings) - while Java is used for updating the XML. Source: MythPodcastMaker.java, or a pre-compiled version: MythPodcastMaker.class

The script expects the XML file and the audio recordings to be in the same place.

To do

The java can trim the XML file to keep x entries before adding the new entry - this should really also delete the associated audio file, but as I don't really use this script I've not implemented this feature (yet).

Automatic Importing of files into iTunes in date order (using Groovy, JavaScript, and a Windows Batch file)

Actually, after all the messing around with Podcasts etc., I decided I didn't like using them for my recordings as the files do not download in date order, but start with the most recent - which means either having to sort the tracks by hand afterwards in the play list or manually getting each file in turn - I want I can leave to run, or even execute with Windows Scheduler. So, here is another Groovy script (which does not depend on MythTV, despite its name). Mything.groovy just takes a source directory (i.e. a shared directory) and imports the m4a files found into iTunes one by one in date order, deleting each file after being imported, finally triggering an iPod synchronise.

A Now Playing Groovy Script (using Groovy with embedded JavaScript)

nowplaying.groovy just gets whats now playing from iTunes and dumps the result in a text file - suitable for for an email signature in Firefox, for example - the JavaScript is embedded so needs no other files.

All the files

Where needed, these files expect to be in the same directory as each other.

addFileToiTunes.bat - Windows batch script
addFileToiTunes.js - JavaScript
HauppeTunes.groovy - Groovy script
Mything.groovy - Groovy script
mythradiopodcast - Bash script
MythPodcastMaker.class - Java binary
MythPodcastMaker.java Java source
nowplaying.groovy - Groovy script
mythpodcast.xml - XML

Here are the parameters MythTV can pass to user jobs

These took me a little while to find...

%DIR% - the directory component of the recording's filename
%FILE% - the filename component of the recording's filename
%TITLE% - the title of the recording (e.g., name of the series)
%SUBTITLE% - the subtitle of the recording (e.g., name of the episode)
%DESCRIPTION% - description text for the recording (from guide data)
%HOSTNAME% - the backend making the recording
%CATEGORY% - the category of the recording (from guide data)
%RECGROUP% - the recording group
%CHANID% - the MythTV channel ID making the recording
%STARTTIME% - the recording start time (YYYYMMDDhhmmss)
%ENDTIME% - the recording end time (YYYYMMDDhhmmss)
%STARTTIMEISO% - the recording start time in ISO 8601 format (YYYY-MM-DDTHH:MM:SS)
%ENDTIMEISO% - the recording end time in ISO 8601 format
%PROGSTART% - the recording's start time (from guide data; YYYYMMDDhhmmss)
%PROGEND% - the recording's end time (from guide data)
%PROGSTARTISO%, %PROGENDISO% - the recording's start and end time in ISO 8601 format.

By the way, I'm using Ubuntu 6.10 Edgy Eft, MythTV 0.20, Sun Java 5, and Windows XP Professional and these are my first real attempts at using Groovy, perl, JavaScript on windows and bash.

I make no promises as to their suitability or safety, you have my permission to use the code the code for legal puprposes only (for example I'm pretty sure you cannot just start providing podcasts of the BBC's copyrighted material!) If you use anything here, please credit me with a link to www.mauricewalton.com

Maurice Walton, 04 January 2007

You can post comments about the stuff on this page here: mrmozza.wordpress.com/ipod-stuff/