Similar problem to previous str/bytes issue
Cacctus opened this issue · 5 comments
I can't get this working either. Chapters file is test info:
00:00:00.000 sdfsdf
00:02:00.000 fasffa
00:04:24.123 fsdfww
Running script:
D:\Download\mp3chaps-master>mp3chaps.py -i ap.mp3
Chapters:
sdfsdf
fasffa
fsdfww
Traceback (most recent call last):
File "D:\Download\mp3chaps-master\mp3chaps.py", line 85, in
main()
File "D:\Download\mp3chaps-master\mp3chaps.py", line 80, in main
add_chapters(tag, args[""])
File "D:\Download\mp3chaps-master\mp3chaps.py", line 64, in add_chapters
tag.save()
File "C:\Program Files\Python38\lib\site-packages\eyed3\id3\tag.py", line 814, in save
self._saveV2Tag(version, encoding, max_padding)
File "C:\Program Files\Python38\lib\site-packages\eyed3\id3\tag.py", line 1019, in _saveV2Tag
rewrite_required, tag_data, padding = self._render(version,
File "C:\Program Files\Python38\lib\site-packages\eyed3\id3\tag.py", line 938, in _render
raw_frame = f.render()
File "C:\Program Files\Python38\lib\site-packages\eyed3\id3\frames.py", line 1335, in render
data = self.element_id + b'\x00'
TypeError: can only concatenate str (not "bytes") to str
Requirement versions differences:
eyeD3=0.9
python-magic=0.4.15
six=1.13.0
I attempted to make python2/3 compatibility, but I may have overlooked something. I seem to get a similar error with python3 but not with python2. I do not have a fix yet.
Got around it with some checking for byte strings:
around line 1659: .local/lib/python3.8/site-packages/eyed3/id3/frames.py
def render(self):
if isinstance(self.element_id, bytes):
data = self.element_id + b'\x00'
else:
data = self.element_id.encode() + b'\x00'
around line 1266: same file
def render(self):
flags = [0] * 8
if self.toplevel:
flags[self.TOP_LEVEL_FLAG_BIT] = 1
if self.ordered:
flags[self.ORDERED_FLAG_BIT] = 1
if isinstance(self.element_id, bytes):
data = (self.element_id + b'\x00' +
bin2bytes(flags) + dec2bytes(len(self.child_ids)))
else:
data = (self.element_id.encode() + b'\x00' +
bin2bytes(flags) + dec2bytes(len(self.child_ids)))
for cid in self.child_ids:
if isinstance(cid, bytes):
data += cid + b'\x00'
else:
data += cid.encode() + b'\x00'
thank you @mgjoni that fixed it for me as well. I'm using mp3chaps in a venv with python 3.7 and ran into exactly the same issue.
Same problem here. Is the problem fixed?
Thanks. :)