Skip to content

Commit 23f1df2

Browse files
Update tagger.py
1 parent 257dcae commit 23f1df2

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

core/process/tagger.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22
from mutagen.mp4 import MP4, MP4Cover
33
from utils import logger
44

5+
def replaceChar(s):
6+
if not isinstance(s, list):
7+
return str(s).encode('latin-1', errors='replace').decode('latin-1')
8+
else:
9+
return [str(l).encode('latin-1', errors='replace').decode('latin-1') for l in s]
10+
511
def tag(media, data, cover, output, nocover=False, nolrc=False):
612
tags = MP4(media)
713
tags.delete()
@@ -37,15 +43,15 @@ def tag(media, data, cover, output, nocover=False, nolrc=False):
3743
for key, value in __tags.items():
3844
if value:
3945
if isinstance(value, list):
40-
value = ['\r\n'.join(value)]
46+
value = ['\r\n'.join(replaceChar(value))]
4147

4248
if key.startswith("----:com.apple.itunes:"):
4349
value = [val.encode() for val in value]
4450

45-
tags[key] = value
51+
tags[replaceChar(key)] = value
4652
else:
4753
if key.startswith("----:com.apple.itunes:"):
48-
value = value.encode()
54+
value = replaceChar(value).encode()
4955

5056
if key in [
5157
"aART",
@@ -62,7 +68,7 @@ def tag(media, data, cover, output, nocover=False, nolrc=False):
6268
'\r\n'
6369
)
6470

65-
tags[key] = [value]
71+
tags[replaceChar(key)] = [value]
6672

6773
if not nocover:
6874
logger.info("Embedding artwork...")
@@ -82,4 +88,4 @@ def tag(media, data, cover, output, nocover=False, nolrc=False):
8288
else:
8389
logger.warning("Unable to find time-synced lyrics!")
8490

85-
tags.save()
91+
tags.save()

0 commit comments

Comments
 (0)