iPod timezone

Jaq bought an iPod some time ago, and I noticed at the time Adelaide was missing from the timezone properties. Should report this to Apple.

The Playlist Meme.

From The Tao of Mac, my next 10 tracks randomly from iTunes.

  1. Open up the music player on your computer.
  2. Set it to play your entire music collection.
  3. Hit the “shuffle” command.
  4. Tell us the title of the next ten songs that show up (with their musicians), no matter how embarrassing. That’s right, no skipping that Carpenters tune that will totally destroy your hip credibility. It’s time for total musical honesty. You can put the list in the comment thread, or write it up in your blog or journal and then post a link in the comments.
  5. If you get the same artist twice, you may skip the second (or third, or etc.) occurances. You don?t have to, but since randomness could mean you end up with a list of ten song with five artists, you can if you’d like.
  1. Enchanted Farm / Forbidden Five / Ultra-Lounge, Vol. 11: Organs In Orbit
  2. Tonight (King Britt’s Sexy Mix) / H-Foundation / The Chillout Session Summer Collection 2004
  3. Desafinado / George Michael / Ladies & Gentlemen : The Best Of George Michael
  4. Ocean Beach / Talbot And White / United States Of Mind
  5. Opus 40 / Mercury Rev / Deserter’s Songs
  6. Cruel Summer / Bananarama / Bananarama
  7. The Tower Of Learning / Rufus Wainwright / Poses
  8. Peer Gynt Suite No. 1 op. 46 In der Halle des Bergkönigs / Berlin Philharmonic Orchestra / Karajan Festival
  9. Sunday 8pm / Faithless / Sunday 8pm
  10. Double Violin Concerto in D Minor, BWV 1043: II. Largo ma non tanto / Bach (Composer) / Unknown
  11. Dub Be Good To Me / Beats International / The Mix

Sharing iTunes Songs

I finally got around to downloading the 10.3.4 OS X update, SharePoints, and Xbox Media Centre (XBMC). My aim for some time has been to share my iTunes library to my Xbox, which is connected up to the TV and Stereo in the lounge.

The MacOS X update provided (apparently) updated Samba sharing, but I still couldn’t get XMP (Xbox Media Player - the previous incarnation of XBMC) to connect to the SMB share I had set up, with all of my MP3s on it. SharePoints fixed that - all I had to do was create a publicly available share.

Setting up XBMC was a breeze, and it even has a cool interface! UnleashX is (almost) banished from my system, and XBMC is my main Dash.

Then I discovered that XCMC can play AAC files! So, I started (and have not yet finished) converting all of my MP3s to AAC. And not just converting, but re-importing, at a bitrate of 128 (small file size, but apparently equivalent to 256 in MP3). See this hint for some tips (and my comments).

I also wanted to re-jig how I had set up sharing my iTunes songs between users - I had a couple of links to the relevant files in each user’s ~/Music/iTunes, and all files were located in ~shared/Music (which all of admin can RW, and all of the world can R). I needed to have seperate Library files, so that we can have our own ratings (I hate Abba, and she isn’t that big a fan of Paul Kelly, for instance). So, I knocked up a script that scanned the ~shared/Music folder and compared any files found to the iTunes LIbrary. If they weren’t in it, it added them.

Here we go:

 1set _tracks to “”
 2tell application iTunes
 3    set sel to tracks of playlist 1
 4    set sel to get a reference to selection
 5    repeat with t in sel
 6        set _tracks to _tracks & 
 7 & (location of t as string)
 8    end repeat
 9end tell
