BlogicBlog: View from the trenches

The blog about Java and XML with focus on troubleshooting issues and tools.

Saturday, October 02, 2004

Extending the podcasting loop

Permanent article link

So, you already use iPodder to listen to your ITConversations on the iPod with a 1-click ease.

All is well, except that it is starting to get difficult to remember which shows you already listened to and which ones are still new. You can of course go to iTunes, find the already-listened-to track and manually delete it or move it to the 'archived' section. But that is very much against 1-clickspirit.

It would be very nice to be able to mark from inside the iPod which tracks you are no longer interested in. Except that iPod is a read-only device.

Except that it is not! You can rate a track with 0-5 stars and that information will get synchronized to the iTunes on the next connection.

Introducing ArchiveTrack. Inspired by one of the iPodder impementations, it uses Windows Scripting Host to archive the tracks (in a given genre) using rating value as a trigger.

The script is given here in all entirety. Feel free to modify it or incorporate it into other setups as long as this article is attributed.


/*
Run this with 'cscript ArchiveTracks.js'

The script goes through the songs in sourceGenre and
moves/archives the ones that have ratings under the threshold
into targetGenre.

Usage scenario:
1) Download podcasting content using iPodder (1 - click)
2) Listen to it on your iPod
3) While you are listening, rate the track 1/2 stars (default script threshold)
4) After the next synchronization, run this script with iPod still connected

Version: 1.0b1 (Oct 2, 2004)
Author: Blogic Blogger
License: Use in any way desired, but mention the source and author
*/

try
{
var sourceGenre = 'Speech'; // The genre used by ITConversations
var targetGenre = 'Speech-Archive'; //The genre to collect all the listened content in
var archiveThreshold = 50; // 1 or 2 stars
var progressNoticeRepeatCount = 250;

WScript.Echo('Connecting to iTunes');
var iTunesApp = WScript.CreateObject("iTunes.Application");
var mainLibrary = iTunesApp.LibraryPlaylist;

var tracks = mainLibrary.Tracks;
var songCount = tracks.count;
WScript.Echo('Total Song Count: ' + songCount);

for (i=1; i<=songCount; i++)
{
if ((i%progressNoticeRepeatCount) == 0)
{
WScript.Echo('Checked ' + i + ' items');
};

var aTrack = tracks.Item(i);
if (aTrack.Genre==sourceGenre)
{
if ((aTrack.Rating > 0) && (aTrack.Rating < archiveThreshold))
{
WScript.Echo();
WScript.Echo(' Archiving: ' + aTrack.Name + ' by ' + aTrack.Artist + ' based on rating ' + aTrack.Rating);
WScript.Echo();
aTrack.Genre = targetGenre; //use 'aTrack.Delete();' to delete instead of archiving
}
else
{
WScript.Echo(' Keeping: ' + aTrack.Name + ' by ' + aTrack.Artist + ' based on rating ' + aTrack.Rating);
}
}
};
}
catch (e)
{
WScript.Echo('Problem archiving: ' + e);
};

try
{
WScript.Echo('Requesting iPod update');
iTunesApp.updateIPod();
WScript.Echo('Successful iPod update request');
}
catch (e)
{
WScript.Echo('Problem updating iPod ' + e);
}
WScript.Echo('Done!');


BlogicBlogger Over and Out

2 Comments:

At October 07, 2004 10:54 PM, Blogger scyro said...

why exactly do you want to change the genre for archiving?

Take a look at this for an easy approach with smart playlists.

 
At October 09, 2004 12:52 PM, Blogger charlie said...

Why not just have a Smart Playlist in iTunes which contains all podcasts added in the last week, with a playcount of zero. That way, when you listen to it, it will drop off the list. Much easier.

 

Post a Comment

Links to this post:

Create a Link

<< Home