Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Annotate iTunes tracks with data from allmusic.com Apps
The script below attempts to automatically query the allmusic.com website to find Tones (see robg's note below) associated with an iTunes track. The Tones are then added to the comments field of the track. I've seen people express a desire for such a script, so thought I'd post what I've come up with -- but check the caveats below...

The script is written in Perl and requires WWW::Mechanize and Mac::AppleScript::Glue to be installed. The script goes through all the currently selected iTunes tracks (tracks highlighted in blue). For each track, it first queries allmusic.com to find the artist. If there are Tones associated with the artist, it remembers these. It then tries to find the album. If it finds the album, then it uses the Tones associated with the album, rather than those associated with the artist. All tracks in a given album will have the same Tones. The Tones are applied to the comment field of the track by adding them onto whatever comments are already present.

Read the rest of the hint for some caveats and the script...

Caveats:

  1. If the tags in your tracks do not exactly match those in allmusic.com, the script will not find anything. There is some facility on the website for fuzzy matching, but this is not implemented in the script in any way.
  2. Usually when you search allmusic.com by artist, you get back a list of artists that sound like the thing you searched for (the fuzzy matching I mentioned above). The script will simply search the top artist in this list. In 99% of cases I've found this is correct, but with some common names ('Air' for instance), you may get the wrong Tones.
  3. The script is a simple screen scraper -- if allmusic.com changes its website it'll break the script.
  4. allmusic.com will presumably not be happy about people downloading their data. They make money by people using their website and viewing ads. I couldn't find any notices forbidding automated downloads, but I didn't look that hard :). If allmusic ask you to stop using the script, please respect that.
  5. Don't email me if this screws up your music library, (though I can't see how it would) - use at your own risk.
  6. I've run through quite a few of my tracks and it seems to work reasonably. Don't expect it to find everything in allmusic.com perfectly, though (particularly things with weird names), and don't expect allmusic.com to have Tones for every one of your albums.
  7. It'll give a bunch of warnings as it runs:
    v-string in use/require non-portable at /Library/Perl/Mac/AppleScript/Glue.pm line 234.
    
    at the start is due to a change in the way Perl deals with version numbers. It'll also say:
    Unknown input type 'textfield' at /Library/Perl/WWW/Mechanize.pm line 1335 a lot. 
    
    Neither are fatal (or even harmful) and can be ignored or patched (just add textfield to the appropriate part of WWW::Mechanize). This is left as an exercise for the reader.
Anyway, here's the script. Like I said, just select a bunch of tracks in iTunes and run the script from the command line. It'll print out what it's doing as it runs.