10
11tell application Finder
12    set _files to “”
13    set _library to Macintosh HD:Users:Shared:Music
14    set _artists to folders of folder _library
15    repeat with _artist in _artists
16        set _albums to folders of _artist
17        repeat with _album in _albums
18            set temp to files of _album
19            repeat with _file in temp
20                set _files to _files & 
21 & _file
22            end repeat
23        end repeat
24    end repeat
25end tell
26set _missing to “”
27repeat with para in paragraphs of _files
28    set para to para as string
29    if para is not in _tracks then
30        set _missing to _missing & 
31 & para
32    end if
33end repeat
34
35tell application iTunes
36    repeat with para in paragraphs of _missing
37        set para to para as string
38        if para is not “” then
39            set _file to para
40            add _file
41        end if
42    end repeat
43end tell

Which worked, but was a bit slow. So I came up with the following system instead:

Create a file called ~/.last_check

Enter the following into a script, and then run it. (I’ve had to modify some lines to get it to look good - particularly the fp=os.popen… line).

 1#! /usr/bin/env python 
 2# Check for songs newer than ~/.last_check, and add them to iTunes
 3
 4import os
 5import sys
 6
 7fp = os.popen(
 8"find ~shared/Music -name *.m?? -newer ~/.last_check")
 9
10data = fp.readlines()
11
12if len(data) == 0:
13    print "No New Songs."
14    sys.exit(0)
15    
16for line in data:
17    filename = "Macintosh HD"+line[:-1]
18    filename = filename.replace("/",":")
19    print "Adding", filename
20    os.system('''osascript < <END
21tell application "iTunes"
22add "'''+filename+'''"
23end tell
24END
25''')

Should be pretty quick - I only tested it with a few files, but seems to work okay. iTunes is even smart enough to not re-add files that are already there (I think!), so it won’t add duplicates!

My library lives in ~shared/Music, yours may vary!

You will, however, need to use something like Super Remove Dead Tracks if you update one library with a new encoder!

I accept no responsibility if it screws up your iTunes Library file!

More on Sharing iTunes Songs

After all of the mucking around with getting an AppleScript to work, and then using python anyway, I discovered a far faster method of adding tracks to iTunes: just drag the folder they all live in, and iTunes will only add the songs that aren’t in the Library yet! Probably well documented, but I didn’t find it! What you may need to do, particularly if multiple people need to be able to change MP3 Tags or artwork, is do the following:

  • Change the owner/group of the files to something that all people can access - I use shared/admin, since all non-admin users are scum, and do not need to be able to change stuff.
  • Change the protection bits of the files to allow owner R+W, group R+W, all R.

Code to do this should be easy: ` find ~shared/Music -name .m -not -perm 664 -exec chmod 664 {}; find ~shared/Music -name .m -not -owner shared -exec chown shared:admin {}; ` But bash interprets the ; itself, and gives the following error: find: -exec: no terminating ";" Bitch. Can’t be bothered figuring out how to use another shell, so knock up a script in python: UpdateShared.py This script also updates the owner/group and permissions for files in ~shared/Movies and ~shared/iPhotoLibrary. Update: the ; must be \; for the bash commands to work.

Export Artwork and Playlists

Exporting Artwork

Seeing as how XBMC won’t read the id3 tags from AAC files, I had to grab the artwork from each album and place it in a file (folder.jpg/folder.png) inside the album folder. This was actually easier with Windows (aargh!), since iTunes for Windows exports album art as BMP files, which can then be processed. Still, it took me most of the afternoon to do that by hand. I had had a bash at doing it with an AppleScript, but could not work out how to get the data from a <<class PNG/JPEG *>> structure into an image file. Until I came across a script that does that. It was then a trivial matter to make it so that it worked for multiple files, and only processed those files it needed to, and ignored those without artwork. Tip: iTunes will give you an Out Of Memory Error if you try to get the data from a song that has no artworks! (Took me a while to figure this out!) So, the finished script can be found below. I optimised it a bit, but it still takes a while to run, especially if you run it on lots of tracks. Since it’s not something you’ll want to run every day, this shouldn’t be too much of a problem.

Exporting Playlists

