1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-08-09 07:36:48 +02:00

Do not scrobble or show current track on Last.fm when listening privately

This commit is contained in:
Jeff Mitchell
2012-05-05 10:10:25 -04:00
parent 07ba8d307c
commit 7b89460aa1
2 changed files with 24 additions and 8 deletions

View File

@@ -79,16 +79,21 @@ Scrobbler::trackStarted( const Tomahawk::result_ptr& track )
scrobble(); scrobble();
} }
Tomahawk::InfoSystem::InfoStringHash trackInfo; QVariantMap playInfo;
Tomahawk::InfoSystem::InfoStringHash trackInfo;
trackInfo["title"] = track->track(); trackInfo["title"] = track->track();
trackInfo["artist"] = track->artist()->name(); trackInfo["artist"] = track->artist()->name();
trackInfo["album"] = track->album()->name(); trackInfo["album"] = track->album()->name();
trackInfo["duration"] = QString::number( track->duration() ); trackInfo["duration"] = QString::number( track->duration() );
trackInfo["albumpos"] = QString::number( track->albumpos() );
playInfo["trackinfo"] = QVariant::fromValue< Tomahawk::InfoSystem::InfoStringHash >( trackInfo );
playInfo["private"] = TomahawkSettings::instance()->privateListeningMode();
Tomahawk::InfoSystem::InfoPushData pushData ( Tomahawk::InfoSystem::InfoPushData pushData (
s_scInfoIdentifier, Tomahawk::InfoSystem::InfoSubmitNowPlaying, s_scInfoIdentifier, Tomahawk::InfoSystem::InfoSubmitNowPlaying,
QVariant::fromValue< Tomahawk::InfoSystem::InfoStringHash >( trackInfo ), playInfo,
Tomahawk::InfoSystem::PushNoFlag ); Tomahawk::InfoSystem::PushNoFlag );
Tomahawk::InfoSystem::InfoSystem::instance()->pushInfo( pushData ); Tomahawk::InfoSystem::InfoSystem::instance()->pushInfo( pushData );

View File

@@ -161,19 +161,30 @@ LastFmInfoPlugin::pushInfo( Tomahawk::InfoSystem::InfoPushData pushData )
void void
LastFmInfoPlugin::nowPlaying( const QVariant &input ) LastFmInfoPlugin::nowPlaying( const QVariant &input )
{ {
if ( !input.canConvert< Tomahawk::InfoSystem::InfoStringHash >() || !m_scrobbler ) m_track = lastfm::MutableTrack();
if ( !input.canConvert< QVariantMap >() )
{ {
tLog() << "LastFmInfoPlugin::nowPlaying no m_scrobbler, or cannot convert input!"; tDebug() << Q_FUNC_INFO << "Failed to convert data to a QVariantMap";
if ( !m_scrobbler )
tLog() << "No scrobbler!";
return; return;
} }
InfoStringHash hash = input.value< Tomahawk::InfoSystem::InfoStringHash >(); QVariantMap map = input.toMap();
if ( map.contains( "private" ) && map[ "private" ] == TomahawkSettings::FullyPrivate )
return;
if ( !map.contains( "trackinfo" ) || !map[ "trackinfo" ].canConvert< Tomahawk::InfoSystem::InfoStringHash >() || !m_scrobbler )
{
tLog() << Q_FUNC_INFO << "LastFmInfoPlugin::nowPlaying no m_scrobbler, or cannot convert input!";
if ( !m_scrobbler )
tLog() << Q_FUNC_INFO << "No scrobbler!";
return;
}
Tomahawk::InfoSystem::InfoStringHash hash = map[ "trackinfo" ].value< Tomahawk::InfoSystem::InfoStringHash >();
if ( !hash.contains( "title" ) || !hash.contains( "artist" ) || !hash.contains( "album" ) || !hash.contains( "duration" ) ) if ( !hash.contains( "title" ) || !hash.contains( "artist" ) || !hash.contains( "album" ) || !hash.contains( "duration" ) )
return; return;
m_track = lastfm::MutableTrack();
m_track.stamp(); m_track.stamp();
m_track.setTitle( hash["title"] ); m_track.setTitle( hash["title"] );