Skip to content

Commit

Permalink
Adding playCount's
Browse files Browse the repository at this point in the history
  • Loading branch information
redshodan committed Dec 30, 2018
1 parent 6874a44 commit 7533e47
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 8 deletions.
7 changes: 0 additions & 7 deletions TODO.rst
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,6 @@ Partial
<shortcut id="11" name="Audio books"/>
<shortcut id="10" name="Podcasts"/>

- getArtist:
resp:
- handle playCount for album

- getAlbumList:
resp:
- missing averageRating for album
Expand All @@ -101,6 +97,3 @@ Partial

- getCoverArt:
params: missing size to convert image to

- getGenres:
resp: Needs album counts
6 changes: 5 additions & 1 deletion unsonic/views/rest/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
from ...version import PROTOCOL_VERSION, UNSONIC_PROTOCOL_VERSION
from ...models import (Session, ArtistRating, AlbumRating, TrackRating,
Artist, Album, Track, PlayList, Share, Bookmark,
InternetRadio, Image, Library)
InternetRadio, Image, Library, PlayCount)
from ...auth import Roles
from ... import lastfm

Expand Down Expand Up @@ -659,6 +659,10 @@ def fillTrackUser(session, song_row, rating_row, user, name="song"):
TrackRating.user_id == user.id).one_or_none()
if rating_row and rating_row.starred:
song.set("starred", rating_row.starred.isoformat())
pcount = session.query(PlayCount). \
filter(PlayCount.track_id == song_row.id,
PlayCount.user_id == user.id).one_or_none()
song.set("playCount", str(pcount.count) if pcount else "0")
return song


Expand Down

0 comments on commit 7533e47

Please sign in to comment.