start migration to <script setup>

This commit is contained in:
geoffrey45
2022-01-26 10:01:35 +03:00
parent d6204946c2
commit 13ee2ed1d6
14 changed files with 91 additions and 73 deletions
+7 -24
View File
@@ -70,7 +70,7 @@ def search_by_title():
artist_obj = {
"name": artist,
"image": "http://0.0.0.0:8900/images/artists/webp/" + artist.replace("/", "::") + ".webp"
"image": "http://0.0.0.0:8900/images/artists/" + artist.replace("/", "::") + ".webp"
}
if artist_obj not in artists_dicts:
@@ -129,7 +129,7 @@ def get_album_artists(album, artist):
for artist in artists:
artist_obj = {
"name": artist,
"image": "http://0.0.0.0:8900/images/artists/webp/" + artist.replace('/', '::') + ".webp"
"image": "http://0.0.0.0:8900/images/artists/" + artist.replace('/', '::') + ".webp"
}
final_artists.append(artist_obj)
@@ -252,7 +252,7 @@ def getAlbumSongs(query: str):
songs = []
for track in all_the_f_music:
if track['album'] == album and track['album_artist'] == artist:
if track.album == album and track.album_artist == artist:
songs.append(track)
songs = helpers.remove_duplicates(songs)
@@ -260,10 +260,10 @@ def getAlbumSongs(query: str):
album_obj = {
"name": album,
"count": len(songs),
"duration": sum(song['length'] for song in songs),
"image": songs[0]['image'],
"artist": songs[0]['album_artist'],
"artist_image": "http://127.0.0.1:8900/images/artists/webp/" + songs[0]['album_artist'].replace('/', '::') + ".webp"
"duration": "56 Minutes",
"image": songs[0].image,
"artist": songs[0].album_artist,
"artist_image": "http://127.0.0.1:8900/images/artists/" + songs[0].album_artist.replace('/', '::') + ".webp"
}
return {'songs': songs, 'info': album_obj}
@@ -275,20 +275,3 @@ def drop_db(title, artist):
bio = functions.getAlbumBio(title, artist)
return {'bio': bio}, 200
@bp.route('/convert')
def convert_images_to_webp():
path = os.path.join(home_dir, helpers.app_dir, 'images', 'artists')
final_path = os.path.join(
home_dir, helpers.app_dir, 'images', 'artists', 'webp')
for file in os.scandir(path):
if file.name.endswith(".jpg"):
print(file.name)
print(os.path.join(final_path, file.name.replace('.jpg', '.webp')))
img = helpers.Image.open(os.path.join(path, file.name)).resize(
(150, 150), helpers.Image.ANTIALIAS)
img.save(os.path.join(final_path, file.name.replace(
'.jpg', '.webp')), format='webp')
return "Done"
+2 -2
View File
@@ -122,12 +122,12 @@ def extract_thumb(audio_file_path: str = None) -> str:
img = Image.open(BytesIO(album_art))
try:
small_img = img.resize((150, 150), Image.ANTIALIAS)
small_img = img.resize((250, 250), Image.ANTIALIAS)
small_img.save(img_path, format="webp")
except OSError:
try:
png = img.convert('RGB')
small_img = png.resize((150, 150), Image.ANTIALIAS)
small_img = png.resize((250, 250), Image.ANTIALIAS)
small_img.save(img_path, format="webp")
except:
return use_defaults()