Tidy Artist List with OneHitWonders.js


Article Image
Tags:

Added On: 14th Jan 08

Links: [site] [download]

Creates a playlist of all the songs in your library which are the only song for their artist. These so-called One-Hit-Wonder tracks are really annoying when they clog up your iTunes or iPod list of artists. A simple trick is to create the playlist (by running the script) then setting those tracks properties to “Compilation” and choosing “Group Compilations when browsing”. Then they’ll all come up under a single item at the top of the list or artists.

// put your playlist name here
var PlaylistName = "One Hit Wonders";
var iTunesApp = WScript.CreateObject("iTunes.Application");
var mainLibrary = iTunesApp.LibraryPlaylist;
// if you want to use some other playlist as the base to look through, uncomment this next line
// and change the "-All Songs" to the base playlist you want to use.:
//var mainLibrary = iTunesApp.LibrarySource.Playlists.ItemByName("-All Songs");
// --- no need to change anything below this line ---
var tracks = mainLibrary.Tracks;
var numTracks = tracks.Count;
var i;
var artistArray = new Array();
for (i = 1; i < = numTracks; i++)
{
var currTrack = tracks.Item(i);
var artist = currTrack.Artist;
if ((artist != undefined) && (artist != ""))
{
if (artistArray[artist] == undefined)
{
artistArray[artist] = new Array();
}
artistArray[artist].push(currTrack);
}
}
OHWPlaylist = iTunesApp.CreatePlaylist(PlaylistName);
for (var artistNameKey in artistArray)
{
var trackArray = artistArray[artistNameKey];
if (trackArray.length == 1)
{
var currTrack = trackArray[0];
OHWPlaylist.AddTrack(currTrack);
}
}

UnRelated Posts:

This post has been read 464 times.

No Comments

Leave a comment