Skip to content

Commit

Permalink
Use client tstamp or server time
Browse files Browse the repository at this point in the history
  • Loading branch information
redshodan committed Dec 25, 2018
1 parent 2664a14 commit 3becb97
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
14 changes: 14 additions & 0 deletions test/tests/rest/testscrobble.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,21 @@
import time

from unsonic.views.rest.scrobble import Scrobble
from . import buildCmd, checkResp


def testScrobble(session):
cmd = buildCmd(session, Scrobble, {"id": "tr-1"})
checkResp(cmd.req, cmd())


def testScrobbleSubmission(session):
cmd = buildCmd(session, Scrobble,
{"id": "tr-1", "time": str(int(time.time()) * 1000),
"submission":"True"})
checkResp(cmd.req, cmd())


def testScrobbleSubmissionNoTime(session):
cmd = buildCmd(session, Scrobble, {"id": "tr-1", "submission":"True"})
checkResp(cmd.req, cmd())
5 changes: 3 additions & 2 deletions unsonic/views/rest/scrobble.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,9 @@ def handleReq(self, session):
if lastfm.is_user:
log.info(
f"last.fm scrobbling: {track.artist} - {track.title}")
lastfm.scrobble(track.artist.name, track.title,
int(time.time()),
tstamp = self.params["time"]
tstamp = tstamp / 1000 if stamp else int(time.time())
lastfm.scrobble(track.artist.name, track.title, tstamp,
album=track.album.title,
album_artist=track.album.artist.name,
track_number=track.track_num,
Expand Down

0 comments on commit 3becb97

Please sign in to comment.