mirror of
https://github.com/Dvorinka/swingmusic-extended.git
synced 2026-06-05 04:53:01 +00:00
fix: building distributable
This commit is contained in:
+3
-2
@@ -5,11 +5,12 @@ All playlist-related routes.
|
||||
import json
|
||||
from datetime import datetime
|
||||
import pathlib
|
||||
from typing import Any
|
||||
|
||||
from PIL import UnidentifiedImageError, Image
|
||||
from pydantic import BaseModel, Field
|
||||
from flask_openapi3 import Tag
|
||||
from flask_openapi3 import APIBlueprint, FileStorage
|
||||
from flask_openapi3 import APIBlueprint
|
||||
|
||||
from app import models
|
||||
from app.api.apischemas import GenericLimitSchema
|
||||
@@ -251,7 +252,7 @@ def get_playlist(path: PlaylistIDPath, query: GetPlaylistQuery):
|
||||
|
||||
|
||||
class UpdatePlaylistForm(BaseModel):
|
||||
image: FileStorage = Field(None, description="The image file")
|
||||
image: Any = Field(..., description="The image file")
|
||||
name: str = Field(..., description="The name of the playlist")
|
||||
settings: str = Field(
|
||||
...,
|
||||
|
||||
@@ -72,7 +72,6 @@ class LastFmPlugin(Plugin):
|
||||
@plugin_method
|
||||
@background
|
||||
def scrobble(self, track: Track, timestamp: int):
|
||||
log.info(f"Last.fm: logging track: {track.title} - {track.artists[0]['name']}")
|
||||
data = {
|
||||
"method": "track.scrobble",
|
||||
"artist": track.artists[0]["name"],
|
||||
@@ -96,17 +95,12 @@ class LastFmPlugin(Plugin):
|
||||
Uploads the scrobble data and handles the
|
||||
response from the lastfm scrobble endpoint.
|
||||
"""
|
||||
log.info(f"scrobble data: {data}")
|
||||
|
||||
try:
|
||||
res = self.post(data)
|
||||
except Exception as e:
|
||||
log.warn("scrobble response error" + str(e))
|
||||
return False
|
||||
|
||||
log.info("scrobble response text: " + str(res.text))
|
||||
log.info("scrobble response json: " + str(res.json()))
|
||||
|
||||
res_json: dict[str, Any] = res.json()
|
||||
|
||||
if res_json.get("error"):
|
||||
@@ -120,7 +114,6 @@ class LastFmPlugin(Plugin):
|
||||
return False
|
||||
|
||||
if res_json.get("scrobbles", {}).get("@attr", {}).get("accepted") == 1:
|
||||
log.info("scrobble accepted")
|
||||
return True
|
||||
|
||||
return False
|
||||
@@ -136,7 +129,6 @@ class LastFmPlugin(Plugin):
|
||||
|
||||
path = dump_dir / f"{int(time.time())}.json"
|
||||
|
||||
log.info(f"Dumping scrobble to {path}")
|
||||
with open(path, "w") as f:
|
||||
json.dump(data, f)
|
||||
|
||||
@@ -155,7 +147,6 @@ class LastFmPlugin(Plugin):
|
||||
|
||||
try:
|
||||
for file in dump_dir.iterdir():
|
||||
log.info(f"Uploading dump: {file}")
|
||||
with open(file, "r") as f:
|
||||
data = json.load(f)
|
||||
success = self.post_scrobble_data(data)
|
||||
|
||||
Reference in New Issue
Block a user