Total Recorder -> iTunes/iPod on Windows

Discussion in 'Perl Misc' started by jase@dufair.org, Dec 21, 2004.

  1. Guest

    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();
     
    , Dec 21, 2004
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. bob

    data recorder examples?

    bob, Oct 31, 2003, in forum: VHDL
    Replies:
    0
    Views:
    527
  2. jeje
    Replies:
    3
    Views:
    373
    Rolf Magnus
    Jul 18, 2003
  3. Dfenestr8
    Replies:
    2
    Views:
    375
    Sandy Norton
    Jul 4, 2003
  4. Denrael
    Replies:
    3
    Views:
    588
  5. Morlence
    Replies:
    0
    Views:
    1,256
    Morlence
    Nov 2, 2009
Loading...

Share This Page