Fixed blob warning

This commit is contained in:
emeric
2026-06-21 16:33:03 +02:00
parent 75c3b302ce
commit d25233f7cc
9 changed files with 50 additions and 50 deletions
@@ -45,7 +45,7 @@ namespace lms::scrobbling::lastFm
const bool res{ track->getDuration() >= std::chrono::seconds{ 30 } && (playedDuration >= std::chrono::minutes{ 4 } || playedDuration >= track->getDuration() / 2) }; const bool res{ track->getDuration() >= std::chrono::seconds{ 30 } && (playedDuration >= std::chrono::minutes{ 4 } || playedDuration >= track->getDuration() / 2) };
if (!res) if (!res)
LOG(DEBUG, "Track cannot be scrobbled: played duration too short (" << playedDuration.count() << "s, total = " << std::chrono::duration_cast<std::chrono::seconds>(track->getDuration()).count() << "s)"); LMS_LOG_LASTFM(DEBUG, "Track cannot be scrobbled: played duration too short (" << playedDuration.count() << "s, total = " << std::chrono::duration_cast<std::chrono::seconds>(track->getDuration()).count() << "s)");
return res; return res;
} }
@@ -57,12 +57,12 @@ namespace lms::scrobbling::lastFm
, _client{ core::http::createClient(ioContext, core::Service<core::IConfig>::get()->getString("lastfm-api-base-url", "https://ws.audioscrobbler.com")) } , _client{ core::http::createClient(ioContext, core::Service<core::IConfig>::get()->getString("lastfm-api-base-url", "https://ws.audioscrobbler.com")) }
, _synchronizer{ ioContext, db, *_client } , _synchronizer{ ioContext, db, *_client }
{ {
LOG(INFO, "Starting Last.fm backend"); LMS_LOG_LASTFM(INFO, "Starting Last.fm backend");
} }
LastFmBackend::~LastFmBackend() LastFmBackend::~LastFmBackend()
{ {
LOG(INFO, "Stopped Last.fm backend"); LMS_LOG_LASTFM(INFO, "Stopped Last.fm backend");
} }
void LastFmBackend::listenStarted(const Listen& listen) void LastFmBackend::listenStarted(const Listen& listen)
@@ -106,7 +106,7 @@ namespace lms::scrobbling::lastFm
const std::string token{ utils::parseAuthToken(msg.body()) }; const std::string token{ utils::parseAuthToken(msg.body()) };
if (token.empty()) if (token.empty())
{ {
LOG(WARNING, "auth.getToken: failed to parse token"); LMS_LOG_LASTFM(WARNING, "auth.getToken: failed to parse token");
onFailure(); onFailure();
return; return;
} }
@@ -120,7 +120,7 @@ namespace lms::scrobbling::lastFm
onSuccess(authUrl); onSuccess(authUrl);
}; };
request.onFailureFunc = [onFailure = std::move(onFailure)] { request.onFailureFunc = [onFailure = std::move(onFailure)] {
LOG(WARNING, "auth.getToken: HTTP request failed"); LMS_LOG_LASTFM(WARNING, "auth.getToken: HTTP request failed");
onFailure(); onFailure();
}; };
_client->sendGETRequest(std::move(request)); _client->sendGETRequest(std::move(request));
@@ -136,7 +136,7 @@ namespace lms::scrobbling::lastFm
auto it{ _pendingAuths.find(userId) }; auto it{ _pendingAuths.find(userId) };
if (it == _pendingAuths.end()) if (it == _pendingAuths.end())
{ {
LOG(WARNING, "continueLastFmLink: no pending auth for user"); LMS_LOG_LASTFM(WARNING, "continueLastFmLink: no pending auth for user");
onFailure(); onFailure();
return; return;
} }
@@ -157,7 +157,7 @@ namespace lms::scrobbling::lastFm
const std::string sessionKey{ utils::parseSessionKey(msg.body()) }; const std::string sessionKey{ utils::parseSessionKey(msg.body()) };
if (sessionKey.empty()) if (sessionKey.empty())
{ {
LOG(WARNING, "auth.getSession: failed to parse session key"); LMS_LOG_LASTFM(WARNING, "auth.getSession: failed to parse session key");
onFailure(); onFailure();
return; return;
} }
@@ -178,11 +178,11 @@ namespace lms::scrobbling::lastFm
_pendingAuths.erase(userId); _pendingAuths.erase(userId);
} }
LOG(INFO, "Last.fm account linked for user " << userId.toString()); LMS_LOG_LASTFM(INFO, "Last.fm account linked for user " << userId.toString());
onSuccess(); onSuccess();
}; };
request.onFailureFunc = [onFailure = std::move(onFailure)] { request.onFailureFunc = [onFailure = std::move(onFailure)] {
LOG(WARNING, "auth.getSession: HTTP request failed"); LMS_LOG_LASTFM(WARNING, "auth.getSession: HTTP request failed");
onFailure(); onFailure();
}; };
@@ -62,7 +62,7 @@ namespace lms::scrobbling::lastFm
const std::string artistName{ track->getArtistDisplayName() }; const std::string artistName{ track->getArtistDisplayName() };
if (artistName.empty()) if (artistName.empty())
{ {
LOG(DEBUG, "Track '" << track->getAbsoluteFilePath() << "' cannot be scrobbled: no artist name"); LMS_LOG_LASTFM(DEBUG, "Track '" << track->getAbsoluteFilePath() << "' cannot be scrobbled: no artist name");
return std::nullopt; return std::nullopt;
} }
@@ -118,7 +118,7 @@ namespace lms::scrobbling::lastFm
, _submitPeriod{ core::Service<core::IConfig>::get()->getULong("lastfm-submit-period-hours", 1) } , _submitPeriod{ core::Service<core::IConfig>::get()->getULong("lastfm-submit-period-hours", 1) }
, _client{ client } , _client{ client }
{ {
LOG(INFO, "Starting Last.fm scrobblings synchronizer, submit period = " << _submitPeriod.count() << " hours"); LMS_LOG_LASTFM(INFO, "Starting Last.fm scrobblings synchronizer, submit period = " << _submitPeriod.count() << " hours");
if (_submitPeriod.count() > 0) if (_submitPeriod.count() > 0)
scheduleSubmit(std::chrono::seconds{ 30 }); scheduleSubmit(std::chrono::seconds{ 30 });
} }
@@ -141,14 +141,14 @@ namespace lms::scrobbling::lastFm
const utils::LastFmCredentials creds{ utils::getLastFmCredentials(_db.getTLSSession(), listen.userId) }; const utils::LastFmCredentials creds{ utils::getLastFmCredentials(_db.getTLSSession(), listen.userId) };
if (creds.apiKey.empty() || creds.apiSecret.empty() || creds.sessionKey.empty()) if (creds.apiKey.empty() || creds.apiSecret.empty() || creds.sessionKey.empty())
{ {
LOG(DEBUG, "Missing Last.fm credentials for user, skipping"); LMS_LOG_LASTFM(DEBUG, "Missing Last.fm credentials for user, skipping");
return; return;
} }
const std::optional<TrackInfo> info{ getTrackInfo(_db.getTLSSession(), listen) }; const std::optional<TrackInfo> info{ getTrackInfo(_db.getTLSSession(), listen) };
if (!info) if (!info)
{ {
LOG(DEBUG, "Cannot build scrobble params: skipping"); LMS_LOG_LASTFM(DEBUG, "Cannot build scrobble params: skipping");
return; return;
} }
@@ -244,7 +244,7 @@ namespace lms::scrobbling::lastFm
const utils::LastFmCredentials creds{ utils::getLastFmCredentials(_db.getTLSSession(), userId) }; const utils::LastFmCredentials creds{ utils::getLastFmCredentials(_db.getTLSSession(), userId) };
if (creds.apiKey.empty() || creds.apiSecret.empty() || creds.sessionKey.empty()) if (creds.apiKey.empty() || creds.apiSecret.empty() || creds.sessionKey.empty())
{ {
LOG(DEBUG, "Missing Last.fm credentials for user, skipping"); LMS_LOG_LASTFM(DEBUG, "Missing Last.fm credentials for user, skipping");
continue; continue;
} }
@@ -280,7 +280,7 @@ namespace lms::scrobbling::lastFm
if (validListens.empty()) if (validListens.empty())
return; return;
LOG(DEBUG, "Sending scrobble batch of " << validListens.size() << " listens"); LMS_LOG_LASTFM(DEBUG, "Sending scrobble batch of " << validListens.size() << " listens");
params["api_key"] = creds.apiKey; params["api_key"] = creds.apiKey;
params["sk"] = creds.sessionKey; params["sk"] = creds.sessionKey;
@@ -304,7 +304,7 @@ namespace lms::scrobbling::lastFm
void ScrobblingsSynchronizer::scheduleSubmit(std::chrono::seconds fromNow) void ScrobblingsSynchronizer::scheduleSubmit(std::chrono::seconds fromNow)
{ {
LOG(DEBUG, "Scheduled pending retry in " << fromNow.count() << " seconds"); LMS_LOG_LASTFM(DEBUG, "Scheduled pending retry in " << fromNow.count() << " seconds");
_submitTimer.expires_after(fromNow); _submitTimer.expires_after(fromNow);
_submitTimer.async_wait(boost::asio::bind_executor(_strand, [this](const boost::system::error_code& ec) { _submitTimer.async_wait(boost::asio::bind_executor(_strand, [this](const boost::system::error_code& ec) {
if (ec == boost::asio::error::operation_aborted) if (ec == boost::asio::error::operation_aborted)
@@ -93,7 +93,7 @@ namespace lms::scrobbling::lastFm::utils
Wt::Json::Object root; Wt::Json::Object root;
if (!Wt::Json::parse(std::string{ msgBody }, root, error)) if (!Wt::Json::parse(std::string{ msgBody }, root, error))
{ {
LOG(ERROR, "Cannot parse auth.getToken response: " << error.what()); LMS_LOG_LASTFM(ERROR, "Cannot parse auth.getToken response: " << error.what());
return {}; return {};
} }
@@ -106,7 +106,7 @@ namespace lms::scrobbling::lastFm::utils
Wt::Json::Object root; Wt::Json::Object root;
if (!Wt::Json::parse(std::string{ msgBody }, root, error)) if (!Wt::Json::parse(std::string{ msgBody }, root, error))
{ {
LOG(ERROR, "Cannot parse auth.getSession response: " << error.what()); LMS_LOG_LASTFM(ERROR, "Cannot parse auth.getSession response: " << error.what());
return {}; return {};
} }
@@ -117,7 +117,7 @@ namespace lms::scrobbling::lastFm::utils
} }
catch (const Wt::WException& e) catch (const Wt::WException& e)
{ {
LOG(ERROR, "Cannot extract session key: " << e.what()); LMS_LOG_LASTFM(ERROR, "Cannot extract session key: " << e.what());
return {}; return {};
} }
} }
@@ -27,7 +27,7 @@
#include "database/objects/UserId.hpp" #include "database/objects/UserId.hpp"
#define LOG(sev, message) LMS_LOG(SCROBBLING, sev, "[lastfm] " << message) #define LMS_LOG_LASTFM(sev, message) LMS_LOG(SCROBBLING, sev, "[lastfm] " << message)
namespace lms::db namespace lms::db
{ {
@@ -45,7 +45,7 @@ namespace lms::scrobbling::listenBrainz
const bool res{ duration >= std::chrono::minutes(4) || (duration >= track->getDuration() / 2) }; const bool res{ duration >= std::chrono::minutes(4) || (duration >= track->getDuration() / 2) };
if (!res) if (!res)
LOG(DEBUG, "Track cannot be scrobbled since played duration is too short: " << duration.count() << "s, total duration = " << std::chrono::duration_cast<std::chrono::seconds>(track->getDuration()).count() << "s"); LMS_LOG_LISTENBRAINZ(DEBUG, "Track cannot be scrobbled since played duration is too short: " << duration.count() << "s, total duration = " << std::chrono::duration_cast<std::chrono::seconds>(track->getDuration()).count() << "s");
return res; return res;
} }
@@ -58,12 +58,12 @@ namespace lms::scrobbling::listenBrainz
, _client{ core::http::createClient(_ioContext, _baseAPIUrl) } , _client{ core::http::createClient(_ioContext, _baseAPIUrl) }
, _listensSynchronizer{ _ioContext, db, *_client } , _listensSynchronizer{ _ioContext, db, *_client }
{ {
LOG(INFO, "Starting ListenBrainz backend... API endpoint = '" << _baseAPIUrl << "'"); LMS_LOG_LISTENBRAINZ(INFO, "Starting ListenBrainz backend... API endpoint = '" << _baseAPIUrl << "'");
} }
ListenBrainzBackend::~ListenBrainzBackend() ListenBrainzBackend::~ListenBrainzBackend()
{ {
LOG(INFO, "Stopped ListenBrainz backend!"); LMS_LOG_LISTENBRAINZ(INFO, "Stopped ListenBrainz backend!");
} }
void ListenBrainzBackend::listenStarted(const Listen& listen) void ListenBrainzBackend::listenStarted(const Listen& listen)
@@ -46,7 +46,7 @@ namespace lms::scrobbling::listenBrainz
if (listenObject.type("listened_at") == Wt::Json::Type::Number) if (listenObject.type("listened_at") == Wt::Json::Type::Number)
listen.listenedAt = Wt::WDateTime::fromTime_t(static_cast<int>(listenObject.get("listened_at"))); listen.listenedAt = Wt::WDateTime::fromTime_t(static_cast<int>(listenObject.get("listened_at")));
if (!listen.listenedAt.isValid()) if (!listen.listenedAt.isValid())
LOG(ERROR, "Invalid or missing 'listened_at' field!"); LMS_LOG_LISTENBRAINZ(ERROR, "Invalid or missing 'listened_at' field!");
if (metadata.type("additional_info") == Wt::Json::Type::Object) if (metadata.type("additional_info") == Wt::Json::Type::Object)
{ {
@@ -77,7 +77,7 @@ namespace lms::scrobbling::listenBrainz
const Wt::Json::Object& payload = root.get("payload"); const Wt::Json::Object& payload = root.get("payload");
const Wt::Json::Array& listens = payload.get("listens"); const Wt::Json::Array& listens = payload.get("listens");
LOG(DEBUG, "Parsing " << listens.size() << " listens..."); LMS_LOG_LISTENBRAINZ(DEBUG, "Parsing " << listens.size() << " listens...");
result.listenCount = listens.size(); result.listenCount = listens.size();
if (listens.empty()) if (listens.empty())
@@ -92,13 +92,13 @@ namespace lms::scrobbling::listenBrainz
} }
catch (const Wt::WException& error) catch (const Wt::WException& error)
{ {
LOG(ERROR, "Cannot parse 'listen': " << error.what()); LMS_LOG_LISTENBRAINZ(ERROR, "Cannot parse 'listen': " << error.what());
} }
} }
} }
catch (const Wt::WException& error) catch (const Wt::WException& error)
{ {
LOG(ERROR, "Cannot parse 'listens': " << error.what()); LMS_LOG_LISTENBRAINZ(ERROR, "Cannot parse 'listens': " << error.what());
} }
return result; return result;
@@ -79,7 +79,7 @@ namespace lms::scrobbling::listenBrainz
const std::vector<Artist> artists{ getTrackArtists(track) }; const std::vector<Artist> artists{ getTrackArtists(track) };
if (artists.empty()) if (artists.empty())
{ {
LOG(DEBUG, "Track cannot be scrobbled since it does not have any artist"); LMS_LOG_LISTENBRAINZ(DEBUG, "Track cannot be scrobbled since it does not have any artist");
return std::nullopt; return std::nullopt;
} }
@@ -158,7 +158,7 @@ namespace lms::scrobbling::listenBrainz
} }
catch (const Wt::WException& e) catch (const Wt::WException& e)
{ {
LOG(ERROR, "Cannot parse listen count response: " << e.what()); LMS_LOG_LISTENBRAINZ(ERROR, "Cannot parse listen count response: " << e.what());
return std::nullopt; return std::nullopt;
} }
} }
@@ -176,12 +176,12 @@ namespace lms::scrobbling::listenBrainz
// if duplicated files, do not record it (let the user correct its database) // if duplicated files, do not record it (let the user correct its database)
if (tracks.size() == 1) if (tracks.size() == 1)
{ {
LOG(DEBUG, "Matched listen '" << listen << "' using track MBID"); LMS_LOG_LISTENBRAINZ(DEBUG, "Matched listen '" << listen << "' using track MBID");
return tracks.front()->getId(); return tracks.front()->getId();
} }
else if (tracks.size() > 1) else if (tracks.size() > 1)
{ {
LOG(DEBUG, "Too many matches for listen '" << listen << "' using track MBID!"); LMS_LOG_LISTENBRAINZ(DEBUG, "Too many matches for listen '" << listen << "' using track MBID!");
return {}; return {};
} }
} }
@@ -192,12 +192,12 @@ namespace lms::scrobbling::listenBrainz
// if duplicated files, do not record it (let the user correct its database) // if duplicated files, do not record it (let the user correct its database)
if (tracks.size() == 1) if (tracks.size() == 1)
{ {
LOG(DEBUG, "Matched listen '" << listen << "' using recording MBID"); LMS_LOG_LISTENBRAINZ(DEBUG, "Matched listen '" << listen << "' using recording MBID");
return tracks.front()->getId(); return tracks.front()->getId();
} }
else if (tracks.size() > 1) else if (tracks.size() > 1)
{ {
LOG(DEBUG, "Too many matches for listen '" << listen << "' using recording MBID!"); LMS_LOG_LISTENBRAINZ(DEBUG, "Too many matches for listen '" << listen << "' using recording MBID!");
return {}; return {};
} }
} }
@@ -216,16 +216,16 @@ namespace lms::scrobbling::listenBrainz
// conservative behavior: in case of multiple matches: reject // conservative behavior: in case of multiple matches: reject
if (tracks.results.size() == 1) if (tracks.results.size() == 1)
{ {
LOG(DEBUG, "Matched listen '" << listen << "' using metadata"); LMS_LOG_LISTENBRAINZ(DEBUG, "Matched listen '" << listen << "' using metadata");
return tracks.results.front(); return tracks.results.front();
} }
else if (tracks.results.size() > 1) else if (tracks.results.size() > 1)
{ {
LOG(DEBUG, "Too many matches for listen '" << listen << "' using metadata"); LMS_LOG_LISTENBRAINZ(DEBUG, "Too many matches for listen '" << listen << "' using metadata");
return {}; return {};
} }
LOG(DEBUG, "No match for listen '" << listen << "'"); LMS_LOG_LISTENBRAINZ(DEBUG, "No match for listen '" << listen << "'");
return {}; return {};
} }
} // namespace } // namespace
@@ -237,7 +237,7 @@ namespace lms::scrobbling::listenBrainz
, _maxSyncListenCount{ core::Service<core::IConfig>::get()->getULong("listenbrainz-max-sync-listen-count", 1000) } , _maxSyncListenCount{ core::Service<core::IConfig>::get()->getULong("listenbrainz-max-sync-listen-count", 1000) }
, _syncListensPeriod{ core::Service<core::IConfig>::get()->getULong("listenbrainz-sync-listens-period-hours", 1) } , _syncListensPeriod{ core::Service<core::IConfig>::get()->getULong("listenbrainz-sync-listens-period-hours", 1) }
{ {
LOG(INFO, "Starting Listens synchronizer, maxSyncListenCount = " << _maxSyncListenCount << ", _syncListensPeriod = " << _syncListensPeriod.count() << " hours"); LMS_LOG_LISTENBRAINZ(INFO, "Starting Listens synchronizer, maxSyncListenCount = " << _maxSyncListenCount << ", _syncListensPeriod = " << _syncListensPeriod.count() << " hours");
scheduleSync(std::chrono::seconds{ 30 }); scheduleSync(std::chrono::seconds{ 30 });
} }
@@ -287,14 +287,14 @@ namespace lms::scrobbling::listenBrainz
std::string bodyText{ listenToJsonString(_db.getTLSSession(), listen, timePoint, timePoint.isValid() ? "single" : "playing_now") }; std::string bodyText{ listenToJsonString(_db.getTLSSession(), listen, timePoint, timePoint.isValid() ? "single" : "playing_now") };
if (bodyText.empty()) if (bodyText.empty())
{ {
LOG(DEBUG, "Cannot convert listen to json: skipping"); LMS_LOG_LISTENBRAINZ(DEBUG, "Cannot convert listen to json: skipping");
return; return;
} }
const std::string listenBrainzToken{ utils::getListenBrainzToken(_db.getTLSSession(), listen.userId) }; const std::string listenBrainzToken{ utils::getListenBrainzToken(_db.getTLSSession(), listen.userId) };
if (listenBrainzToken.empty()) if (listenBrainzToken.empty())
{ {
LOG(DEBUG, "No listenbrainz token found: skipping"); LMS_LOG_LISTENBRAINZ(DEBUG, "No listenbrainz token found: skipping");
return; return;
} }
@@ -323,7 +323,7 @@ namespace lms::scrobbling::listenBrainz
dbListen = session.create<db::Listen>(user, track, db::ScrobblingBackend::ListenBrainz, listen.listenedAt); dbListen = session.create<db::Listen>(user, track, db::ScrobblingBackend::ListenBrainz, listen.listenedAt);
dbListen.modify()->setSyncState(scrobblingState); dbListen.modify()->setSyncState(scrobblingState);
LOG(DEBUG, "LISTEN CREATED for user " << user->getLoginName() << ", track '" << track->getName() << "' AT " << listen.listenedAt.toString()); LMS_LOG_LISTENBRAINZ(DEBUG, "LISTEN CREATED for user " << user->getLoginName() << ", track '" << track->getName() << "' AT " << listen.listenedAt.toString());
return true; return true;
} }
@@ -365,7 +365,7 @@ namespace lms::scrobbling::listenBrainz
} }
} }
LOG(DEBUG, "Queing " << pendingListens.size() << " pending listen"); LMS_LOG_LISTENBRAINZ(DEBUG, "Queing " << pendingListens.size() << " pending listen");
for (const TimedListen& pendingListen : pendingListens) for (const TimedListen& pendingListen : pendingListens)
enqueListen(pendingListen); enqueListen(pendingListen);
@@ -396,12 +396,12 @@ namespace lms::scrobbling::listenBrainz
if (_syncListensPeriod.count() == 0 || _maxSyncListenCount == 0) if (_syncListensPeriod.count() == 0 || _maxSyncListenCount == 0)
return; return;
LOG(DEBUG, "Scheduled sync in " << fromNow.count() << " seconds..."); LMS_LOG_LISTENBRAINZ(DEBUG, "Scheduled sync in " << fromNow.count() << " seconds...");
_syncTimer.expires_after(fromNow); _syncTimer.expires_after(fromNow);
_syncTimer.async_wait(boost::asio::bind_executor(_strand, [this](const boost::system::error_code& ec) { _syncTimer.async_wait(boost::asio::bind_executor(_strand, [this](const boost::system::error_code& ec) {
if (ec == boost::asio::error::operation_aborted) if (ec == boost::asio::error::operation_aborted)
{ {
LOG(DEBUG, "getListens aborted"); LMS_LOG_LISTENBRAINZ(DEBUG, "getListens aborted");
return; return;
} }
else if (ec) else if (ec)
@@ -415,7 +415,7 @@ namespace lms::scrobbling::listenBrainz
void ListensSynchronizer::startSync() void ListensSynchronizer::startSync()
{ {
LOG(DEBUG, "Starting sync!"); LMS_LOG_LISTENBRAINZ(DEBUG, "Starting sync!");
assert(!isSyncing()); assert(!isSyncing());
@@ -450,7 +450,7 @@ namespace lms::scrobbling::listenBrainz
void ListensSynchronizer::onSyncEnded(UserContext& context) void ListensSynchronizer::onSyncEnded(UserContext& context)
{ {
boost::asio::post(boost::asio::bind_executor(_strand, [this, &context] { boost::asio::post(boost::asio::bind_executor(_strand, [this, &context] {
LOG(INFO, "Sync done for user '" << context.listenBrainzUserName << "', fetched: " << context.fetchedListenCount << ", matched: " << context.matchedListenCount << ", imported: " << context.importedListenCount); LMS_LOG_LISTENBRAINZ(INFO, "Sync done for user '" << context.listenBrainzUserName << "', fetched: " << context.fetchedListenCount << ", matched: " << context.matchedListenCount << ", imported: " << context.importedListenCount);
context.syncing = false; context.syncing = false;
if (!isSyncing()) if (!isSyncing())
@@ -500,7 +500,7 @@ namespace lms::scrobbling::listenBrainz
const auto listenCount{ parseListenCount(msg.body()) }; const auto listenCount{ parseListenCount(msg.body()) };
boost::asio::post(boost::asio::bind_executor(_strand, [this, listenCount, &context] { boost::asio::post(boost::asio::bind_executor(_strand, [this, listenCount, &context] {
if (listenCount) if (listenCount)
LOG(DEBUG, "Listen count for listenbrainz user '" << context.listenBrainzUserName << "' = " << *listenCount); LMS_LOG_LISTENBRAINZ(DEBUG, "Listen count for listenbrainz user '" << context.listenBrainzUserName << "' = " << *listenCount);
bool needSync{ listenCount && (!context.listenCount || *context.listenCount != *listenCount) }; bool needSync{ listenCount && (!context.listenCount || *context.listenCount != *listenCount) };
context.listenCount = listenCount; context.listenCount = listenCount;
@@ -559,7 +559,7 @@ namespace lms::scrobbling::listenBrainz
// update oldest listen for the next query // update oldest listen for the next query
if (!parsedListen.listenedAt.isValid()) if (!parsedListen.listenedAt.isValid())
{ {
LOG(DEBUG, "Skipping entry due to invalid listenedAt"); LMS_LOG_LISTENBRAINZ(DEBUG, "Skipping entry due to invalid listenedAt");
continue; continue;
} }
@@ -49,13 +49,13 @@ namespace lms::scrobbling::listenBrainz::utils
Wt::Json::Object root; Wt::Json::Object root;
if (!Wt::Json::parse(std::string{ msgBody }, root, error)) if (!Wt::Json::parse(std::string{ msgBody }, root, error))
{ {
LOG(ERROR, "Cannot parse 'validate-token' result: " << error.what()); LMS_LOG_LISTENBRAINZ(ERROR, "Cannot parse 'validate-token' result: " << error.what());
return listenBrainzUserName; return listenBrainzUserName;
} }
if (!root.get("valid").orIfNull(false)) if (!root.get("valid").orIfNull(false))
{ {
LOG(INFO, "Invalid listenbrainz user"); LMS_LOG_LISTENBRAINZ(INFO, "Invalid listenbrainz user");
return listenBrainzUserName; return listenBrainzUserName;
} }
@@ -23,7 +23,7 @@
#include "database/objects/UserId.hpp" #include "database/objects/UserId.hpp"
#define LOG(sev, message) LMS_LOG(SCROBBLING, sev, "[listenbrainz] " << message) #define LMS_LOG_LISTENBRAINZ(sev, message) LMS_LOG(SCROBBLING, sev, "[listenbrainz] " << message)
namespace lms::db namespace lms::db
{ {