Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Similar problem to previous str/bytes issue #4

Closed
Cacctus opened this issue Jan 10, 2020 · 5 comments
Closed

Similar problem to previous str/bytes issue #4

Cacctus opened this issue Jan 10, 2020 · 5 comments

Comments

@Cacctus
Copy link

Cacctus commented Jan 10, 2020

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

@dskrad
Copy link
Owner

dskrad commented Feb 6, 2020

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.

@mgjoni
Copy link

mgjoni commented Apr 6, 2020

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'

@rudelm
Copy link

rudelm commented Apr 16, 2020

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.

@pintman
Copy link

pintman commented Apr 23, 2020

Same problem here. Is the problem fixed?

@dskrad dskrad closed this as completed in e466842 May 23, 2020
@pintman
Copy link

pintman commented May 24, 2020

Thanks. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants