server: add get album bio from last fm function

- co-written by Github Copilot
This commit is contained in:
geoffrey45
2022-01-17 12:32:27 +03:00
parent a720891c20
commit 2ee8d27bf0
20 changed files with 370 additions and 446 deletions
+14 -15
View File
@@ -5,18 +5,19 @@ from app import functions, instances, helpers, cache
bp = Blueprint('api', __name__, url_prefix='')
all_the_f_music = []
home_dir = helpers.home_dir
all_the_f_music = helpers.getAllSongs()
def initialize() -> None:
helpers.create_config_dir()
helpers.check_for_new_songs()
initialize()
@bp.route('/')
def adutsfsd():
return "^ _ ^"
@@ -79,7 +80,7 @@ def x():
def get_album_artists(album, artist):
album = album.replace('|', '/')
artist = artist.replace('|', '/')
tracks = []
for track in all_the_f_music:
@@ -161,7 +162,7 @@ def getArtistData(artist: str):
@bp.route("/f/<folder>")
@cache.cached()
def getFolderTree(folder: str = None):
def getFolderTree(folder: str):
req_dir = folder.replace('|', '/')
if folder == "home":
@@ -180,21 +181,11 @@ def getFolderTree(folder: str = None):
dir = {
"name": entry.name,
"count": len(files_in_dir),
"path": entry.path.replace(home_dir, "")
"path": entry.path.replace(home_dir, ""),
}
folders.append(dir)
# if entry.is_file():
# if isValidFile(entry.name) == True:
# file = instances.songs_instance.find_song_by_path(entry.path)
# if not file:
# getTags(entry.path)
# songs_array = instances.songs_instance.find_songs_by_folder(
# req_dir)
songs = []
for x in all_the_f_music:
@@ -203,6 +194,7 @@ def getFolderTree(folder: str = None):
return {"files": helpers.remove_duplicates(songs), "folders": sorted(folders, key=lambda i: i['name'])}
@bp.route('/qwerty')
def populateArtists():
all_songs = instances.songs_instance.get_all_songs()
@@ -222,6 +214,7 @@ def populateArtists():
return {'songs': artists}
@bp.route('/albums')
def getAlbums():
s = instances.songs_instance.get_all_songs()
@@ -239,6 +232,7 @@ def getAlbums():
return {'albums': albums}
@bp.route('/albums/<query>')
@cache.cached()
def getAlbumSongs(query: str):
@@ -260,3 +254,8 @@ def getAlbumSongs(query: str):
}
return {'songs': helpers.remove_duplicates(songs), 'info': album_obj}
@bp.route('/album/<title>/<artist>/bio')
def drop_db(title, artist):
return functions.getAlbumBio(title, artist)