Recover text playlist from .xml file?

GO TO ADMIN PANEL > ADD-ONS AND INSTALL VERTIFORO SIDEBAR TO SEE FORUMS AND SIDEBAR

chicowoodhill

New member
Joined
Apr 14, 2009
Messages
6
Points
0
Hi - A friend who is a playlist freak lost a big chunk of his music library. He had hundreds of hand-crafted playlists, now with gaping holes.

We still have some old .xml playlist files, and a backup .xml library file, all dated before the losses.

Does an applescript exist that can create text listings of his playlists from the .xml files? Inside the .xml files I can see the list of library songs, and below those are the playlist arrays (consisting of pointers to the songs in the library list). I've recreated a couple by hand so the information is all there.

I dread the time it will take me to write and debug an applescript to do this (I'm a clumsy programmer but given lots of time I can eventually get it done). Does anyone know of a script to do this? Anybody already written something similar?

Thanks......chico
 

rockmyplimsoul

Active member
Joined
Jan 3, 2006
Messages
5,492
Points
36
Location
In the Pub
Website
www.last.fm
If you have the original .xml files from the playlists, you can simply import them into iTunes if the location of the native files for the songs has not changed. If that's the case, the playlists would be as they were before. Note that the playlist name may come in as it appeared when the .xml file was created, so if the name has not changed, maybe re-name the current (defective) one to keep it separate for now.
 

chicowoodhill

New member
Joined
Apr 14, 2009
Messages
6
Points
0
If you have the original .xml files from the playlists, you can simply import them into iTunes if the location of the native files for the songs has not changed.
Thanks but that won't work. Since many of the songs are now gone, importing the playlist will not provide correct playlists, only playlists made up of the remaining songs. iTunes does not inform you which songs are missing.

My friend needs to create a text listing of his original playlists, so he knows what songs to go out and buy to recreate the playlists in full.

All the required data (Music Library and Playlist Contents & Order) are contained in the playlist.xml files he still has (they were saved before he lost his files). But the playlists are numerical pointers to the Music Library songs already listed higher in the file, so they are not directly readable without some data manipulation. I'm trying to locate an applescript (or other software) that would scan his .xml files and recreate the playlists in text format, showing the full contents of the playlists prior to his losing his music files.

The data is all there. It just needs to be parsed and cleaned up. I could write a flowchart myself, but I know from experience that if I try to write an Applescript myself we're talking days of struggle. I'm that bad.

So just asking is anyone has already done this??? I would be so relieved if so.... :)
 

S2_Mac

New member
Joined
Oct 24, 2006
Messages
4,878
Points
0
Location
About 3 feet in front of the monitor
Since the files referenced in the XML files may or may not exist, there's no need to include iTunes in the equation; the whole thing could be done in pure Perl or Python. Never tried parsing playlist info from iTunes XML before (it's always the other-way-round -- as soon as you hit playlists you can stop ;-); doesn't look too nasty.

I could p'bly have something whipped out this weekend...but it would really help to know exactly what info about the tracks was wanted -- track name and what else? Artist? Album? Track Time? Etc. Post again with that info and I'll get started in the next couple of days....
 

chicowoodhill

New member
Joined
Apr 14, 2009
Messages
6
Points
0
Since the files referenced in the XML files may or may not exist, there's no need to include iTunes in the equation; the whole thing could be done in pure Perl or Python. Never tried parsing playlist info from iTunes XML before (it's always the other-way-round -- as soon as you hit playlists you can stop ;-); doesn't look too nasty.

I could p'bly have something whipped out this weekend...but it would really help to know exactly what info about the tracks was wanted -- track name and what else? Artist? Album? Track Time? Etc. Post again with that info and I'll get started in the next couple of days....
Wow, that would be great.

I now realize iTunes is not part of the equation. I am investigating using an AppleScript-savvy text editor, Tex-Edit Plus, to do the task, but as usual I'm spending all my time trying to understand a new programming environment rather than attacking the problem at hand.

Here's what I need: given an xml playlist, I need a text listing of the playlist's Track IDs, Song Titles, and Albums.

for example:

1. 10211 / Let's Misbehave / Elvis Costello / De-Lovely
2. 10654 / Begin The Beguine / The Spencer Wyatt Big Band / The Majestic Soundtrack
3. etc.

I assume you know the format of the xml file, but just in case not, all tracks and associated info are listed in the first part of the file ("<key>Tracks</key">, and the actual playlist Track IDs are in a following part of the file ("<key>Playlists</key>").

I have never worked with Perl or Python...if you should give this a try, I'd appreciate the chance to learn how to do this myself by examining the script and understanding the procedure.

If you would like me to provide a sample xml playlist or two, let me know.

Thanks incredibly in advance....chico
 

S2_Mac

New member
Joined
Oct 24, 2006
Messages
4,878
Points
0
Location
About 3 feet in front of the monitor
Hmm...don't forget to check out Doug's page of Tex-Edit Plus Applescripts; p'bly a good way to get your feet wet. (And how 'bout that Doug...is there anything he doesn't do? ;-) For something like this, the "grep" features are your best friends. (That's all this upcoming script will be -- perl's version of "grep".)

FWIW, the Track IDs won't do you much good; they're local to each library (i.e. 10221 in your library is a different track than 10221 in my library is a different track than 10221 in your friend's library), and with so many files mising (either not listed in iTunes, or not located in the paths where iTunes expects them to be) the Track ID information doesn't go very far.... (Yes, I know that "track ID" will be needed to work within the XML file, matching up playlist entries with music file entries; it's just that outside of a solid, working iTunes library the track IDs don't mean much.)

But, that might be a good excuse for fitting in a little Applescript work.... How about this: we'll look for Name, Artist, Album, and maybe Kind (AIFF, M3, etc.) -- and certainly Track ID, if you want -- and then check with iTunes to see if it currently has a file matching those characteristics.

Well, I'll chew it over. Just got even busier, so this weekend is definitely the soonest. L8R!
 

chicowoodhill

New member
Joined
Apr 14, 2009
Messages
6
Points
0
Hmm...don't forget to check out Doug's page of Tex-Edit Plus Applescripts; p'bly a good way to get your feet wet. (And how 'bout that Doug...is there anything he doesn't do? ;-) For something like this, the "grep" features are your best friends. (That's all this upcoming script will be -- perl's version of "grep".)
Yes, I'm familiar with the Tex-Edit Applescript page...that's what's got me going in the Tex-Edit direction. My problem is that when I modify existing scripts to get what I want, things invariably break, and I spend hours trying to find out why. Applescript seems quite arbitrary that way, not as consistent as the old Hypercard language (there, I've just dated myself ;))

I agree, Doug seems to be THE AppleScript man...

