mirror of
https://github.com/Dvorinka/swingmusic-extended.git
synced 2026-06-04 20:43:04 +00:00
add a get_normal_artist_name function to try and normalize artist name variations
- add a get_artist_lists function to group artist name variants into a list
- add a get_normalized_artists function to return normalized artist objects
- use the above functions in:
- searching artists
- album artists
- playlist artists
This commit is contained in:
@@ -11,7 +11,7 @@ from app import exceptions
|
||||
from app import instances
|
||||
from app import models
|
||||
from app import settings
|
||||
from app.helpers import Get
|
||||
from app.helpers import Get, get_normalized_artists
|
||||
from app.lib import trackslib
|
||||
from app.logger import get_logger
|
||||
from PIL import Image
|
||||
@@ -153,8 +153,5 @@ class GetPlaylistArtists:
|
||||
def __call__(self):
|
||||
artists = set()
|
||||
|
||||
for t in self.tracks:
|
||||
for a in t.artists:
|
||||
artists.add(a)
|
||||
|
||||
return [models.Artist(a) for a in artists]
|
||||
artists = [a for t in self.tracks for a in t.artists]
|
||||
return get_normalized_artists(artists)
|
||||
|
||||
@@ -37,7 +37,6 @@ class Limit:
|
||||
|
||||
|
||||
class SearchTracks:
|
||||
|
||||
def __init__(self, tracks: List[models.Track], query: str) -> None:
|
||||
self.query = query
|
||||
self.tracks = tracks
|
||||
@@ -60,7 +59,6 @@ class SearchTracks:
|
||||
|
||||
|
||||
class SearchArtists:
|
||||
|
||||
def __init__(self, artists: set[str], query: str) -> None:
|
||||
self.query = query
|
||||
self.artists = artists
|
||||
@@ -78,19 +76,11 @@ class SearchArtists:
|
||||
limit=Limit.artists,
|
||||
)
|
||||
|
||||
f_artists = []
|
||||
for artist in results:
|
||||
aa = {
|
||||
"name": artist[0],
|
||||
"image": helpers.create_safe_name(artist[0]) + ".webp",
|
||||
}
|
||||
f_artists.append(aa)
|
||||
|
||||
return f_artists
|
||||
artists = [a[0] for a in results]
|
||||
return helpers.get_normalized_artists(artists)
|
||||
|
||||
|
||||
class SearchAlbums:
|
||||
|
||||
def __init__(self, albums: List[models.Album], query: str) -> None:
|
||||
self.query = query
|
||||
self.albums = albums
|
||||
@@ -121,7 +111,6 @@ class SearchAlbums:
|
||||
|
||||
|
||||
class SearchPlaylists:
|
||||
|
||||
def __init__(self, playlists: List[models.Playlist], query: str) -> None:
|
||||
self.playlists = playlists
|
||||
self.query = query
|
||||
|
||||
Reference in New Issue
Block a user