small patch that enables control over related artists

Laurent lorijho at yes.lu
Wed Aug 9 17:06:27 UTC 2006


Showing 6 times as many suggestions is too much I know.

I didn't extensively check cache purging.

I will workout a solution with a persistant ignore list if you guys 
really want to have an "exclude from similar artist list" feature ??
I'll improve the patch anyway for my personal use now that you pointed 
out the cache purge thing.

Greetings

Laurent Baum (lorijho)

Martin Aumueller wrote:
> On Wed August 9 2006 17:56, Ian Monroe wrote:
>> Do we never refresh the cache? Does the cache ever get purged? Eg.
>> what database version is it part of.
> 
> The cache gets thrown away on each collection rescan. If something like this 
> patch gets integrated, then there should probably be a persistent 'ignore 
> these relations' table and these should get stripped from the similar artists 
> result.
> 
>> I think the current number of suggested artists and songs shown is
>> good. Maybe its a good idea to broaden it for the dynamic playlist.
> 
> Showing 6 times as many suggestions as now is a bit exaggerated for my taste, 
> too.
> 
> 
>> On 8/9/06, Laurent <lorijho at yes.lu> wrote:
>>> Hi to all Amarok Fans.
>>>
>>> This is my first post to the list and it includes a patch.
>>>
>>> I've written a small patch against amarok-1.4.1. It enables control over
>>> related artists. Last.fm artist relations are not always accurate, so
>>> with the patch applied the user can exclude related artists by right
>>> clicking a related artist name and select "E&xclude from similar artists
>>> list". The item is then removed from the related_artists table in the
>>> collectionDB. This works, of course, also for recursively related
>>> artists (when browsing related artists).
>>>
>>> Other small changes (which are not absolutely necessary):
>>> - fetch up to twice as much (60) related artists from last.fm
>>> - display up to twice as much (60) related artists in the ContextBrowser.
>>> - display up to 60 suggested songs in the ContextBrowser
>>> - consider up to 60 related artists when appending tracks in dynamic
>>> playlist mode
>>>
>>> Some screenshot:
>>> 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
>>>
>>> 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-08
>>> 22:26:17.323684750 +0200 @@ -3470,6 +3470,13 @@
>>>                .arg( escapeString( path ) ) );
>>>  }
>>>
>>> +void
>>> +CollectionDB::removeRelatedArtist(const QString &artist, const QString
>>> &relArtist) +{
>>> +    query( QString( "DELETE FROM related_artists WHERE artist = '%1' AND
>>> suggestion = '%2';"  ) +                .arg(  escapeString( artist  ),
>>> escapeString( relArtist  ) )  ); +
>>> +}
>>>
>>>  bool
>>>  CollectionDB::isDirInCollection( QString path )
>>> 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-08
>>> 22:26:17.355686750 +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 deletes related Artists from DB*/
>>> +        void removeRelatedArtist(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-09
>>> 14:10:04.794680500 +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, DEL_REL_ARTIST }; /*added ID for deleting 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 deleting 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" ),
>>> DEL_REL_ARTIST ); +            }
>>>          }
>>>          if ( url.protocol() == "album" )
>>>          {
>>> @@ -909,6 +918,33 @@
>>>          MediaBrowser::queue()->addURLs( urls );
>>>          break;
>>>
>>> +    /*do the deletion here*/
>>> +    case DEL_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.fileName();
>>> +        if ( !curArtist.isEmpty() )
>>> +        {
>>> +            CollectionDB::instance()->removeRelatedArtist( curArtist,
>>> relArtist ); +        }
>>> +        /*
>>> +        debug() << "currentTrack.artist(): " << currentTrack.artist() <<
>>> endl; +        debug() << "this->m_artist: " << this->m_artist << endl; +
>>>        debug() << "selected curArtist: " << curArtist << endl; +       
>>> debug() << "url.fileName(): " << url.fileName() << endl; +        */
>>> +        break;
>>> +    }
>>>      }
>>>  }
>>>
>>> @@ -2159,9 +2195,9 @@
>>>      {
>>>          bool isInCollection =
>>> !CollectionDB::instance()->albumListOfArtist( relArtists[i] ).isEmpty();
>>> m_HTMLSource.append(
>>> -                ( isInCollection ? "" : "<i>\n" )
>>> +                ( isInCollection ? "<b>\n" : "<i>\n" ) /*bold name if
>>> artist in collection*/ + QString( "<a href='artist:" ) + escapeHTMLAttr(
>>> relArtists[i] ) + "'>\n" + escapeHTML( relArtists[i] ).replace( " ",
>>> " " ) + "</a>\n" -                + ( isInCollection ? "" : "</i>\n"
>>> )
>>> +                + ( isInCollection ? "</b>\n" : "</i>\n" ) /*bold name
>>> if artist in collection*/ );
>>>          if( i != relArtists.count()-1 )
>>>              m_HTMLSource.append( ", " );
>>> @@ -2195,7 +2231,7 @@
>>>      values = qb.run();
>>>
>>>      // not enough items returned, let's fill the list with score-less
>>> tracks -    if ( values.count() < 10 * qb.countReturnValues() )
>>> +    if ( values.count() < 60 * qb.countReturnValues() ) /*10->60related
>>> to relArtists QStringList? which new size is 60*/ {
>>>          qb.clear();
>>>          qb.exclusiveFilter( QueryBuilder::tabSong,
>>> QueryBuilder::tabStats, QueryBuilder::valURL ); @@ -2204,7 +2240,7 @@
>>>          qb.addReturnValue( QueryBuilder::tabArtist,
>>> QueryBuilder::valName ); qb.addMatches( QueryBuilder::tabArtist,
>>> relArtists );
>>>          qb.setOptions( QueryBuilder::optRandomize );
>>> -        qb.setLimit( 0, 10 - values.count() / 4 );
>>> +        qb.setLimit( 0, 60 - values.count() / 4 ); /*10->60 see comment
>>> above*/
>>>
>>>          QStringList sl;
>>>          sl = qb.run();
>>> @@ -2761,7 +2797,7 @@
>>>      else
>>>          showCurrentArtistHeader( currentTrack );
>>>
>>> -    QStringList relArtists = CollectionDB::instance()->similarArtists(
>>> artist, 10 ); +    QStringList relArtists =
>>> CollectionDB::instance()->similarArtists( artist, 60 ); /* 10->60 as many
>>> as we asked for from last.fm*/ if ( !relArtists.isEmpty() )
>>>      {
>>>          if( ContextBrowser::instance()->m_showRelated )
>>> diff -Naur amarok-1.4.1/amarok/src/playlist.cpp
>>> amarok-1.4.1.new/amarok/src/playlist.cpp ---
>>> amarok-1.4.1/amarok/src/playlist.cpp        2006-07-02 21:37:44.000000000
>>> +0200 +++ amarok-1.4.1.new/amarok/src/playlist.cpp    2006-08-08
>>> 22:26:17.395689250 +0200 @@ -597,7 +597,7 @@
>>>      if( type == DynamicMode::SUGGESTION )
>>>      {
>>>          if( !m_currentTrack ) return;
>>> -        QStringList suggestions =
>>> CollectionDB::instance()->similarArtists( currentTrack()->artist(), 16 );
>>> +        QStringList suggestions =
>>> CollectionDB::instance()->similarArtists( currentTrack()->artist(), 60 );
>>> /*16->60 consider all 60 related artists that we asked for from last.fm*/
>>> qb.addMatches( QueryBuilder::tabArtist, suggestions );
>>>      }
>>>      else if( type != DynamicMode::RANDOM ) //we have playlists to choose
>>> from.
>>>
>>>
>>>
>>> _______________________________________________
>>> Amarok mailing list
>>> Amarok at kde.org
>>> https://mail.kde.org/mailman/listinfo/amarok
>> _______________________________________________
>> Amarok mailing list
>> Amarok at kde.org
>> https://mail.kde.org/mailman/listinfo/amarok
> _______________________________________________
> Amarok mailing list
> Amarok at kde.org
> https://mail.kde.org/mailman/listinfo/amarok




More information about the Amarok mailing list