exclude related artists with persistent ignore table

Laurent lorijho at yes.lu
Thu Aug 10 14:09:42 UTC 2006


Hi Seb,

Last.fm artist relations are not always accurate. By excluding certain
entries from the related artists list of an artist the user can decide
if the relations make sense and blacklist what she/he doesn't like to be
associated with each other.
This is especially useful when Amarok is in dynamic playlist mode I think.

Have a look at this blog entry for details and other examples on
inaccurate recommendations:
http://www.stevekrause.org/steve_krause_blog/2006/01/pandora_and_las.html


Screenshots of Amarok with the patch applied:
http://213.213.211.196/amarok/snapshot1.jpg
http://213.213.211.196/amarok/snapshot2.jpg
http://213.213.211.196/amarok/snapshot3.jpg
http://213.213.211.196/amarok/snapshot4.jpg


Dynamic playlists are more fun and you don't get upset because of
bizarre suggestions that ruin the e.g. mood/genre consistency... and
degrade this otherwise fabulous Amarok feature.

I wanted to share this patch, I created for my personal use, with other 
users so that's why I posted it here in the first place.

Greetings,

Laurent

Seb Ruiz wrote:
> Hi Laurent,
> 
> Could you please explain why you think this patch should be included
> in Amarok - such as usability improvements, convenience or other
> reasons?
> 
> cheers,
> seb
> 
> 
> On 10/08/06, Laurent <lorijho at yes.lu> wrote:
>> Hi to all Amarok Fans.
>>
>> I've improved my previous patch. ( see
>> http://mail.kde.org/pipermail/amarok/2006-August/000937.html )
>>
>> There is now a persistent ignored_related_artists table.
>> I hope the SQL used is compatible with all DB systems supported by 
>> Amarok.
>>
>> The ignored_related_artists table should be created when checking the
>> persistent table version (DATABASE_PERSISTENT_TABLES_VERSION)!
>>
>> Read the patch below or give it a try...
>>
>> Greetings
>>
>> Laurent Baum (lorijho)
>>
>>
>> diff -Naur amarok-1.4.1/amarok/src/collectiondb.cpp 
>> amarok-1.4.1.new/amarok/src/collectiondb.cpp
>> --- amarok-1.4.1/amarok/src/collectiondb.cpp    2006-07-02 
>> 21:37:44.000000000 +0200
>> +++ amarok-1.4.1.new/amarok/src/collectiondb.cpp        2006-08-10 
>> 13:17:48.774354000 +0200
>> @@ -3470,6 +3470,32 @@
>>                .arg( escapeString( path ) ) );
>>  }
>>
>> +void
>> +CollectionDB::ignoreRelatedArtist(const QString &artist, const 
>> QString &relArtist)
>> +{
>> +    // create persistant ignore list for unwanted artist relations
>> +    // I KNOW THIS IS BAD. The table should be created when checking 
>> persistent table versions.
>> +    query( QString( "CREATE TABLE ignored_related_artists ("
>> +                    "artist " + textColumnType() + ","
>> +                    "suggestion " + textColumnType() + ");" )  );
>> +    query( "CREATE INDEX ignored_related_artists_artist ON 
>> ignored_related_artists( artist  );"  );
>> +
>> +    /*check for existing artist/related artist pair*/
>> +    QStringList values = query( QString( "SELECT suggestion FROM 
>> ignored_related_artists "
>> +                                "WHERE artist = '%1' AND suggestion = 
>> '%2';")
>> +                        .arg( escapeString( artist  ), escapeString( 
>> relArtist  )  ) );
>> +    /*add only if the pair is not already in the table*/
>> +    if(values.isEmpty())
>> +    {
>> +        query( QString( "INSERT INTO ignored_related_artists (artist, 
>> suggestion) VALUES( '%1', '%2');" )
>> +                .arg( escapeString( artist ), escapeString( relArtist 
>> ) ) );
>> +    }
>> +    /*
>> +    query( QString( "DELETE FROM related_artists WHERE artist = '%1' 
>> AND suggestion = '%2';"  )
>> +                .arg(  escapeString( artist  ), escapeString( 
>> relArtist  ) )  );
>> +    */
>> +
>> +}
>>
>>  bool
>>  CollectionDB::isDirInCollection( QString path )
>> @@ -3513,11 +3539,23 @@
>>  QStringList
>>  CollectionDB::similarArtists( const QString &artist, uint count )
>>  {
>> +    // create persistant ignore list for unwanted artist relations
>> +    // I KNOW THIS IS BAD. The table should be created when checking 
>> persistent table versions.
>> +    query( QString( "CREATE TABLE ignored_related_artists ("
>> +                    "artist " + textColumnType() + ","
>> +                    "suggestion " + textColumnType() + ");" )  );
>> +    query( "CREATE INDEX ignored_related_artists_artist ON 
>> ignored_related_artists( artist  );"  );
>> +
>>      QStringList values;
>> -
>> +    //exclude previously ignored related artists when querying for 
>> related artists
>> +    values = query( QString( "SELECT suggestion FROM related_artists 
>> WHERE artist = '%1' "
>> +                               "EXCEPT SELECT suggestion FROM 
>> ignored_related_artists WHERE artist = '%1' "
>> +                               "LIMIT %2 OFFSET 0;"  )
>> +                               .arg( escapeString( artist  ), 
>> QString::number( count  )  ) );
>> +    /*
>>      values = query( QString( "SELECT suggestion FROM related_artists 
>> WHERE artist = '%1' LIMIT %2 OFFSET 0;" )
>>                                   .arg( escapeString( artist ), 
>> QString::number( count ) ) );
>> -
>> +    */
>>      if ( values.isEmpty() )
>>          Scrobbler::instance()->similarArtists( artist );
>>
>> diff -Naur amarok-1.4.1/amarok/src/collectiondb.h 
>> amarok-1.4.1.new/amarok/src/collectiondb.h
>> --- amarok-1.4.1/amarok/src/collectiondb.h      2006-07-02 
>> 21:37:44.000000000 +0200
>> +++ amarok-1.4.1.new/amarok/src/collectiondb.h  2006-08-09 
>> 22:00:52.292038750 +0200
>> @@ -270,7 +270,8 @@
>>          void removeSongsInDir( QString path );
>>          void removeSongs( const KURL::List& urls );
>>          void updateDirStats( QString path, const long datetime, const 
>> bool temporary = false );
>> -
>> +        /*member function that add a artist/related artist to the 
>> ignore table*/
>> +        void ignoreRelatedArtist(const QString &artist, const QString 
>> &relArtist);
>>          //song methods
>>          bool addSong( MetaBundle* bundle, const bool incremental = 
>> false );
>>          void doATFStuff( MetaBundle *bundle, const bool tempTables = 
>> true );
>> diff -Naur amarok-1.4.1/amarok/src/contextbrowser.cpp 
>> amarok-1.4.1.new/amarok/src/contextbrowser.cpp
>> --- amarok-1.4.1/amarok/src/contextbrowser.cpp  2006-07-02 
>> 21:37:44.000000000 +0200
>> +++ amarok-1.4.1.new/amarok/src/contextbrowser.cpp      2006-08-10 
>> 13:14:57.287636750 +0200
>> @@ -706,7 +706,8 @@
>>
>>  void ContextBrowser::slotContextMenu( const QString& urlString, const 
>> QPoint& point )
>>  {
>> -    enum { APPEND, ASNEXT, MAKE, MEDIA_DEVICE, INFO, TITLE, RELATED, 
>> SUGGEST, FAVES, FRESHPODCASTS, NEWALBUMS, FAVALBUMS };
>> +    //enum { APPEND, ASNEXT, MAKE, MEDIA_DEVICE, INFO, TITLE, 
>> RELATED, SUGGEST, FAVES, FRESHPODCASTS, NEWALBUMS, FAVALBUMS };
>> +    enum { APPEND, ASNEXT, MAKE, MEDIA_DEVICE, INFO, TITLE, RELATED, 
>> SUGGEST, FAVES, FRESHPODCASTS, NEWALBUMS, FAVALBUMS, IGNORE_REL_ARTIST 
>> }; /*added ID for ignoring related artist*/
>>      debug() << "url string: " << urlString << endl;
>>
>>      if( urlString.startsWith( "musicbrainz" ) ||
>> @@ -788,6 +789,14 @@
>>              menu.changeTitle( TITLE, i18n("Artist") );
>>              menu.changeItem( INFO,   i18n("Edit Artist 
>> &Information..." ) );
>>              menu.changeItem( ASNEXT, i18n("&Queue Artist's Songs") );
>> +            /*add menu item for excluding related artist only for the 
>> current track artist's related artists or recursively related artists*/
>> +            const MetaBundle &currentTrack = 
>> EngineController::instance()->bundle();
>> +            /*this->m_artist is set when browsing (recursively) 
>> related artists*/
>> +            if (!currentTrack.artist().isEmpty() || 
>> !this->m_artist.isEmpty())
>> +            {
>> +                menu.insertSeparator();
>> +                menu.insertItem( SmallIconSet( amaroK::icon( 
>> "remove_from_playlist" ) ), i18n( "E&xclude from similar artists list" 
>> ), IGNORE_REL_ARTIST );
>> +            }
>>          }
>>          if ( url.protocol() == "album" )
>>          {
>> @@ -909,6 +918,40 @@
>>          MediaBrowser::queue()->addURLs( urls );
>>          break;
>>
>> +    /*add the artist/suggestion to the ignore table*/
>> +    case IGNORE_REL_ARTIST:
>> +    {
>> +        /*this->m_artist is set so we have to consider a related 
>> artist as primary artist that has related artist*/
>> +        QString curArtist;
>> +        if ( !this->m_artist.isEmpty() )
>> +        {
>> +            curArtist=this->m_artist;
>> +        }
>> +        else
>> +        {
>> +            const MetaBundle &currentTrack = 
>> EngineController::instance()->bundle();
>> +            curArtist = currentTrack.artist();
>> +        }
>> +        QString relArtist=url.path();
>> +        if ( !curArtist.isEmpty() )
>> +        {
>> +            CollectionDB::instance()->ignoreRelatedArtist( curArtist, 
>> relArtist );
>> +        }
>> +        /*refresh related artist list in contextbrowser*/
>> +        m_showRelated = !menu.isItemChecked( RELATED );
>> +        amaroK::config( "ContextBrowser" )->writeEntry( 
>> "ShowRelated", m_showRelated );
>> +        m_dirtyCurrentTrackPage = true;
>> +        showCurrentTrack();
>> +
>> +        /*
>> +        //debug() << "currentTrack.artist(): " << 
>> currentTrack.artist() << endl;
>> +        debug() << "this->m_artist: " << this->m_artist << endl;
>> +        debug() << "selected curArtist: " << curArtist << endl;
>> +        debug() << "url.path(): " << url.path() << endl;
>> +        */
>> +
>> +        break;
>> +    }
>>      }
>>  }
>>
>>
>>
>> _______________________________________________
>> Amarok mailing list
>> Amarok at kde.org
>> https://mail.kde.org/mailman/listinfo/amarok
>>
>>
>>
> 
> 





More information about the Amarok mailing list