All,
I am taking a break from Perl6 to help solve a problem for a relative. They have a huge library of music CDs and find it difficult to remember what they already have when looking to buy new stuff. I was hoping there was something equivalent to ISBN for books so that I could automate most of the process of building a database. Using the UPC, I was able to come up with the following very rough proof of concept:
#!/usr/bin/perl use strict; use warnings; use WWW::Mechanize; use HTML::Strip; use HTML::TableContentParser; my $upc = $ARGV[0] || die 'UPC required'; my $url= "http://www.amusicarea.com/detail/$upc.html"; my $mech = WWW::Mechanize->new( autocheck => 1 ); $mech->get($url); my %meta; my $table = HTML::TableContentParser->new()->parse($mech->content); my $data = HTML::Strip->new()->parse($table->[7]{rows}[0]{cells}[1]{da +ta}); $data =~ s/\n\s+//; for my $detail ( split /\n/, $data ) { my ($cat, $info) = split /\s*:\s*/, $detail, 2; $meta{$cat} = $info; } my $song = join '', map { HTML::Strip->new()->parse($_->{data}) } @{$table->[9]{rows}[0]{cells}}; $song =~ s/\n\s*/ /g; push @{$meta{track}}, $_ for grep $_, split /\s+\d+\.\s+/, $song; use Data::Dumper; print Dumper( \%meta );
Before I invest any time into this, I was wondering if anyone else was familiar with a better pre-existing wheel? I spent 2 minutes looking at Net::Amazon::UPC, but I couldn't find any info on the CD in my hand with it. Perhaps I just don't know how to use the module as it seems to me that this is a problem someone else would have already solved. If not, I would be happy to put some real development time into and share it publicly. Your thoughts?

Cheers - L~R


In reply to Music CD Data by Limbic~Region

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.