mirror of
https://github.com/Wojtek242/qobuz-dl.git
synced 2024-11-22 11:05:25 +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 os
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
@ -37,13 +38,12 @@ def _format_genres(genres: list) -> str:
|
|||||||
"""Fixes the weirdly formatted genre lists returned by the API.
|
"""Fixes the weirdly formatted genre lists returned by the API.
|
||||||
>>> g = ['Pop/Rock', 'Pop/Rock→Rock', 'Pop/Rock→Rock→Alternatif et Indé']
|
>>> g = ['Pop/Rock', 'Pop/Rock→Rock', 'Pop/Rock→Rock→Alternatif et Indé']
|
||||||
>>> _format_genres(g)
|
>>> _format_genres(g)
|
||||||
'Pop/Rock, Rock, Alternatif et Indé'
|
'Pop, Rock, Alternatif et Indé'
|
||||||
"""
|
"""
|
||||||
|
genres = re.findall(r"([^\u2192\/]+)", "/".join(genres))
|
||||||
if genres == []:
|
no_repeats = []
|
||||||
return ""
|
[no_repeats.append(g) for g in genres if g not in no_repeats]
|
||||||
else:
|
return ", ".join(no_repeats)
|
||||||
return ", ".join(genres[-1].split("\u2192"))
|
|
||||||
|
|
||||||
|
|
||||||
# Use KeyError catching instead of dict.get to avoid empty tags
|
# Use KeyError catching instead of dict.get to avoid empty tags
|
||||||
|
Loading…
Reference in New Issue
Block a user