I manage my music & playlists on my laptop, but have a shadow music storage on a NAS at home and run slimserver from a home server (been both windows box and linux box from time to time) pointed to the NAS. With this setup, the built in iTunes playlist usage in slimserver doesn't help (as my local iTunes Library.xml file is on my laptop).
I tired a few iTunes playlist export utilities, but none fixed the fact that the path (and if I was using the linux box for slimserver, forward slash vs. backslash in the paths) is different between my iTunes Library.xml and where slimserver expects to see files on the NAS. This left me doing a series of editpad search and replaces every time. Which not surprisingly meant I didn't update the slimserver playlists very often. Recently, I wrote a PowerShell (formerly know as Monad) script that will parse the iTunes Library.xml, make the necessary path conversions, output extended m3u playlists to my NAS playlist directory, and force a slimserver rescan. In the case anybody else out there would find something like this helpful here is the script. Just fill in the right paths, etc. in the Variable Setup section and it should work fine. FWIW, it takes about 55 seconds to complete the conversion of my 6000 song, 100 playlist iTunes Library on my Core 2 Duo laptop. Its been 10 years since I wrote any code so excuse any inefficiencies that may offend a pro. --------Powershell Script--------------------------- ########################################################################## # Key Variable Setup ########################################################################## $itunesxml = "C:\XXXX\XXXXXX\Music\iTunes\iTunes Music Library.xml" $plloc = "X:\PLAYLISTFOLDER\" $oldpath = "file://localhost/X:/" $newpath = "\\SERVER\Music\" $olddirsep = "/" $newdirsep = "\" $blocklist = "Library", "Movies", "Music", "Party Shuffle", "Podcasts", "Purchased", "TV Shows" $rescan = "http://XXX.XXX.XXX.XXX:9000/status.html?p0=rescan;cauth=XXXXXXXXXXXXXXXXXXXX" ########################################################################## # Export Playlists & Rescan Slimserver Library ########################################################################## $playlisttrigger = $false $newstr="#EXTM3U" $starttime=$(get-date) echo "" "Parsing Library . . . " "" gc $itunesxml | % { if (-not $playlisttrigger) { Switch -regex ($_) { '(<key>Track ID<.key><integer>)([0-9]*)(<.integer>)' { $idtemp=$matches[2] $nametemp = "NAMEERROR" $timetemp = [int] -1 $loctemp = "LOCATIONERROR" } '(<key>Name<.key><string>)(.*)(<.string>)' {$nametemp=$matches[2]} '(<key>Total Time<.key><integer>)([0-9]*)(<.integer>)' {$timetemp=[int]($matches[2]/1000)} '(<key>Location<.key><string>)(.*)(<.string>)' { $loctemp=$matches[2] $tracktable += @{"$idtemp" = @{ "name" = $nametemp; "playtime" = $timetemp; "location" = $loctemp}} } '<key>Playlists<.key>' { $playlisttrigger=$true del "$plloc*.m3u" echo "Writing Playlists . . . " "" } } } else { Switch -regex ($_) { '(<key>Name<.key><string>)(.*)(<.string>)' { $skippl=$false foreach ($bltemp in $blocklist) { $bltemp = "^$bltemp" if ($matches[2] -match $bltemp) { $skippl=$true break } } if (-not $skippl) { if ($emt) {del temp.tmp} if (test-path temp.tmp) {Move-Item temp.tmp $newm3u} $newm3u=$plloc+$matches[2]+".m3u" Add-Content temp.tmp $newstr $emt=$true } } '(<key>Track ID<.key><integer>)([0-9]*)(<.integer>)' { if (-not $skippl) { $id=$matches[2] $newline="EXTINF:" + $tracktable[$id].playtime + ", " + $tracktable[$id].name Add-Content temp.tmp $newline $newline=$tracktable[$matches[2]].location $newline=$newline -replace $oldpath, $newpath $newline=$newline -replace $olddirsep, $newdirsep $newline=$newline -replace "%20", " " Add-Content temp.tmp $newline $emt=$false } } } } } if ($emt) {del temp.tmp} if (test-path temp.tmp) {Move-Item temp.tmp $newm3u} echo "Initiating Rescan of Slimserver . . . " "" $wc=New-Object net.webclient $page=$wc.DownloadString($rescan) $runtime=(New-TimeSpan $starttime $(get-date)).TotalMilliseconds/1000 echo "Completed" "" "Script Run Time: $runtime seconds" "" "Press any key to exit" $null = $Host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown") --------------End----------------------------------- PS. Not sure why this Forum collapsed the indenting in the script, as I know this makes it harder to read. -- IPGuy ------------------------------------------------------------------------ IPGuy's Profile: http://forums.slimdevices.com/member.php?userid=961 View this thread: http://forums.slimdevices.com/showthread.php?t=35608 _______________________________________________ discuss mailing list discuss@lists.slimdevices.com http://lists.slimdevices.com/lists/listinfo/discuss