Fixed subsonic scrobble command + internal scrobbler: do not record listen that have been played for less than 5s
This commit is contained in:
@@ -43,7 +43,7 @@ namespace Scrobbling
|
||||
virtual ~IScrobbler() = default;
|
||||
|
||||
virtual void listenStarted(const Listen& listen) = 0;
|
||||
virtual void listenFinished(const Listen& listen, std::chrono::seconds duration) = 0;
|
||||
virtual void listenFinished(const Listen& listen, std::optional<std::chrono::seconds> duration) = 0;
|
||||
|
||||
virtual void addListen(const Listen& listen, const Wt::WDateTime& timePoint) = 0;
|
||||
|
||||
|
||||
@@ -50,7 +50,7 @@ namespace Scrobbling
|
||||
}
|
||||
|
||||
void
|
||||
Scrobbling::listenFinished(const Listen& listen, std::chrono::seconds duration)
|
||||
Scrobbling::listenFinished(const Listen& listen, std::optional<std::chrono::seconds> duration)
|
||||
{
|
||||
if (auto scrobbler {getUserScrobbler(listen.userId)})
|
||||
_scrobblers[*scrobbler]->listenFinished(listen, duration);
|
||||
|
||||
@@ -35,7 +35,7 @@ namespace Scrobbling
|
||||
|
||||
private:
|
||||
void listenStarted(const Listen& listen) override;
|
||||
void listenFinished(const Listen& listen, std::chrono::seconds duration) override;
|
||||
void listenFinished(const Listen& listen, std::optional<std::chrono::seconds> duration) override;
|
||||
void addListen(const Listen& listen, Wt::WDateTime timePoint) override;
|
||||
|
||||
std::vector<Wt::Dbo::ptr<Database::Artist>> getRecentArtists(Database::Session& session,
|
||||
|
||||
@@ -35,15 +35,19 @@ namespace Scrobbling
|
||||
{}
|
||||
|
||||
void
|
||||
InternalScrobbler::listenStarted(const Listen& listen)
|
||||
InternalScrobbler::listenStarted(const Listen& /*listen*/)
|
||||
{
|
||||
addListen(listen, Wt::WDateTime::currentDateTime());
|
||||
// nothing to do
|
||||
}
|
||||
|
||||
void
|
||||
InternalScrobbler::listenFinished(const Listen& /*event*/, std::chrono::seconds /* duration */)
|
||||
InternalScrobbler::listenFinished(const Listen& listen, std::optional<std::chrono::seconds> duration)
|
||||
{
|
||||
// nothing to do
|
||||
// record tracks that have been played for at least of few seconds...
|
||||
if (duration && *duration < std::chrono::seconds {5})
|
||||
return;
|
||||
|
||||
addListen(listen, Wt::WDateTime::currentDateTime());
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
@@ -30,7 +30,7 @@ namespace Scrobbling
|
||||
|
||||
private:
|
||||
void listenStarted(const Listen& listen) override;
|
||||
void listenFinished(const Listen& listen, std::chrono::seconds duration) override;
|
||||
void listenFinished(const Listen& listen, std::optional<std::chrono::seconds> duration) override;
|
||||
|
||||
void addListen(const Listen& listen, const Wt::WDateTime& timePoint) override;
|
||||
|
||||
|
||||
@@ -214,13 +214,13 @@ namespace Scrobbling
|
||||
}
|
||||
|
||||
void
|
||||
ListenBrainzScrobbler::listenFinished(const Listen& listen, std::chrono::seconds duration)
|
||||
ListenBrainzScrobbler::listenFinished(const Listen& listen, std::optional<std::chrono::seconds> duration)
|
||||
{
|
||||
if (!canBeScrobbled(_db.getTLSSession(), listen.trackId, duration))
|
||||
if (duration && !canBeScrobbled(_db.getTLSSession(), listen.trackId, *duration))
|
||||
return;
|
||||
|
||||
Listen timedListen {listen};
|
||||
const Wt::WDateTime now {Wt::WDateTime::currentDateTime().addSecs(-duration.count())};
|
||||
const Wt::WDateTime now {Wt::WDateTime::currentDateTime()};
|
||||
|
||||
_ioService.post([=]
|
||||
{
|
||||
|
||||
@@ -50,7 +50,7 @@ namespace Scrobbling
|
||||
|
||||
private:
|
||||
void listenStarted(const Listen& listen) override;
|
||||
void listenFinished(const Listen& listen, std::chrono::seconds duration) override;
|
||||
void listenFinished(const Listen& listen, std::optional<std::chrono::seconds> duration) override;
|
||||
void addListen(const Listen& listen, const Wt::WDateTime& timePoint) override;
|
||||
|
||||
Wt::Dbo::ptr<Database::TrackList> getListensTrackList(Database::Session& session, Wt::Dbo::ptr<Database::User> user) override;
|
||||
|
||||
@@ -49,7 +49,7 @@ namespace Scrobbling
|
||||
|
||||
// Scrobbling
|
||||
virtual void listenStarted(const Listen& listen) = 0;
|
||||
virtual void listenFinished(const Listen& listen, std::chrono::seconds duration) = 0;
|
||||
virtual void listenFinished(const Listen& listen, std::optional<std::chrono::seconds> playedDuration = std::nullopt) = 0;
|
||||
|
||||
virtual void addListen(const Listen& listen, Wt::WDateTime timePoint) = 0;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user