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.

Blogpsot!

I typed schinckel.blogpsot.com into my browser, wanting to check out the links I had made, but got the address wrong. Have a look - it’s funny if you look at my post a little while ago. I thought some vengeful god was hacking me.

I Am The Listmaker

It’s ironic, how disorganised I am, because I love to organise things.

For instance, I have had a ball importing all of my CDs (okay, not all of them, yet) into iTunes, then finding all of the cover art (or eventually, scanning it so it was of a suitable quality), and making sure all of the tags were good.

Then re-importing them as AAC files because they are smaller (and better quality) than MP3.

Then getting all of the cases out for the fourth time to change the year of most songs, especially if they came from a compilation CD.

Then I discovered iPhoto, and have since been importing all of my digital images into that, and organising them. Eventually, I’ll scan all of my old photos, and add them in.

And check all of the dates (luckily, most of my photos are APS/Advantix, so they have a date associated with them!).

Even more recently (let’s be honest, importing the digital photos didn’t take that long. The scanning of the old photos will) I discovered Books, an OSX program that acts as a repository for storing info about your paper library.

And I have a fairly large library. I built a custom bookshelf in my study (two walls worth) and have filled it up. The great feature about Books, other than it is free is that it can do an on-line search for books according to the ISBN of the book. Even better, it can handle barcode inputs, not that I have a barcode scanner.

But it’s fun typing in the number, and letting Amazon.com give me the data.

What’s really fun is seeing how many of my old books (most of my library comes from 2nd hand stores, and I don’t ever throw out or sell a book. I don’t even like to lend them out) are in the Amazon database.

My earliest successes so far include some vintage Frank Herbert (e.g., The Santaroga Barrier, April 1971, ISBN 0-450-00823-1).

The funniest thing I have found is a book without an ISBN: Hulme, H.R., (1969) Nuclear Fusion, Wykeham Publications, London. Not sure if it pre-dates ISBNs, or this publisher just didn’t get one for this series (The Wykeham Science Series: For schools and universities).

Well, back to entering ISBNs.

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.

Step Counts Are In

Well, my four week stint of wearing a pedometer is over. I must say, I really enjoyed it, and it shows me I am not only quite active during the week, but pretty damn inactive over the weekends - unless I have Touch on. And even then, coaching means I walk a hell of a lot less than playing. But I guess I don’t really need a pedometer to tell me that! My highest step count was 20,022 steps: this was on a Thursday (when I play Touch) - I ran out of money and bus ticket, and had to walk home! My lowest step count was 1,415 steps - the Sunday after a 21st. You figure out why. My average over the whole month was 11,709 steps per day - more than the target of 10,000. My weekday average was 13,662; on the weekends (including public holidays) I averaged 7500. Over the whole time period, I did about 328,000 steps: the equivalent of walking to Kingston, S.E. Shame I didn’t make it to Robe. Click on the image above to see a breakdown of my daily step counts.

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:

set _tracks to “”
tell application iTunes
    set sel to tracks of playlist 1
    set sel to get a reference to selection
    repeat with t in sel
        set _tracks to _tracks & 
 & (location of t as string)
    end repeat
end tell

tell application Finder
    set _files to “”
    set _library to Macintosh HD:Users:Shared:Music
    set _artists to folders of folder _library
    repeat with _artist in _artists
        set _albums to folders of _artist
        repeat with _album in _albums
            set temp to files of _album
            repeat with _file in temp
                set _files to _files & 
 & _file
            end repeat
        end repeat
    end repeat
end tell
set _missing to “”
repeat with para in paragraphs of _files
    set para to para as string
    if para is not in _tracks then
        set _missing to _missing & 
 & para
    end if
end repeat

tell application iTunes
    repeat with para in paragraphs of _missing
        set para to para as string
        if para is not “” then
            set _file to para
            add _file
        end if
    end repeat
end 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).

#! /usr/bin/env python 
# Check for songs newer than ~/.last_check, and add them to iTunes

import os
import sys

fp = os.popen(
"find ~shared/Music -name *.m?? -newer ~/.last_check")

data = fp.readlines()

if len(data) == 0:
    print "No New Songs."
    sys.exit(0)
    
for line in data:
    filename = "Macintosh HD"+line[:-1]
    filename = filename.replace("/",":")
    print "Adding", filename
    os.system('''osascript < <END
tell application "iTunes"
add "'''+filename+'''"
end tell
END
''')

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!

Am I a God Botherer?

Just for fun (actually, to see if Google I plugged in “Life According To Matt” (notice the quotes). I was happy to say that this blog came top of the results list, but I was amused to see the remainder:

  • Authorized Version Defense Mystery Of The Cursed Fig Tree
  • The Florida Catholic - Abortion Destroys Women’s Health
  • Claude “Fiddler” Williams: Nearly as Young as Jazz
  • Unknown News - www.UnknownNews.net - The news you need, whether …
  • [PDF] BT V3N16 File Format: PDF/Adobe Acrobat
  • 2blowhards.com: Half Baked Notions, Redux
  • The Vertex - 6.0

From then on in, everything is bible related. Without the quotes, I come in number 3. Like anyone cares.

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.

Prince Reversed

Ain’t technology wonderful. Listening to iTunes tonight, I noticed that the song Darling Nikki has a little bit at the end that is backwards. Grabbing this and reversing it in Sound Studio (but it wouldn’t play in SS, had to re-save it and load it in QuickTime Player), it gives the following:

Hello. / How are you? / I’m fine, ‘cause I know the Lord is coming soon. / Coming, coming soon. / Ha Ha Ha Ha Ha….

Reminded me of the segment that John Safran had on Music Jamboree a few years back. Way back in 2002, according to the website.

iCal to unix calendar

Because I have a PC right next to my Mac (I hate Windows, but until AutoDesk make Inventor for MacOS X…) I sometimes need to be able to check my diary - which I have recently converted to iCal.

Since the reason I am not on the Mac is because my Significant Other is using it, I need a non-gui, non-AppleScript way of checking what’s on for me today.

Being a refugee from BeOS, and having used various unix (and even VMS - the DOS of the mainframe world!) flavours, I had come across calendar. What I needed was a way to make calendar read from the iCal *.ics files. (Speaking of ICS, Google seems to think I am searching for Internet Connection Sharing. Grr!) Since the files themselves are quite easy to understand, I knocked up a quick python script. Called pycal.py, you can find it at pycal.py.