Illustrate monthly reports and add viewing pattern breakdowns
This commit is contained in:
@@ -35,16 +35,19 @@ def signature(user, runtime, media_id, expires):
|
||||
|
||||
def with_artwork(data, user, runtime):
|
||||
expires = int(time.time()) + TOKEN_SECONDS
|
||||
recent = []
|
||||
for play in data.get("recent", []):
|
||||
row = {**play}
|
||||
media_id = row.pop("artwork_item_id", None)
|
||||
row["artwork_url"] = None
|
||||
if item_id(media_id) and settings.jwt_secret and runtime.jellyfin_base_url and runtime.jellyfin_api_key:
|
||||
token = f"{expires}.{signature(user, runtime, media_id, expires)}"
|
||||
row["artwork_url"] = f"/insights/artwork/{media_id}?token={token}"
|
||||
recent.append(row)
|
||||
return {**data, "recent": recent}
|
||||
result = {**data}
|
||||
for field in ("recent", "top_titles"):
|
||||
rows = []
|
||||
for play in data.get(field, []):
|
||||
row = {**play}
|
||||
media_id = row.pop("artwork_item_id", None)
|
||||
row["artwork_url"] = None
|
||||
if item_id(media_id) and settings.jwt_secret and runtime.jellyfin_base_url and runtime.jellyfin_api_key:
|
||||
token = f"{expires}.{signature(user, runtime, media_id, expires)}"
|
||||
row["artwork_url"] = f"/insights/artwork/{media_id}?token={token}"
|
||||
rows.append(row)
|
||||
result[field] = rows
|
||||
return result
|
||||
|
||||
|
||||
def verify_artwork_token(user, runtime, media_id, token):
|
||||
|
||||
Reference in New Issue
Block a user