mirror of
https://github.com/Wojtek242/qobuz-dl.git
synced 2024-12-22 15:24:40 +01:00
cleaner genre tags
didnt need to use reduce function
This commit is contained in:
parent
41cc9a5333
commit
5886d274da
@ -1,3 +1,4 @@
|
||||
import re
|
||||
import os
|
||||
import logging
|
||||
|
||||
@ -37,13 +38,12 @@ def _format_genres(genres: list) -> str:
|
||||
"""Fixes the weirdly formatted genre lists returned by the API.
|
||||
>>> g = ['Pop/Rock', 'Pop/Rock→Rock', 'Pop/Rock→Rock→Alternatif et Indé']
|
||||
>>> _format_genres(g)
|
||||
'Pop/Rock, Rock, Alternatif et Indé'
|
||||
'Pop, Rock, Alternatif et Indé'
|
||||
"""
|
||||
|
||||
if genres == []:
|
||||
return ""
|
||||
else:
|
||||
return ", ".join(genres[-1].split("\u2192"))
|
||||
genres = re.findall(r"([^\u2192\/]+)", "/".join(genres))
|
||||
no_repeats = []
|
||||
[no_repeats.append(g) for g in genres if g not in no_repeats]
|
||||
return ", ".join(no_repeats)
|
||||
|
||||
|
||||
# Use KeyError catching instead of dict.get to avoid empty tags
|
||||
|
Loading…
Reference in New Issue
Block a user