Total Recorder -> iTunes/iPod on Windows

J

jase

For anyone who may have Total Recorder Pro, iTunes, and Perl on
Windows, I've created tr2itunes.pl that takes a TR job name, a "show
name" (i.e. whatever you want to call your recording), a duration, a
path to save to, and an extension for the file (i.e. mp3) and launches
a TR job, records it to a file name based on the show name and date,
gives it and ID3v2 tag with the show name, and puts it in iTunes in a
playlist with the name of the job as the playlist.

This basically gives you a way to schedule any web broadcast directly
into your iPod.

To use Windows' Scheduled Task functionality with this (I had trouble
using Cygwin cron because it runs as a different user by default and
can't do OLE automation to iTunes), just create a task with something
like the following:

"c:\Program Files\cygwin\bin\perl5.8.2.exe" "c:\Documents and
Settings\Jase\My Documents\bin\tr2itunes.pl" "WBAA AM" "Acoustic Blend"
"01:04:00" "c:\\Documents and Settings\\Jase\\My Documents\\My
Music\\WBAA\\" "mp3"

This assumes your TotalRecorder.exe is in its standard install location
and that you have Perl's Win32::OLE, File::Basename, and MP3::Tag.

Please feel free to use this under the GPL:

#!/usr/bin/perl -w
use strict;

use Win32::OLE;
use File::Basename;
use MP3::Tag;

my $scriptName = basename($0);
my $job = $ARGV[0];
my $show = $ARGV[1];
my $duration = $ARGV[2];
my $path = $ARGV[3];
my $extension = $ARGV[4];

die "usage: $scriptName <jobName> <showName> <duration> <path>
<extension>\n" unless $job && $show && $duration && $path &&
$extension;

my ($second, $minute, $hour, $day, $month, $year, $weekday, $dayOfYear,
$isDST) = localtime time;
$month += 1;
$year += 1900;
my $date = sprintf("%02d-%02d-%04d %02d.%02d.%02d", $month, $day,
$year, $hour, $minute, $second);
my $file = "$path$show-$date.$extension";

print "Recording $show from job \"$job\" to $file\n";
system("/c/Program\\\
Files/HighCriteria/TotalRecorder/TotalRecorder.exe \"$file\"
/Time:$duration /Job:\"$job\"");

print "Tagging $file\n";
my $mp3File = MP3::Tag->new($file);
$mp3File->new_tag("ID3v2");
$mp3File->{ID3v2}->add_frame("TIT2","$show - $month/$day/$year");
$mp3File->{ID3v2}->write_tag;

print "Adding $file to iTunes\n";
my $iTunesApp = new Win32::OLE('iTunes.Application');
$iTunesApp->LibraryPlaylist->AddFile($file);
my $playlist = $iTunesApp->LibrarySource->Playlists->ItemByName($job);
$playlist = $iTunesApp->CreatePlaylist($job) unless $playlist;
$playlist->AddFile($file);
$iTunesApp->UpdateIpod();
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,236
Members
46,822
Latest member
israfaceZa

Latest Threads

Top