Index: Slim/Music/Info.pm =================================================================== RCS file: /home/cvs/cvsroot/slim/server/Slim/Music/Info.pm,v retrieving revision 1.158 diff -u -p -B -r1.158 Info.pm --- Slim/Music/Info.pm 25 Nov 2004 04:02:42 -0000 1.158 +++ Slim/Music/Info.pm 3 Dec 2004 07:53:04 -0000 @@ -145,7 +146,7 @@ my $dbname; my $DBVERSION = 16; my %artworkCache = (); -my $artworkDir; +my $artworkDir=''; my %lastFile; my @playlists=(); @@ -534,6 +536,7 @@ sub completeClearCache { %caseCache = (); %sortCache = (); %artworkCache = (); + $artworkDir=''; %songCountMemoize=(); %artistCountMemoize=(); @@ -1524,7 +1527,7 @@ sub coverArt { if (($art eq 'cover') && $artwork && ($artwork ne '1')) { $body = getImageContent($artwork); if ($body) { - $::d_artwork && Slim::Utils::Misc::msg("Found cached artwork file: $artwork\n"); + $::d_artwork && Slim::Utils::Misc::msg("Found cached $art file: $artwork\n"); $contenttype = mimeType(Slim::Utils::Misc::fileURLFromPath($artwork)); $path = $artwork; } else { @@ -1533,8 +1536,9 @@ sub coverArt { } elsif (($art eq 'thumb') && $artworksmall && ($artworksmall ne '1')) { $body = getImageContent($artworksmall); + if ($body) { - $::d_artwork && Slim::Utils::Misc::msg("Found cached artwork-small file: $artworksmall\n"); + $::d_artwork && Slim::Utils::Misc::msg("Found cached $art file: $artworksmall\n"); $contenttype = mimeType(Slim::Utils::Misc::fileURLFromPath($artworksmall)); $path = $artworksmall; } else { @@ -2183,44 +2189,42 @@ sub readTags { $::d_info && Slim::Utils::Misc::msg("readTags: calculating header $header, startbytes $startbytes and endbytes $endbytes\n"); } - if (! Slim::Music::iTunes::useiTunesLibrary()) { - # Check for Cover Artwork, only if not already present. - if (exists $tempCacheEntry->{'COVER'} || exists $tempCacheEntry->{'THUMB'}) { - $::d_artwork && Slim::Utils::Misc::msg("already checked artwork for $file\n"); - } elsif (Slim::Utils::Prefs::get('lookForArtwork')) { - my $album = $tempCacheEntry->{'ALBUM'}; - $tempCacheEntry->{'TAG'} = 1; - $tempCacheEntry->{'VALID'} = 1; - # cache the content type - $tempCacheEntry->{'CT'} = $type unless defined $tempCacheEntry->{'CT'}; - #update the cache so we can use readCoverArt without recursion. - updateCacheEntry($file, $tempCacheEntry); - # Look for Cover Art and cache location - my ($body,$contenttype,$path); - if (defined $tempCacheEntry->{'PIC'} || defined $tempCacheEntry->{'APIC'}) { - ($body,$contenttype,$path) = readCoverArtTags($file,$tempCacheEntry); + # Check for Cover Artwork, only if not already present. + if (exists $tempCacheEntry->{'COVER'} || exists $tempCacheEntry->{'THUMB'}) { + $::d_artwork && Slim::Utils::Misc::msg("already checked artwork for $file\n"); + } elsif (Slim::Utils::Prefs::get('lookForArtwork')) { + my $album = $tempCacheEntry->{'ALBUM'}; + $tempCacheEntry->{'TAG'} = 1; + $tempCacheEntry->{'VALID'} = 1; + # cache the content type + $tempCacheEntry->{'CT'} = $type unless defined $tempCacheEntry->{'CT'}; + #update the cache so we can use readCoverArt without recursion. + updateCacheEntry($file, $tempCacheEntry); + # Look for Cover Art and cache location + my ($body,$contenttype,$path); + if (defined $tempCacheEntry->{'PIC'} || defined $tempCacheEntry->{'APIC'}) { + ($body,$contenttype,$path) = readCoverArtTags($file,$tempCacheEntry); + } + if (defined $body) { + $tempCacheEntry->{'COVER'} = 1; + $tempCacheEntry->{'THUMB'} = 1; + if ($album && !exists $artworkCache{$album}) { + $::d_artwork && Slim::Utils::Misc::msg("ID3 Artwork cache entry for $album: $file\n"); + $artworkCache{$album} = $file; } + } else { + ($body,$contenttype,$path) = readCoverArtFiles($file,'cover'); if (defined $body) { - $tempCacheEntry->{'COVER'} = 1; - $tempCacheEntry->{'THUMB'} = 1; + $tempCacheEntry->{'COVER'} = $path; + } + # look for Thumbnail Art and cache location + ($body,$contenttype,$path) = readCoverArtFiles($file,'thumb'); + if (defined $body) { + $tempCacheEntry->{'THUMB'} = $path; + # add song entry to %artworkcache if we have valid artwork if ($album && !exists $artworkCache{$album}) { - $::d_artwork && Slim::Utils::Misc::msg("ID3 Artwork cache entry for $album: $filepath\n"); - $artworkCache{$album} = $filepath; - } - } else { - ($body,$contenttype,$path) = readCoverArtFiles($file,'cover'); - if (defined $body) { - $tempCacheEntry->{'COVER'} = $path; - } - # look for Thumbnail Art and cache location - ($body,$contenttype,$path) = readCoverArtFiles($file,'thumb'); - if (defined $body) { - $tempCacheEntry->{'THUMB'} = $path; - # add song entry to %artworkcache if we have valid artwork - if ($album && !exists $artworkCache{$album}) { - $::d_artwork && Slim::Utils::Misc::msg("Artwork cache entry for $album: $filepath\n"); - $artworkCache{$album} = $filepath; - } + $::d_artwork && Slim::Utils::Misc::msg("Artwork cache entry for $album: $file\n"); + $artworkCache{$album} = $file; } } } @@ -2486,7 +2490,7 @@ sub readCoverArtFiles { if ($body) { $::d_artwork && Slim::Utils::Misc::msg("Found $image file: $artpath\n\n"); $contenttype = mimeType(Slim::Utils::Misc::fileURLFromPath($artpath)); - $lastFile{$image} = $artpath; + #$lastFile{$image} = $artpath; return ($body, $contenttype, $artpath); } } elsif (defined($artwork)) { @@ -2575,14 +2579,15 @@ sub updateArtworkCache { # Check for Artwork and update %artworkCache my $artworksmall = $cacheEntry->{'THUMB'}; my $album = $cacheEntry->{'ALBUM'}; + if (defined $artworksmall && defined $album && $artworksmall) { if (!exists $artworkCache{$album}) { # only cache albums once each my $filepath = $file; if (isFileURL($file)) { $filepath = Slim::Utils::Misc::pathFromFileURL($file); } - $::d_artwork && Slim::Utils::Misc::msg("Updating $album artwork cache: $filepath\n"); - $artworkCache{$album} = $filepath; + $::d_artwork && Slim::Utils::Misc::msg("Updating $album artwork cache: $file\n"); + $artworkCache{$album} = $file; } } }