[robg adds: Tones are like genres on steroids. For instance, the Tones for Paul Simon's Graceland are 'Whimsical, Summery, Exuberant, Organic, Cheerful, Laid-Back/Mellow, Happy, Poignant, Rousing, Playful, Fun, Reflective.' Having Tones attached to your songs will allow you to create some very targeted playlists. I've also mirrored the script on the macosxhints' server, in case the original goes away at some point. I have not tried this yet, but intend to once I have some time to update my Perl installation.]

    •    
  • Currently 3.60 / 5
  You rated: 5 / 5 (5 votes cast)
 
[24,472 views]  

Annotate iTunes tracks with data from allmusic.com | 9 comments | Create New Account
Click here to return to the 'Annotate iTunes tracks with data from allmusic.com' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
WWW::AllMusicGuide
Authored by: blech75 on May 18, '04 11:40:26AM
for something along the same lines, check out WWW::AllMusicGuide, a perl module that interfaces with the AMG.

[ Reply to This | # ]
Annotate iTunes tracks with data from allmusic.com
Authored by: jeffbyrnes on May 18, '04 07:59:40PM
Along with grabbing the "Tones", would it be possible to grab "Styles", and if so, how would I go about changing this script to do so? For all of my jazz albums, I add the styles by hand. If I could automate this, I'd really appreciate the help :)

---
-Jeff

[ Reply to This | # ]

Annotate iTunes tracks with data from allmusic.com
Authored by: bluehz on May 18, '04 10:52:42PM

Maybe I'm misunderstanding "grouping" but it seems to me that I read that "Grouping" was like "genres on steroids", so maybethis script should write to the grouping field instead. I'm still very sketchy on the whole purpose of grouping though.



[ Reply to This | # ]
Annotate iTunes tracks with data from allmusic.com
Authored by: ahbe on May 19, '04 11:54:33AM
Let me start by pointing out that I have no idea what I'm doing. I tried to install WWW:Mechanize and Mac-AppleScript-Glue with limited results. Neither seem to have an installation guide. I get the following at the command line.

[ahbe@Ahbes-PowerBook WWW-Mechanize-1.02]$ perl Makefile.PL 
Do you want to install the mech-dump utility? [y] y

It looks like you don't have SSL capability (like IO::Socket::SSL) installed. 
You will not be able to process https:// URLs correctly.


WWW::Mechanize likes to have a lot of test modules for some of its tests.
The following are modules that would be nice to have, but not required.

        Test::Pod
        Test::Memory::Cycle
        Test::Warn


Warning: prerequisite HTML::Form 1.038 not found.
Warning: prerequisite HTML::HeadParser 0 not found.
Warning: prerequisite HTML::TokeParser 2.28 not found.
Warning: prerequisite HTTP::Daemon 0 not found.
Warning: prerequisite HTTP::Request 1.3 not found.
Warning: prerequisite HTTP::Status 0 not found.
Warning: prerequisite LWP 5.76 not found.
Warning: prerequisite LWP::UserAgent 2.024 not found.
Warning: prerequisite URI::URL 0 not found.
Warning: prerequisite URI::file 0 not found.
Writing Makefile for WWW::Mechanize
[ahbe@Ahbes-PowerBook WWW-Mechanize-1.02]$ 
And

[ahbe@Ahbes-PowerBook Mac-AppleScript-Glue-0.03]$ perl Makefile.PL 
Warning: prerequisite Mac::AppleScript 0.03 not found.
Warning: prerequisite Test::Pod 0 not found.
Writing Makefile for Mac::AppleScript::Glue
[ahbe@Ahbes-PowerBook Mac-AppleScript-Glue-0.03]$ 
So, I'm sure those warning's aren't good, but I press on. Here's what I get with the iTunes script.

[ahbe@Ahbes-PowerBook Desktop]$ perl iTunesAMG.pl 
Can't locate WWW/Mechanize.pm in @INC (@INC contains: /sw/lib/perl5 /System/Library/Perl/5.8.1/darwin-thread-multi-2level /System/Library/Perl/5.8.1 /Library/Perl/5.8.1/darwin-thread-multi-2level /Library/Perl/5.8.1 /Library/Perl /Network/Library/Perl/5.8.1/darwin-thread-multi-2level /Network/Library/Perl/5.8.1 /Network/Library/Perl .) at iTunesAMG.pl line 4.
BEGIN failed--compilation aborted at iTunesAMG.pl line 4.
[ahbe@Ahbes-PowerBook Desktop]$ 
That obviously didn't work. Now I read that Rob had to update his Perl installation, and I haven't done that. a perl --version gives back 5.8.1-RC3 (Panther default). I took a look on perl.org, and the stable release is 5.8.4. However, I didn't find any packaged installation for OS X, and I didn't feel like trying it from source. I took a look at Fink, but the latest version it lists is 5.6.0, even older. So, what am I doing wrong, and how can I get this to work? Thanx for all your help. --Ahbe

[ Reply to This | # ]
Annotate iTunes tracks with data from allmusic.com
Authored by: smyklar on May 19, '04 10:57:57PM

After creating the makefile with the perl Makefile.PL script, you need to type 'make' at the shell prompt while in the same directory. Works here with Perl v5.8.1-RC3 in Panther. HTH.



[ Reply to This | # ]
Latest Perl still fails to compile this . . .
Authored by: smyklar on May 20, '04 06:35:43AM

ahbe,

Scratch my earlier comment; I'm getting the same errors re: @ INC, even after installing the latest version of Perl (5.8.4-1), using the Fink utility. I'm afraid I"m just as much an amateur as you! Anyone else help?

R



[ Reply to This | # ]
Annotate iTunes tracks with data from allmusic.com
Authored by: Darukaru on May 20, '04 01:11:48AM

Do be careful with this if you have a large library. AMG has been known to ban people from accessing its site for the use of tools like this.



[ Reply to This | # ]
Annotate iTunes tracks with data from allmusic.com
Authored by: kmriley on Jun 11, '04 06:46:20PM

I got all the perl libraries installed just fine, but, I'm caught on how to run the thing. (I could find no documentation.) I tried putting the script in my Library/iTunes/Scripts, and, it did not appear in the scripts listing in iTunes. Looking at how it is written, it looks like it runs from a selection in iTunes. Where have I gone wrong? Obviously, I know very little about this.



[ Reply to This | # ]
Annotate iTunes tracks with data from allmusic.com
Authored by: david-bo on Nov 24, '04 02:23:17PM

Did anyone ever got this to work?

I asked a question about it in the forums but so far no one has answered

link

---
http://www.google.com/search?as_q=%22Authored+by%3A+david-bo%22&num=10&hl=en&ie=ISO-8859-1&btnG=

[ Reply to This | # ]