[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    extragear/multimedia/amarok
From:       Martin Aumüller <aumuell () reserv ! at>
Date:       2005-11-29 22:00:36
Message-ID: 1133301636.137541.19277.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 484223 by aumuell:

update playcount for items played on iPod


 M  +2 -0      ChangeLog  
 M  +43 -0     src/collectiondb.cpp  
 M  +1 -0      src/collectiondb.h  
 M  +10 -0     src/mediabrowser.cpp  


--- trunk/extragear/multimedia/amarok/ChangeLog #484222:484223
@@ -5,6 +5,8 @@
 
 VERSION 1.4:
   FEATURES:
+    * Optionally update playcount for items played on iPod and submit them
+      to last.fm.
     * Ability to copy items from iPod and from filebrowser to collection.
     * Downloaded podcast episodes can be deleted from the context menu.
     * New DCOP call "player: osdEnabled".
--- trunk/extragear/multimedia/amarok/src/collectiondb.cpp #484222:484223
@@ -1201,7 +1201,50 @@
     return true;
 }
 
+QString
+CollectionDB::getURL( const QString &artist, const QString &album, const QString \
&title ) +{
+    uint artID = artistID( artist, false );
+    if( !artID )
+        return QString::null;
 
+    uint albID = albumID( album, false );
+    if( !albID )
+        return QString::null;
+
+
+    QStringList urls = query( QString(
+            "SELECT tags.url "
+            "FROM tags "
+            "WHERE tags.album = '%1' AND tags.artist = '%2' AND tags.title = '%3';" \
) +                .arg( albID ).arg( artID ).arg( escapeString( title ) ) );
+
+    if( urls.empty() )
+        return QString::null;
+
+    if( urls.size() == 1 )
+    {
+        return urls.first();
+    }
+
+    QString url = urls.first();
+    int maxPlayed = -1;
+    for( QStringList::iterator it = urls.begin();
+            it != urls.end();
+            it++ )
+    {
+        int pc = getPlayCount( *it );
+        if( pc > maxPlayed )
+        {
+            maxPlayed = pc;
+            url = *it;
+        }
+    }
+
+    return url;
+}
+
+
 static void
 fillInBundle( QStringList values, MetaBundle &bundle )
 {
--- trunk/extragear/multimedia/amarok/src/collectiondb.h #484222:484223
@@ -234,6 +234,7 @@
 
         bool isDirInCollection( QString path );
         bool isFileInCollection( const QString &url );
+        QString getURL( const QString &artist, const QString &album, const QString \
&title );  void removeDirFromCollection( QString path );
         void removeSongsInDir( QString path );
         void removeSongs( const KURL::List& urls );
--- trunk/extragear/multimedia/amarok/src/mediabrowser.cpp #484222:484223
@@ -18,6 +18,7 @@
 #include "metabundle.h"
 #include "statusbar.h"
 #include "scrobbler.h"
+#include "collectiondb.h"
 
 #ifdef HAVE_LIBGPOD
 #include "gpodmediadevice/gpodmediadevice.h"
@@ -1376,10 +1377,19 @@
                 MetaBundle *bundle = it->bundle();
                 for( int i=0; i<it->recentlyPlayed(); i++ )
                 {
+                    // submit to last.fm
                     playTime -= bundle->length();
                     SubmitItem *sit = new SubmitItem( bundle->artist(), \
                bundle->album(), bundle->title(), bundle->length(), playTime );
                     Scrobbler::instance()->m_submitter->submitItem( sit );
                     debug() << "scrobbling " << bundle->artist() << " - " << \
bundle->title() << ": " << it->url() << endl; +
+                    // increase amaroK playcount
+                    QString url = CollectionDB::instance()->getURL( \
bundle->artist(), bundle->album(), bundle->title() ); +                    if( url != \
QString::null ) +                    {
+                        CollectionDB::instance()->addSongPercentage( url, 100 );
+                        debug() << "played " << url << endl;
+                    }
                 }
             }
             break;


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic