Limbic~Region has asked for the wisdom of the Perl Monks concerning the following question:
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:
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?
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 );
Cheers - L~R
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Music CD Data
by brian_d_foy (Abbot) on May 29, 2005 at 18:48 UTC | |
by Limbic~Region (Chancellor) on May 29, 2005 at 21:54 UTC | |
by ghenry (Vicar) on May 29, 2005 at 22:43 UTC | |
by brian_d_foy (Abbot) on May 30, 2005 at 00:43 UTC | |
by Limbic~Region (Chancellor) on May 30, 2005 at 00:46 UTC | |
by bart (Canon) on May 30, 2005 at 07:18 UTC | |
Re: Music CD Data
by Camel_thirst (Friar) on May 29, 2005 at 18:46 UTC | |
by Limbic~Region (Chancellor) on May 29, 2005 at 21:47 UTC | |
Re: Music CD Data
by TilRMan (Friar) on May 30, 2005 at 05:08 UTC | |
Re: Music CD Data
by jhourcle (Prior) on May 29, 2005 at 23:18 UTC | |
Re: Music CD Data
by aufflick (Deacon) on May 30, 2005 at 02:45 UTC | |
Re: Music CD Data
by salva (Canon) on May 30, 2005 at 09:28 UTC | |
Re: Music CD Data
by astroboy (Chaplain) on May 30, 2005 at 07:33 UTC | |
Re: Music CD Data
by CountZero (Bishop) on Jun 02, 2005 at 04:08 UTC | |
Re: Music CD Data
by DrHyde (Prior) on Jun 01, 2005 at 09:32 UTC |
Back to
Seekers of Perl Wisdom