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