I know how you programming folk like music, and I believe there
may be "support the little guys, not the corporations"
people in here too. So I created the script that takes a directory as an argument,
and then checks all the folders using the RIAA Radar database.
The RIAA Radar is a tool that music consumers can use to
easily and instantly distinguish whether an album was
released by a member of the Recording Industry Association of America (RIAA).
Sample output:
Morcheeba -- Safe: 3 Warning: 7
Moby -- Safe: 6 Warning: 4
#!/usr/bin/perl
use warnings;
use IO::Socket;
$somedir = $ARGV[0];
opendir DH, $somedir or die "Cannot open $somedir: $!";
my @files = grep { !-d } readdir DH;
closedir DH;
foreach $word (@files) {
$flag = 0;
$safecou = 0;
$warcou = 0;
@split = split( / /, $word );
$join = join( '+', @split );
$getexp = IO::Socket::INET->new(
PeerAddr => 'www.riaaradar.com',
PeerPort => '80',
Proto => 'tcp',
Timeout => '100'
) || print "Error: Connection\n";
print $getexp
"GET /search.asp?searchtype=ArtistSearch&keyword=$join HTTP/1.0\
+n";
print $getexp "Host: www.riaaradar.com\n\n";
while ( $exp = <$getexp> ) {
if ( $exp =~ m/No results were found/ ) { $flag = 1; }
#print "Artist: $1\n" if $exp =~ m/name="artist" value="(.*?)"
+ \/>/;
#print "Album: $1\n" if $exp =~ m/name="album" value="(.*?)" \
+/>/;
#print "Result: $1\n\n" if $exp =~ m/name="result" value="(.*?
+)" \/>/;
if ( $exp =~ m/name="result" value="Warning" \/>/ ) { $warcou
++= 1; }
elsif ( $exp =~ m/name="result" value="Safe" \/>/ ) { $safecou
+ += 1; }
}
print "$word -- Safe: $safecou Warning: $warcou\n" if $flag != 1;
}
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.