summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorAndreas Brachold <vdr07@deltab.de>2007-12-20 19:35:31 +0000
committerAndreas Brachold <vdr07@deltab.de>2007-12-20 19:35:31 +0000
commit8eef2643b0c5fe934cc0f1050fa70b698f11aebb (patch)
tree6618c2a62c5496146bbafee3dee2841d5084564b /lib
parente74ce33a1b84c8bd1240f9396c0b6277ccbc9f56 (diff)
downloadxxv-8eef2643b0c5fe934cc0f1050fa70b698f11aebb.tar.gz
xxv-8eef2643b0c5fe934cc0f1050fa70b698f11aebb.tar.bz2
* MUSIC: Cover lookup, more strict
Diffstat (limited to 'lib')
-rw-r--r--lib/XXV/MODULES/MUSIC.pm65
1 files changed, 52 insertions, 13 deletions
diff --git a/lib/XXV/MODULES/MUSIC.pm b/lib/XXV/MODULES/MUSIC.pm
index e0d94e7..4dfcc5a 100644
--- a/lib/XXV/MODULES/MUSIC.pm
+++ b/lib/XXV/MODULES/MUSIC.pm
@@ -24,8 +24,7 @@ sub module {
'CGI' => 'Simple Common Gateway Interface Class',
'LWP::Simple' => 'get, head, getprint, getstore, mirror - Procedural LWP interface',
'Net::Amazon' => 'Framework for accessing amazon.com via SOAP and XML/HTTP',
- 'Net::Amazon::Request::Artist' =>
- 'Class for submitting Artist requests',
+ 'Net::Amazon::Request::Artist' => 'Class for submitting Artist requests',
},
Description => gettext('This module managed music files.'),
Version => (split(/ /, '$Revision$'))[1],
@@ -935,6 +934,30 @@ sub status {
}
# ------------------
+sub _storecover {
+# ------------------
+ my $obj = shift || return error('No object defined!');
+ my $image = shift || return 0;
+ my $target = shift;
+
+ # Avoid empty hash
+ if($image && ref $image eq 'HASH') {
+ my $hash = $image;
+ $image = undef;
+ foreach my $i (keys %$hash) {
+ $image = $hash->{$i};
+ last;
+ }
+ }
+
+ if($image) {
+ lg sprintf("Try to get cover %s", $image);
+ return 1 if(is_success(getstore($image, $target)));
+ }
+ return 0;
+}
+
+# ------------------
sub getcovers {
# ------------------
my $obj = shift || return error('No object defined!');
@@ -975,7 +998,7 @@ sub getcovers {
lg $msg;
# Anzeige der ProcessBar
$waiter->next($current,undef, $msg) if(ref $waiter);
-
+
my $req = Net::Amazon::Request::Artist->new(
artist => $artist,
);
@@ -984,17 +1007,33 @@ sub getcovers {
$album =~ s/([\)\(\-\?\+\*\[\]\{\}])/\\$1/g; # Replace regex groupsymbols "),(,-,?,+,*,[,],{,}"
$album =~ s/([\/])/\./g; # Replace splash
- foreach my $item ($resp->properties) {
+ $artist =~ s/([\)\(\-\?\+\*\[\]\{\}])/\\$1/g; # Replace regex groupsymbols "),(,-,?,+,*,[,],{,}"
+ $artist =~ s/([\/])/\./g; # Replace splash
- if($item->album() =~ /$album/i or
- ($year and $item->year() and $item->year() == $year)) {
- my $image = $item->ImageUrlMedium()
- or $item->ImageUrlLarge()
- or $item->ImageUrlSmall();
- lg sprintf("Try to get cover %s.", $image);
- getstore($image, $target) if($image);
- last;
- }
+ my $image;
+ foreach my $item ($resp->properties) {
+ my $ialbum = $item->album();
+ $ialbum =~ s/([\)\(\-\?\+\*\[\]\{\}])/\\$1/g;
+ $ialbum =~ s/([\/])/\./g;
+ my $iartist = $item->artist();
+ $artist =~ s/([\)\(\-\?\+\*\[\]\{\}])/\\$1/g;
+ $artist =~ s/([\/])/\./g;
+
+ if($ialbum =~ /$album/i
+ and $iartist =~ /$artist/i) {
+
+ $image = $item->ImageUrlMedium()
+ if($item->ImageUrlMedium);
+ last if($image && $obj->_storecover($image,$target));
+
+ $image = $item->ImageUrlLarge()
+ if($item->ImageUrlLarge);
+ last if($image && $obj->_storecover($image,$target));
+
+ $image = $item->ImageUrlSmall()
+ if($item->ImageUrlSmall);
+ last if($image && $obj->_storecover($image,$target));
+ }
}
return 1;