fix: UnicodeEncodeError: 'utf-8' codec can't encode character '\udce0' in position 99: surrogates not allowed

This commit is contained in:
mungai-njoroge 2023-09-19 17:45:28 +03:00
parent 34c26416e2
commit f2e110a564

View File

@ -42,9 +42,15 @@ class SQLiteTrackMethods:
:date, :disc, :duration, :filepath, :folder, :genre, :last_mod, :title, :track, :trackhash)
"""
#
track = OrderedDict(sorted(track.items()))
def force_surrogatepass(string: str):
return string.encode("utf-16", "surrogatepass").decode("utf-16")
for key, value in track.items():
if isinstance(value, str):
track[key] = force_surrogatepass(value)
track["artist"] = track["artists"]
track["albumartist"] = track["albumartists"]