mirror of
https://github.com/Dvorinka/swingmusic-extended.git
synced 2026-06-04 20:43:04 +00:00
remove telemetry
+ add docstrings to lyrics functions
This commit is contained in:
+1
-16
@@ -1,8 +1,8 @@
|
||||
"""
|
||||
Contains all the artist(s) routes.
|
||||
"""
|
||||
import random
|
||||
import math
|
||||
import random
|
||||
from datetime import datetime
|
||||
|
||||
from flask import Blueprint, request
|
||||
@@ -15,29 +15,15 @@ from app.serializers.track import serialize_tracks
|
||||
from app.store.albums import AlbumStore
|
||||
from app.store.artists import ArtistStore
|
||||
from app.store.tracks import TrackStore
|
||||
from app.telemetry import Telemetry
|
||||
from app.utils.threading import background
|
||||
|
||||
api = Blueprint("artist", __name__, url_prefix="/")
|
||||
|
||||
ARTIST_VISIT_COUNT = 0
|
||||
|
||||
|
||||
@background
|
||||
def send_event():
|
||||
global ARTIST_VISIT_COUNT
|
||||
ARTIST_VISIT_COUNT += 1
|
||||
|
||||
if ARTIST_VISIT_COUNT % 5 == 0:
|
||||
Telemetry.send_artist_visited()
|
||||
|
||||
|
||||
@api.route("/artist/<artisthash>", methods=["GET"])
|
||||
def get_artist(artisthash: str):
|
||||
"""
|
||||
Get artist data.
|
||||
"""
|
||||
send_event()
|
||||
limit = request.args.get("limit")
|
||||
|
||||
if limit is None:
|
||||
@@ -211,7 +197,6 @@ def get_similar_artists(artisthash: str):
|
||||
if artist is None:
|
||||
return {"error": "Artist not found"}, 404
|
||||
|
||||
# result = LastFMStore.get_similar_artists_for(artist.artisthash)
|
||||
result = fmdb.get_similar_artists_for(artist.artisthash)
|
||||
|
||||
if result is None:
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
from flask import Blueprint, request
|
||||
from app.lib.lyrics import format_synced_lyrics
|
||||
|
||||
from app.plugins.lyrics import Lyrics
|
||||
from app.utils.hashing import create_hash
|
||||
@@ -10,6 +11,7 @@ api = Blueprint("lyricsplugin", __name__, url_prefix="/plugins/lyrics")
|
||||
def search_lyrics():
|
||||
data = request.get_json()
|
||||
|
||||
trackhash = data.get("trackhash", "")
|
||||
title = data.get("title", "")
|
||||
artist = data.get("artist", "")
|
||||
album = data.get("album", "")
|
||||
@@ -20,7 +22,7 @@ def search_lyrics():
|
||||
data = finder.search_lyrics_by_title_and_artist(title, artist)
|
||||
|
||||
if not data:
|
||||
return {"downloaded": False}
|
||||
return {"trackhash": trackhash, "lyrics": None}
|
||||
|
||||
perfect_match = data[0]
|
||||
|
||||
@@ -34,6 +36,12 @@ def search_lyrics():
|
||||
perfect_match = track
|
||||
|
||||
track_id = perfect_match["track_id"]
|
||||
downloaded = finder.download_lyrics(track_id, filepath)
|
||||
lrc = finder.download_lyrics(track_id, filepath)
|
||||
|
||||
return {"downloaded": downloaded}, 200
|
||||
if lrc is not None:
|
||||
lines = lrc.split("\n")
|
||||
lyrics = format_synced_lyrics(lines)
|
||||
|
||||
return {"trackhash": trackhash, "lyrics": lyrics}, 200
|
||||
|
||||
return {"trackhash": trackhash, "lyrics": lrc}, 200
|
||||
|
||||
Reference in New Issue
Block a user