This code will parse the Creative Commons URL into different parts.
#!/bin/perl
#
# Creative Commons url tool by Gunther Voet, 2008.
#
# This Perl CC tool is distributed under
$cclicense = "2008 Gunther Voet.
Licensed to the public under
http://creativecommons.org/licenses/by-nc-sa/2.0/be/
verify at http://www.xsrv.net/license";
#
# version 0.1 preliminary,
#
#
#
# since I didn't find any perl tool available I had to start somewhere!
# this code will be used in my personal perl-media projects, including VisualDreams.
#
# By changing this code you agreed to this license by default!
#
# Enjoy!
#
# Gunther Voet,
# http://www.xsrv.net/contact
#
use URI::Find;
my @uris;
my $cclicensefind = $cclicense;
my $finder = URI::Find->new(
sub {
my($uri, $orig_uri) = @_;
push(@uris,$orig_uri);
});
$finder->find(\$cclicensefind);
if(@uris[0] =~ /http:\/\/creativecommons.org\/licenses\//) {
print "Creative Commons found!\n";
$text = @uris[0];
$text =~ s/http:\/\///gi;
@license = split /\//, $text, 6;
@licenseflags = split /-/, $license[2],3;
$licensetext = $cclicense;
$licensetext =~ /(\w+) (.+) Licensed to the public under (.*)/g;
$lic{year} = $1;
$lic{owner} = $2;
foreach $licenseinfo (@licenseflags){
if ($licenseinfo eq "by") { print "by: Attribution required\n"; }
elsif ($licenseinfo eq "sa") { print "sa: Require Share-Alike\n"; }
if ($licenseinfo eq "nc") { print "nc: Non Commercial use only\n"; }
if ($licenseinfo eq "nd") { print "nd: No Derivative works\n"; }
}
if (@uris[0]) { print "license url: @uris[0]\n"; }
if ($license[3]) { print "version: $license[3]\n"; }
if ($license[4]) { print "country: $license[4]\n"; }
if ($cclicense =~ /verify at @uris[1]/) {
print "cc+: commercial license available at: $uris[1]\n";
}
if ($lic{year}) { print "year: $lic{year} "; }
if ($lic{owner}) { print "owner: $lic{owner} "; }
print "button img: http://i.creativecommons.org/i/$license[2]/88x31.png\n";
print "\nlicense text: $cclicense\n";
} else {
print "No Creative Commons license found!\n";
}