mirror of
https://github.com/Dvorinka/swingmusic-extended.git
synced 2026-06-03 20:13:02 +00:00
Restyled by yapf
This commit is contained in:
committed by
Mungai Geoffrey
parent
dc683e6314
commit
bb69ac1fc1
@@ -16,8 +16,7 @@ def send_track_file(trackid):
|
||||
"""
|
||||
try:
|
||||
filepath = [
|
||||
file["filepath"]
|
||||
for file in api.PRE_TRACKS
|
||||
file["filepath"] for file in api.PRE_TRACKS
|
||||
if file["_id"]["$oid"] == trackid
|
||||
][0]
|
||||
except (FileNotFoundError, IndexError):
|
||||
@@ -32,4 +31,5 @@ def get_sample_track():
|
||||
Returns a sample track object.
|
||||
"""
|
||||
|
||||
return instances.songs_instance.get_song_by_album("Legends Never Die", "Juice WRLD")
|
||||
return instances.songs_instance.get_song_by_album("Legends Never Die",
|
||||
"Juice WRLD")
|
||||
|
||||
+9
-13
@@ -29,7 +29,6 @@ from progress.bar import Bar
|
||||
# from pprint import pprint
|
||||
|
||||
|
||||
|
||||
@helpers.background
|
||||
def reindex_tracks():
|
||||
"""
|
||||
@@ -62,7 +61,8 @@ def populate():
|
||||
"""
|
||||
start = time.time()
|
||||
|
||||
s, files = helpers.run_fast_scandir(settings.HOME_DIR, [".flac", ".mp3"], full=True)
|
||||
s, files = helpers.run_fast_scandir(settings.HOME_DIR, [".flac", ".mp3"],
|
||||
full=True)
|
||||
|
||||
_bar = Bar("Processing files", max=len(files))
|
||||
|
||||
@@ -86,11 +86,8 @@ def populate():
|
||||
end = time.time()
|
||||
|
||||
print(
|
||||
str(datetime.timedelta(seconds=round(end - start)))
|
||||
+ " elapsed for "
|
||||
+ str(len(files))
|
||||
+ " files"
|
||||
)
|
||||
str(datetime.timedelta(seconds=round(end - start))) + " elapsed for " +
|
||||
str(len(files)) + " files")
|
||||
|
||||
|
||||
def fetch_image_path(artist: str) -> str or None:
|
||||
@@ -125,9 +122,8 @@ def populate_images():
|
||||
|
||||
_bar = Bar("Processing images", max=len(artists))
|
||||
for artist in artists:
|
||||
file_path = (
|
||||
helpers.app_dir + "/images/artists/" + artist.replace("/", "::") + ".webp"
|
||||
)
|
||||
file_path = (helpers.app_dir + "/images/artists/" +
|
||||
artist.replace("/", "::") + ".webp")
|
||||
|
||||
if not os.path.exists(file_path):
|
||||
img_path = fetch_image_path(artist)
|
||||
@@ -358,8 +354,7 @@ def get_album_bio(title: str, albumartist: str):
|
||||
Returns the album bio for a given album.
|
||||
"""
|
||||
last_fm_url = "http://ws.audioscrobbler.com/2.0/?method=album.getinfo&api_key={}&artist={}&album={}&format=json".format(
|
||||
settings.LAST_FM_API_KEY, albumartist, title
|
||||
)
|
||||
settings.LAST_FM_API_KEY, albumartist, title)
|
||||
|
||||
try:
|
||||
response = requests.get(last_fm_url)
|
||||
@@ -368,7 +363,8 @@ def get_album_bio(title: str, albumartist: str):
|
||||
return None
|
||||
|
||||
try:
|
||||
bio = data["album"]["wiki"]["summary"].split('<a href="https://www.last.fm/')[0]
|
||||
bio = data["album"]["wiki"]["summary"].split(
|
||||
'<a href="https://www.last.fm/')[0]
|
||||
except KeyError:
|
||||
bio = None
|
||||
|
||||
|
||||
@@ -46,7 +46,8 @@ def get_album_image(album: list) -> str:
|
||||
"""
|
||||
|
||||
for track in album:
|
||||
img_p = (track["album"] + track["albumartist"] + ".webp").replace("/", "::")
|
||||
img_p = (track["album"] + track["albumartist"] + ".webp").replace(
|
||||
"/", "::")
|
||||
img = functions.extract_thumb(track["filepath"], webp_path=img_p)
|
||||
|
||||
if img is not None:
|
||||
@@ -84,8 +85,7 @@ def create_album(track) -> models.Album:
|
||||
album["date"] = album_tracks[0]["date"]
|
||||
|
||||
album["artistimage"] = urllib.parse.quote_plus(
|
||||
album_tracks[0]["albumartist"] + ".webp"
|
||||
)
|
||||
album_tracks[0]["albumartist"] + ".webp")
|
||||
|
||||
album["image"] = get_album_image(album_tracks)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user