diff --git a/server/app/api.py b/server/app/api.py index 5ff25980..c6ad1a6d 100644 --- a/server/app/api.py +++ b/server/app/api.py @@ -32,35 +32,36 @@ def search_by_title(): albums = [] artists = [] + tracks = [] - s = [] + albums_dicts = [] + artists_dicts = [] for track in all_the_f_music: if query.lower() in track['title'].lower(): - s.append(track) - - al = instances.songs_instance.search_songs_by_album(query) - ar = instances.songs_instance.search_songs_by_artist(query) + tracks.append(track) - for song in al: + if query.lower() in track['album'].lower(): + albums.append(track) + + if query.lower() in str(track['artists']).lower(): + artists.append(track) + + for song in albums: album_obj = { "name": song["album"], "artists": song["artists"], } - if album_obj not in albums: - albums.append(album_obj) - - for album in albums: - # try: - # image = convert_one_to_json(instances.songs_instance.get_song_by_album(album['name'], album['artists']))['image'] - # except: - # image: None - - album['image'] = "image" - - for song in ar: + if album_obj not in albums_dicts: + albums_dicts.append(album_obj) + for album in albums_dicts: + for track in albums: + if album['name'] == track['album']: + album['image'] = track['image'] + + for song in artists: for artist in song["artists"]: if query.lower() in artist.lower(): @@ -68,11 +69,31 @@ def search_by_title(): "name": artist, } - if artist_obj not in artists: - artists.append(artist_obj) + if artist_obj not in artists_dicts: + artists_dicts.append(artist_obj) - return {'songs': helpers.remove_duplicates(s), 'albums': albums, 'artists': artists} + tracks = helpers.remove_duplicates(tracks) + if len(tracks) > 5: + more_tracks = True + else: + more_tracks = False + + if len(artists_dicts) > 5: + more_artists = True + else: + more_artists = False + + if len(albums_dicts) > 5: + more_albums = True + else: + more_albums = False + + return {'data': [ + {'tracks': tracks[:5], 'more': more_tracks}, + {'albums': albums_dicts[:10], 'more': more_albums}, + {'artists': artists_dicts[:10], 'more': more_artists} + ]} @bp.route('/populate') def x(): @@ -282,11 +303,14 @@ def convert_images_to_webp(): 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') + 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" + @bp.route('/test') def test_http_status_response(): - return "OK", 200 \ No newline at end of file + return "OK", 200 diff --git a/server/app/functions.py b/server/app/functions.py index 73baad05..f785725f 100644 --- a/server/app/functions.py +++ b/server/app/functions.py @@ -211,10 +211,6 @@ def getTags(full_path: str) -> dict: "length": round(audio.info.length), "bitrate": audio.info.bitrate, "image": img_path, - "type": { - "name": None, - "id": None - } } instances.songs_instance.insert_song(tags) @@ -228,7 +224,7 @@ def getAlbumBio(title: str, album_artist: str) -> dict: try: response = requests.get(last_fm_url) data = response.json() - except requests.ConnectionError: + except: return "None" try: diff --git a/src/App.vue b/src/App.vue index 2f362e16..e6475d18 100644 --- a/src/App.vue +++ b/src/App.vue @@ -75,6 +75,7 @@ export default { }; const collapseSearch = () => { + console.log('hooooo') search.value = false; }; @@ -131,6 +132,7 @@ export default { } .content { + width: 100%; padding: 0 $small; display: grid; grid-template-rows: auto 1fr; diff --git a/src/components/FolderView/SongList.vue b/src/components/FolderView/SongList.vue index 60cb1a3b..d6016fa9 100644 --- a/src/components/FolderView/SongList.vue +++ b/src/components/FolderView/SongList.vue @@ -35,7 +35,7 @@ import { ref } from "@vue/reactivity"; import { onMounted } from "@vue/runtime-core"; -import SongItem from "../SongItem.vue"; +import SongItem from "../shared/SongItem.vue"; import routeLoader from "@/composables/routeLoader.js"; import perks from "@/composables/perks.js"; import state from "@/composables/state.js"; diff --git a/src/components/PlaylistView/FeaturedArtists.vue b/src/components/PlaylistView/FeaturedArtists.vue index 2445b252..7f7f3e65 100644 --- a/src/components/PlaylistView/FeaturedArtists.vue +++ b/src/components/PlaylistView/FeaturedArtists.vue @@ -5,29 +5,24 @@
Featured Artists
{{ artist.name }}
- -