Playlist Name Sort Order on iPod G5.5
(tags iPod, iTunes, Ruby, programming)
I took the time to manually figure out the sort order of playlists names on the iPod G5.5. From left to right (with some ASCII values in hexadecimal):
Seems as if the iPod is pulling the ' (quote) and - (dash) higher up, while pushing the + (plus), < (left angle bracket), = (equal sign), > (right angle bracket), and \ (backslash) down. Then numbers and alphabet come later, respectively. Finally, any name prefixed with spaces are ignored, and hiragana comes before katakana, while finally kanji picks up the end. As far as I can tell, smart and manual playlists share the same order, regardless of type.
I used the following script to create the temporary manual playlists. If this looks like a straight copy and paste of the SDK provided script, you'd be pretty close.
# Ruby 1.8 script
require 'win32ole'
iTunesApp = WIN32OLE.new("iTunes.Application")
mainLibrary = iTunesApp.LibraryPlaylist
tracks = mainLibrary.Tracks
def createAllAscii( iTunesApp, foldername, track )
source = iTunesApp.LibrarySource
# if exist, add to that folder, else create
unless (folder = source.Playlists.ItemByName( foldername ))
folder = iTunesApp.CreateFolder( foldername )
end
# need a track so that playlist is synced to iPod
0x20.upto(0x7e) do |chr|
plname = yield chr
# show some status
print "creating playlist '#{plname}'..."
albumPlaylist = folder.CreatePlaylist( plname )
albumPlaylist.AddTrack( track )
puts "done!"
end
end
# any track is fine
atrack = tracks.ItemByName("Stage 4 - Assault! -")
createAllAscii( iTunesApp, "sortTest", atrack )
{ |ch| "#{ch.chr}sorttesting" }
createAllAscii( iTunesApp, "sortTest", atrack )
{ |ch| "a#{ch.chr}sorttesting" }
Now armed with this info, I'm gonna group my "Imported" and "Played", "Rated", "Not Rated", "Year" playlists with some funky symbols at the beginning. Happy joy.
<< Home