Listening stats: Last.fm user.* methods and /api/v1/me
CI / lint (push) Successful in 12s
CI / test (push) Successful in 30s
CI / notify (push) Successful in 5s

- Stats service shared by both APIs: recent scrobbles, top artists,
  albums and tracks over Last.fm periods, per-day/week/month counts
  (with empty days filled) and totals
- Case-insensitive grouping that displays the most common spelling
- user.getInfo, user.getRecentTracks (now playing first, from/to),
  user.getTopArtists/Albums/Tracks with Last.fm paging attributes
- /api/v1/me: now-playing, recent, top/{artists,albums,tracks},
  counts and summary

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MK52BGoJbPhZ1vSFuKcGUW
This commit is contained in:
mattandClaude Opus 5.5 committed 2026-09-25 14:05:20 +01:00
1 parent 2702815a1e
commit 0d49311848
7 files changed
+769 -2

No files matched your search

+76
View File
@@ -67,3 +67,79 @@ class AuthTokenInfoSchema(Schema):
class ApproveTokenSchema(Schema):
token = fields.String(required=True, metadata={"description": "Token from auth.getToken"})
PERIODS = ["overall", "7day", "1month", "3month", "6month", "12month"]
class PageArgsSchema(Schema):
page = fields.Integer(load_default=1, validate=validate.Range(min=1))
limit = fields.Integer(load_default=50, validate=validate.Range(min=1, max=200))
class TopArgsSchema(PageArgsSchema):
period = fields.String(load_default="7day", validate=validate.OneOf(PERIODS))
class CountsArgsSchema(Schema):
period = fields.String(load_default="1month", validate=validate.OneOf(PERIODS))
bucket = fields.String(load_default="day", validate=validate.OneOf(["day", "week", "month"]))
class PageMetaSchema(Schema):
page = fields.Integer()
per_page = fields.Integer()
total = fields.Integer()
total_pages = fields.Integer()
class ScrobbleSchema(Schema):
artist = fields.String()
track = fields.String()
album = fields.String(allow_none=True)
album_artist = fields.String(allow_none=True)
duration = fields.Integer(allow_none=True)
played_at = fields.DateTime()
class RecentPageSchema(PageMetaSchema):
items = fields.List(fields.Nested(ScrobbleSchema))
class NowPlayingTrackSchema(Schema):
artist = fields.String()
track = fields.String()
album = fields.String(allow_none=True)
duration = fields.Integer(allow_none=True)
started_at = fields.DateTime()
expires_at = fields.DateTime()
class NowPlayingSchema(Schema):
now_playing = fields.Nested(
NowPlayingTrackSchema, allow_none=True, metadata={"description": "null when idle"}
)
class TopItemSchema(Schema):
rank = fields.Integer()
name = fields.String()
artist = fields.String(allow_none=True, metadata={"description": "Albums and tracks only"})
playcount = fields.Integer()
class TopPageSchema(PageMetaSchema):
period = fields.String()
items = fields.List(fields.Nested(TopItemSchema))
class CountSchema(Schema):
start = fields.Date(metadata={"description": "First day of the bucket (UTC)"})
count = fields.Integer()
class SummarySchema(Schema):
scrobbles = fields.Integer()
artists = fields.Integer()
tracks = fields.Integer()
first_scrobble_at = fields.DateTime(allow_none=True)