I also thought it would be neat to get the playlists I use in iTunes (I use mostly smart playlists, such as 50’s - 00’s Music, Not Played Today, Recently Added and so on), and use them on XBMC. So, I wrote a script that does this, and then ftp’s the resulting files to the xbox. You will need to edit the first few lines: it should be obvious what needs to go where. Anyway, you can download Export Artwork and Export Playlists. You can also download Bracket Change, a small script that swaps the round & square brackets in a track name. (Right-click and choose to download them, else they will just open in your browser window). All of these files should go into ~/Library/iTunes/Scripts (User only) or /Library/iTunes/Scripts (System-wide) for best effect. Note: The first Script is no longer required, since more recent builds of XBMC can handle the data from AAC files.

Backing Up iTunes Meta-Data

iTunes stores most of the meta-data about songs as id3 tags when you have MP3 files in your collection. I’m not sure what it does with AAC - probably they can have id3 tags or similar as well. However, some important bits of data are not stored - the play count, the rating and the added/played dates. Rating Writer (written by Cornelius Qualley) fixes some of this, but I thought I would expand it so that it stores the other bits. And so that it is smart about not overwriting comments. Enter iTunes MetaData BackUp.scpt. Once again I am reminded of how crap AppleScript is if you are not just doing something really basic. Python so rocks. Finally, though, I managed to get everything working, with one exception: you do not seem to be able to convert back into a date from a string, unless you just typed it in as code. I’ve tried, several times, including stripping out trailing newlines, and then finally by creating a function/subroutine to do it manually. But guess what. None of them actually work. iTunes will not accept any type of date back in. So, it only backs up and restores the rating and the played count. Hardly three hours work, in the end. Swears under breath.

iTunes Library File Name Change

In iTunes 4.9, the library file is no longer called iTunes 4 Music Library, but just plain old iTunes Library. Broke my cron entry for backing it up…

Rainlight OctaMED module.

Back in the old days (I’m talking 1993), I found an OctaMED module on Aminet, that I really liked, called Rainlight. Since then, I’ve often thought about this track, and today downloaded it again. Finding something that would play, and convert it well was a bit of a struggle. I tried SoundApp, but that would have clicking errors, so I had to look elsewhere. (I later found out these errors were due to it trying to upsample to 22kHz, 11 works okay.) I also tried CocoModX, which would only play the track too fast. I could change the tempo, but this song has tempo marks throughout it, and it kept speeding up again). Finally, I used Sound Trecker, which, like SoundApp, requires classic, but it worked (I was able to change the sample rate), and I was able to export it to AIFF, and then import this into iTunes. So, and important part of my computing/music heritage is now safe in my iTunes library. Yay Rainlight.

Meow!

Using the program Meow, it’s possible to see what notifications different programs give to the system - things like changing the menu-bar, that the menu was activated, and in iTunes, that the song has changed. Yes, you heard right - there will be no need to poll the system every n seconds to see if the song is the same! Or if the song is paused! Now I just need to find out how to discover these notifications, and act upon them.

Transferrence (iTunes Library Migration)

I’m putting my whole iTunes Library, and all of my iPhoto pictures, and the various movies I’ve collected onto my NSLU2. To shift the iTunes library, I just changed the library location in the Advanced Preferences, and then Consolidated the Library. I’m hoping I’ll be able to do exactly the same with Jaq’s and it won’t actually have to copy the files across, as they will already be there. It will be interesting to see how clever it is. It takes a couple of hours to transfer the many gigabytes of music I’ve encoded, so hopefully it won’t have to be completely redone. Either way, it will keep all of my ratings, and so forth. My tip for sharing songs from a library between multiple users - just point all of the iTuneses at the same location for storing the files, and make sure all of them are set up the same in terms of organising. When one person adds songs, the others just need to drag the folder/disk onto the iTunes Library icon in iTunes, and only the new files will be added. There are occasionally issues when someone changes an album or track name, but iTunes seems to cope pretty well most of the time.