alias READXML {
var %fref = LIB
var %string, %token, %value
var %c
;-- predefined tags
hadd -m PLAYLIST.TOKENS n0 Track ID
hadd -m PLAYLIST.TOKENS n1 Name
hadd -m PLAYLIST.TOKENS n2 Artist
hadd -m PLAYLIST.TOKENS n3 Composer
hadd -m PLAYLIST.TOKENS n4 Album
hadd -m PLAYLIST.TOKENS n5 Genre
hadd -m PLAYLIST.TOKENS n6 Kind
hadd -m PLAYLIST.TOKENS n7 Size
hadd -m PLAYLIST.TOKENS n8 Total Time
hadd -m PLAYLIST.TOKENS n9 Track Number
hadd -m PLAYLIST.TOKENS n10 Year
hadd -m PLAYLIST.TOKENS n11 Date Modified
hadd -m PLAYLIST.TOKENS n12 Date Added
hadd -m PLAYLIST.TOKENS n13 Bit Rate
hadd -m PLAYLIST.TOKENS n14 Sample Rate
hadd -m PLAYLIST.TOKENS n15 Normalization
hadd -m PLAYLIST.TOKENS n16 Location
hadd -m PLAYLIST.TOKENS n17 File Folder Count
hadd -m PLAYLIST.TOKENS n18 Library Folder Count
hadd -m PLAYLIST.TOKENS n19 Play Count
hadd -m PLAYLIST.TOKENS n20 Play Date
hadd -m PLAYLIST.TOKENS n21 Play Date UTC
hadd -m PLAYLIST.TOKENS n22 Equalizer
hadd -m PLAYLIST.TOKENS n23 Rating
/.fopen %fref "iTunes Library.xml"
while (1) {
/.fseek -w %fref *<dict>
if ($feof || $ferr) { break }
var %space = $false
while ($fgetc(%fref)) {
%c = $ifmatch
if (%c == 32) { %space = $true | continue }
%c = $chr(%c)
if (%c !isin <>) && (%c != $t) {
;-- space hack fix
if %space { %string = %string %c | %space = $false }
else { %string = %string $+ %c }
}
if (%c == <) {
if ($hfind(PLAYLIST.TOKENS,%string,1).data) {
%token = %string
}
else {
if (%string != $null) && (%string != $chr(32)) {
%token = %token = %string
;-- write out to a file
write XML.TXT %token
%token = $null
}
%string = $null
}
}
if (%c == >) {
%string = $null
}
}
}
/.hfree PLAYLIST.TOKENS
/.fclose %fref
}