mirror of
https://github.com/krateng/maloja.git
synced 2025-07-09 03:04:07 -04:00
Fix casting
This commit is contained in:
parent
152e3948a1
commit
2c2d13e39c
@ -246,7 +246,7 @@ class ScrobbleDict(TypedDict):
|
|||||||
def scrobbles_db_to_dict(rows, include_internal=False, dbconn=None) -> list[ScrobbleDict]:
|
def scrobbles_db_to_dict(rows, include_internal=False, dbconn=None) -> list[ScrobbleDict]:
|
||||||
tracks: list[TrackDict] = get_tracks_map(set(row.track_id for row in rows), dbconn=dbconn)
|
tracks: list[TrackDict] = get_tracks_map(set(row.track_id for row in rows), dbconn=dbconn)
|
||||||
return [
|
return [
|
||||||
cast({
|
cast(ScrobbleDict, {
|
||||||
**{
|
**{
|
||||||
"time": row.timestamp,
|
"time": row.timestamp,
|
||||||
"track": tracks[row.track_id],
|
"track": tracks[row.track_id],
|
||||||
@ -257,7 +257,7 @@ def scrobbles_db_to_dict(rows, include_internal=False, dbconn=None) -> list[Scro
|
|||||||
"extra": json.loads(row.extra or '{}'),
|
"extra": json.loads(row.extra or '{}'),
|
||||||
"rawscrobble": json.loads(row.rawscrobble or '{}')
|
"rawscrobble": json.loads(row.rawscrobble or '{}')
|
||||||
} if include_internal else {})
|
} if include_internal else {})
|
||||||
}, ScrobbleDict)
|
})
|
||||||
|
|
||||||
for row in rows
|
for row in rows
|
||||||
]
|
]
|
||||||
@ -271,12 +271,12 @@ def tracks_db_to_dict(rows, dbconn=None) -> list[TrackDict]:
|
|||||||
artists = get_artists_of_tracks(set(row.id for row in rows), dbconn=dbconn)
|
artists = get_artists_of_tracks(set(row.id for row in rows), dbconn=dbconn)
|
||||||
albums = get_albums_map(set(row.album_id for row in rows), dbconn=dbconn)
|
albums = get_albums_map(set(row.album_id for row in rows), dbconn=dbconn)
|
||||||
return [
|
return [
|
||||||
cast({
|
cast(TrackDict, {
|
||||||
"artists":artists[row.id],
|
"artists":artists[row.id],
|
||||||
"title":row.title,
|
"title":row.title,
|
||||||
"album":albums.get(row.album_id),
|
"album":albums.get(row.album_id),
|
||||||
"length":row.length
|
"length":row.length
|
||||||
}, TrackDict)
|
})
|
||||||
for row in rows
|
for row in rows
|
||||||
]
|
]
|
||||||
|
|
||||||
@ -299,10 +299,10 @@ def artist_db_to_dict(row, dbconn=None) -> str:
|
|||||||
def albums_db_to_dict(rows, dbconn=None) -> list[AlbumDict]:
|
def albums_db_to_dict(rows, dbconn=None) -> list[AlbumDict]:
|
||||||
artists = get_artists_of_albums(set(row.id for row in rows), dbconn=dbconn)
|
artists = get_artists_of_albums(set(row.id for row in rows), dbconn=dbconn)
|
||||||
return [
|
return [
|
||||||
cast({
|
cast(AlbumDict, {
|
||||||
"artists": artists.get(row.id),
|
"artists": artists.get(row.id),
|
||||||
"albumtitle": row.albtitle,
|
"albumtitle": row.albtitle,
|
||||||
}, AlbumDict)
|
})
|
||||||
for row in rows
|
for row in rows
|
||||||
]
|
]
|
||||||
|
|
||||||
@ -1002,7 +1002,6 @@ def get_scrobbles(since=None,to=None,resolve_references=True,limit=None,reverse=
|
|||||||
result = scrobbles_db_to_dict(result,dbconn=dbconn)
|
result = scrobbles_db_to_dict(result,dbconn=dbconn)
|
||||||
#result = [scrobble_db_to_dict(row,resolve_references=resolve_references) for i,row in enumerate(result) if i<max]
|
#result = [scrobble_db_to_dict(row,resolve_references=resolve_references) for i,row in enumerate(result) if i<max]
|
||||||
|
|
||||||
|
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user