FWIW, the Track IDs won't do you much good; they're local to each library (i.e. 10221 in your library is a different track than 10221 in my library is a different track than 10221 in your friend's library), and with so many files mising (either not listed in iTunes, or not located in the paths where iTunes expects them to be) the Track ID information doesn't go very far.... (Yes, I know that "track ID" will be needed to work within the XML file, matching up playlist entries with music file entries; it's just that outside of a solid, working iTunes library the track IDs don't mean much.)
I realize that. I just wanted them for referring back to the original xml file, to make things more readable. Of course, they are the keys to restoring the original playlist order. But you're right, they won't help outside of this limited environment.

But, that might be a good excuse for fitting in a little Applescript work.... How about this: we'll look for Name, Artist, Album, and maybe Kind (AIFF, M3, etc.) -- and certainly Track ID, if you want -- and then check with iTunes to see if it currently has a file matching those characteristics.
No need to do much more than Track ID, Artist, and Album, listed in the playlist order, since he's very familiar with his huge music collection (a radio DJ since 1972). Basically he just wants to examine each playlist to see if it's worth reripping the missing music from his 50,000 CD collection or buying it on iTunes.

Well, I'll chew it over. Just got even busier, so this weekend is definitely the soonest. L8R!
Any help would be greatly appreciated. In the meantime I'm hacking away at Tex-Edit scripts, trying to make something that'll work. Thanks again...

chico
 

S2_Mac

New member
Joined
Oct 24, 2006
Messages
4,878
Points
0
Location
About 3 feet in front of the monitor
Applescript seems quite arbitrary that way, not as consistent as the old Hypercard language

There now, you've brought a tear to my eye. Still amazes me that two people put the whole thing together (Bill Atkinsons and Dan Winkler) in about a year, doing a large chunk of it on Lisas (since there were no compilers for early Macs ;-). The shock of Apple not keeping it alive has never quite left me...especially when there were such grand plans for it -- QuickTime was to become a container for stacks; each container would be able to run a number of "streams" (kinda like threads), up to 16 IIRC; video in one part of the window, text in a couple others, upload in another, all knit together with HyperTalk. All that would be needed to run stacks was QT Player. Stacks could live on the internet, and Player would download and run them -- it would have been like the Web, only years earlier (and way cooler). But the HC "team" (mostly just Kevin Calhoun) was pulled off to help complete QuickTime 4, and the whole idea just faded away...

(there, I've just dated myself)

LOL! Maybe we've crossed paths before....ever hang out in the AOL HyperCard forum back in the day? I ran the libraries, boards, and discussions there for a few years. Lottsa fun; used to bump into Apple people all the time, and the community was fantastic
 

chicowoodhill

New member
Joined
Apr 14, 2009
Messages
6
Points
0
Applescript seems quite arbitrary that way, not as consistent as the old Hypercard language

There now, you've brought a tear to my eye....But the HC "team" (mostly just Kevin Calhoun) was pulled off to help complete QuickTime 4, and the whole idea just faded away...
Yeah, too bad HC was lost. The beauty of HC was that you could usually intuit if something... syntax, commands, whatever...was going to work. Amazing how easy it was to write stuff with very few issues or glitches, it just flowed out smoothly.

To me the biggest problem with AS is that, as an occasional user, things that OUGHT TO work don't...and I have to struggle to to figure out why, even if I just borrowed the routine from another script where it worked. Costs me a lot of sweat.

I think you nailed the reason why HC was more elegant...one or two sharp guys defined the syntax, so once you sensed how their minds worked it was pretty easy to track their thinking processes.


LOL! Maybe we've crossed paths before....ever hang out in the AOL HyperCard forum back in the day?
No, can't say I was ever there. For me HC was a tool I used a lot for quick and dirty projects, many of which grew well beyond their original intent, just because it was so easy to keep hacking away and adding more and more stuff.

For example, with HC I could probably punch out this xml playlist parsing thing real quick, because HC incorporated equally powerful text and numerical handlers. I'll use Tex-Edit Applescript for this particular thing, but while Tex-Edit is great for text it doesn't do anything with numbers...something desired here, since it's necessary to reconstruct the order of the playlist based on pointers to the songs. I can see how to do it just using search-and-replace routines rather than computation, but somehow it seems a bit less elegant.

OK, enough bemoaning the disappearance of outdated lost technologies. Don't even get me started on CP/M! ... :)
 

chicowoodhill

New member
Joined
Apr 14, 2009
Messages
6
Points
0
Well, I'll chew it over. Just got even busier, so this weekend is definitely the soonest. L8R!
Hey S2_Mac, thanks for the offer to help out, but don't worry about it...I coded up a script that uses Tex-Edit to parse and rearrange a 75 megabyte iTunes Library.xml file.

It recovered hundreds of lengthy playlists in text format, all properly ordered and formatted. My friend is ecstatic since those represent years of work that he thought was lost. For me, it was an interesting exercise in digging around inside the iTunes Library file, that's my reward...:D
 

rostopovitch

New member
Joined
Nov 27, 2009
Messages
1
Points
0
Any chance you could post the script?

I am in the same boat completely and I need to recover this. I can do it manually as its only like 10 playlists, but would be so much better if I could use your script?

Many thanks

Pov
 

swolk

New member
Joined
May 15, 2013
Messages
1
Points
0
Bump - can anybody help me out with creating one of these scripts? I am in the same boat as these guys were a long time ago - I seem to only have an xml file from before the crash and the playlist data, particularly the orders (I'm a radio guy) are very very important to me. Help would be much appreciated.
 
Top