mirror of
https://github.com/tcsenpai/swingmusic.git
synced 2025-07-23 18:10:13 +00:00
add "&" character to genre separators
+ handle r&b genre and rock&roll
This commit is contained in:
parent
da88bbd9cc
commit
5ff3e5d28a
@ -25,7 +25,7 @@ def create_api():
|
|||||||
Creates the Flask instance, registers modules and registers all the API blueprints.
|
Creates the Flask instance, registers modules and registers all the API blueprints.
|
||||||
"""
|
"""
|
||||||
app = Flask(__name__)
|
app = Flask(__name__)
|
||||||
CORS(app)
|
CORS(app, origins="*")
|
||||||
Compress(app)
|
Compress(app)
|
||||||
|
|
||||||
app.config["COMPRESS_MIMETYPES"] = [
|
app.config["COMPRESS_MIMETYPES"] = [
|
||||||
|
@ -216,7 +216,17 @@ def get_artist(artisthash: str):
|
|||||||
|
|
||||||
artist.is_favorite = favdb.check_is_favorite(artisthash, FavType.artist)
|
artist.is_favorite = favdb.check_is_favorite(artisthash, FavType.artist)
|
||||||
|
|
||||||
return {"artist": artist, "tracks": serialize_tracks(tracks[:limit])}
|
genres = set()
|
||||||
|
|
||||||
|
for t in tracks:
|
||||||
|
if t.genre is not None:
|
||||||
|
genres = genres.union(t.genre)
|
||||||
|
|
||||||
|
return {
|
||||||
|
"artist": artist,
|
||||||
|
"tracks": serialize_tracks(tracks[:limit]),
|
||||||
|
"genres": list(genres),
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@api.route("/artist/<artisthash>/albums", methods=["GET"])
|
@api.route("/artist/<artisthash>/albums", methods=["GET"])
|
||||||
|
@ -93,8 +93,22 @@ class Track:
|
|||||||
self.image = self.albumhash + ".webp"
|
self.image = self.albumhash + ".webp"
|
||||||
|
|
||||||
if self.genre is not None and self.genre != "":
|
if self.genre is not None and self.genre != "":
|
||||||
self.genre = str(self.genre).replace("/", ",").replace(";", ",")
|
self.genre = self.genre.lower()
|
||||||
self.genre = str(self.genre).lower().split(",")
|
separators = {"/", ";", "&"}
|
||||||
|
|
||||||
|
contains_rnb = "r&b" in self.genre
|
||||||
|
contains_rock = "rock & roll" in self.genre
|
||||||
|
|
||||||
|
if contains_rnb:
|
||||||
|
self.genre = self.genre.replace("r&b", "RnB")
|
||||||
|
|
||||||
|
if contains_rock:
|
||||||
|
self.genre = self.genre.replace("rock & roll", "rock")
|
||||||
|
|
||||||
|
for s in separators:
|
||||||
|
self.genre: str = self.genre.replace(s, ",")
|
||||||
|
|
||||||
|
self.genre = self.genre.split(",")
|
||||||
self.genre = [g.strip() for g in self.genre]
|
self.genre = [g.strip() for g in self.genre]
|
||||||
|
|
||||||
self.recreate_hash()
|
self.recreate_hash()
|
||||||
|
@ -9,12 +9,12 @@ def split_artists(src: str):
|
|||||||
Splits a string of artists into a list of artists.
|
Splits a string of artists into a list of artists.
|
||||||
"""
|
"""
|
||||||
separators: set = get_flag(SessionVarKeys.ARTIST_SEPARATORS)
|
separators: set = get_flag(SessionVarKeys.ARTIST_SEPARATORS)
|
||||||
separators = separators.union({","})
|
# separators = separators.union({","})
|
||||||
|
|
||||||
for sep in separators:
|
for sep in separators:
|
||||||
src = src.replace(sep, "߸")
|
src = src.replace(sep, ",")
|
||||||
|
|
||||||
artists = src.split("߸")
|
artists = src.split(",")
|
||||||
|
|
||||||
return [a.strip() for a in artists]
|
return [a.strip() for a in artists]
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user