1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-03-21 16:29:43 +01: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();
}
QVariantMap playInfo;
Tomahawk::InfoSystem::InfoStringHash trackInfo;
trackInfo["title"] = track->track();
trackInfo["artist"] = track->artist()->name();
trackInfo["album"] = track->album()->name();
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 (
s_scInfoIdentifier, Tomahawk::InfoSystem::InfoSubmitNowPlaying,
QVariant::fromValue< Tomahawk::InfoSystem::InfoStringHash >( trackInfo ),
playInfo,
Tomahawk::InfoSystem::PushNoFlag );
Tomahawk::InfoSystem::InfoSystem::instance()->pushInfo( pushData );

View File

@ -161,19 +161,30 @@ LastFmInfoPlugin::pushInfo( Tomahawk::InfoSystem::InfoPushData pushData )
void
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!";
if ( !m_scrobbler )
tLog() << "No scrobbler!";
tDebug() << Q_FUNC_INFO << "Failed to convert data to a QVariantMap";
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" ) )
return;
m_track = lastfm::MutableTrack();
m_track.stamp();
m_track.setTitle( hash["title"] );