Bug 130518 - Cover isn't replaced by amazon search in context browser
Summary: Cover isn't replaced by amazon search in context browser
Status: RESOLVED FIXED
Alias: None
Product: amarok
Classification: Applications
Component: Context View (show other bugs)
Version: 1.4.1
Platform: Ubuntu Linux
: NOR normal
Target Milestone: ---
Assignee: Amarok Developers
URL:
Keywords:
: 114887 132538 (view as bug list)
Depends on:
Blocks:
 
Reported: 2006-07-09 16:46 UTC by Voggeneder Simon
Modified: 2007-03-03 21:41 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Voggeneder Simon 2006-07-09 16:46:05 UTC
Version:           1.4.1 (using KDE KDE 3.5.3)
Installed from:    Ubuntu Packages
OS:                Linux

Since I am using amaroK 1.4.1, released several days ago, under Kubuntu Dapper I am not able to replace wrong album covers by searching amazon for them. I click on 'save' but the cover remains the same.

At first at least.. it is not shown in the context browser. Under the cover management tool it is working like a charm, but this little bug annoys me a bit ;)

Just wanted to inform you that it's not working proplerly - it did work under all the previous versions.
Comment 1 Voggeneder Simon 2006-07-09 16:48:35 UTC
oh.. before I forget

Kubuntu Dapper 6.06
KDE 3.5.3 from Kubuntu.org
amaroK 1.4.1 from Kubuntu.org
every other package up to date

If it helps :)
Comment 2 Tobias Knieper 2007-01-16 23:09:08 UTC
SVN commit 624268 by tknieper:

Embed album covers in html as encoded strings to get around KHtmlView's 
caching.

BUG: 130518



 M  +1 -0      ChangeLog  
 M  +20 -11    src/contextbrowser.cpp  
 M  +2 -0      src/contextbrowser.h  


--- trunk/extragear/multimedia/amarok/ChangeLog #624267:624268
@@ -97,6 +97,7 @@
     * Amarok now saves playlists with relative paths by default.
 
   BUGFIXES:
+    * Context browser would not display updated covers correctly. (BR 130518)
     * The select custom cover dialog no longer starts in the wrong directory 
       for compilations. (BR 131776)
     * Amarok's xine engine would cut off approximately the last second of an
--- trunk/extragear/multimedia/amarok/src/contextbrowser.cpp #624267:624268
@@ -1389,7 +1389,7 @@
 
         QString artistName = albumValues[5].isEmpty() ? i18n( "Unknown artist" ) : albumValues[5];
 
-        QString albumImage = CollectionDB::instance()->albumImage( albumValues[5], reqResult[ i ], true, 50 );
+        QString albumImage = ContextBrowser::getEncodedImage( CollectionDB::instance()->albumImage( albumValues[5], reqResult[ i ], true, 50 ) );
         QString albumImageTitleAttr = albumImageTooltip( albumImage, 50 );
 
         // Album image
@@ -1733,13 +1733,7 @@
     const QString titleUrl   = lastFmInfo->titleUrl();
     const QString lastfmIcon = "file://" + locate( "data","amarok/images/lastfm.png" );
 
-    // Embed cover image in html (encoded string), to get around khtml's caching
-    const QImage img( lastFmInfo->imageUrl() );
-    QByteArray ba;
-    QBuffer buffer( ba );
-    buffer.open( IO_WriteOnly );
-    img.save( &buffer, "PNG" ); // writes image into ba in PNG format
-    const QString coverImage = QString( "data:image/png;base64,%1" ).arg( KCodecs::base64Encode( ba ) );
+    const QString coverImage = ContextBrowser::getEncodedImage( lastFmInfo->imageUrl() );
 
     QPtrList<QString> newUrls;
     newUrls.append( &albumUrl  );
@@ -2194,7 +2188,7 @@
     usleep( 10000 );
 
     //making 2 tables is most probably not the cleanest way to do it, but it works.
-    QString albumImage = CollectionDB::instance()->albumImage( currentTrack, true, 1 );
+    QString albumImage = ContextBrowser::getEncodedImage( CollectionDB::instance()->albumImage( currentTrack, true, 1 ) );
     QString albumImageTitleAttr = albumImageTooltip( albumImage, 0 );
 
     bool isCompilation = false;
@@ -2660,7 +2654,7 @@
                 i_albumLength += QString(albumValues[j + 4]).toInt();
 
             QString albumLength = ( i_albumLength==0 ? i18n( "Unknown" ) : MetaBundle::prettyTime( i_albumLength, true ) );
-            QString albumImage = CollectionDB::instance()->albumImage( artist, values[ i ], true, 50 );
+            QString albumImage = ContextBrowser::getEncodedImage( CollectionDB::instance()->albumImage( artist, values[ i ], true, 50 ) );
             QString albumImageTitleAttr = albumImageTooltip( albumImage, 50 );
 
             m_HTMLSource.append( QStringx (
@@ -2823,7 +2817,7 @@
                 i_albumLength += QString(albumValues[j + 4]).toInt();
 
             QString albumLength = ( i_albumLength==0 ? i18n( "Unknown" ) : MetaBundle::prettyTime( i_albumLength, true ) );
-            QString albumImage = CollectionDB::instance()->albumImage( artist, values[ i ], true, 50 );
+            QString albumImage = ContextBrowser::getEncodedImage( CollectionDB::instance()->albumImage( artist, values[ i ], true, 50 ) );
             QString albumImageTitleAttr = albumImageTooltip( albumImage, 50 );
 
             m_HTMLSource.append( QStringx (
@@ -3157,6 +3151,21 @@
     saveHtmlData(); // Send html code to file
 }
 
+QString
+ContextBrowser::getEncodedImage( const QString &imageUrl )
+{
+    // Embed cover image in html (encoded string), to get around khtml's caching
+    //debug() << "Encoding imageUrl: " << imageUrl << endl;
+    const QImage img( imageUrl );
+    QByteArray ba;
+    QBuffer buffer( ba );
+    buffer.open( IO_WriteOnly );
+    img.save( &buffer, "PNG" ); // writes image into ba in PNG format
+    const QString coverImage = QString( "data:image/png;base64,%1" ).arg( KCodecs::base64Encode( ba ) );
+    //debug() << "Encoded imageUrl: " << coverImage << endl;
+    return coverImage;
+}
+
 //////////////////////////////////////////////////////////////////////////////////////////
 // Lyrics-Tab
 //////////////////////////////////////////////////////////////////////////////////////////
--- trunk/extragear/multimedia/amarok/src/contextbrowser.h #624267:624268
@@ -134,6 +134,8 @@
         void saveHtmlData();
         void showScanning();
 
+        static QString getEncodedImage( const QString &imageUrl );
+
         static QString wikiLocale();
         static void setWikiLocale( const QString &locale );
         static QString wikiURL( const QString &item );
Comment 3 Tobias Knieper 2007-02-14 15:25:18 UTC
*** Bug 114887 has been marked as a duplicate of this bug. ***
Comment 4 Tobias Knieper 2007-03-03 21:41:15 UTC
*** Bug 132538 has been marked as a duplicate of this bug. ***