Skip to content

Japanese characters in chapters.txt cause runtime issue #6

@GaProgMan

Description

@GaProgMan

10kft view of error

When Japanese characters are added to the test.chapters.txt file (where test is the name of the mp3), and the mp3chaps -i test.mp3 is used, a runtime error happens, and the chapter marker is not added to the mp3 file.

Steps to recreate

  • Create a valid mp3 file called test.mp3
  • Create a text file called test.chapters.txt
  • Insert the following line into the text file:
    • 00:00:00.000 I N e e d Y o u 私の側て by G.H
  • Run the following command:
    • mp3chaps -i test.mp3

Full output from error

λ mp3chaps -i test.mp3
Traceback (most recent call last):
  File "c:\python39\lib\runpy.py", line 197, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "c:\python39\lib\runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "C:\Python39\Scripts\mp3chaps.exe\__main__.py", line 7, in <module>
  File "c:\python39\lib\site-packages\mp3chaps.py", line 81, in main
    add_chapters(tag, args["<filename>"])
  File "c:\python39\lib\site-packages\mp3chaps.py", line 45, in add_chapters
    chaps = parse_chapters_file(fname)
  File "c:\python39\lib\site-packages\mp3chaps.py", line 39, in parse_chapters_file
    for line in f.readlines():
  File "c:\python39\lib\encodings\cp1252.py", line 23, in decode
    return codecs.charmap_decode(input,self.errors,decoding_table)[0]
UnicodeDecodeError: 'charmap' codec can't decode byte 0x81 in position 31: character maps to <undefined>

Expected result

test.mp3 should have a single chapter marker called I N e e d Y o u 私の側て by G.H, and running mp3chaps -l test.mp3 should show:

λ mp3chaps -l test.mp3
Chapters:
I N e e d Y o u 私の側て by G.H

Machine details

  • Windows 10 (build number: 19041.329)
    • Will also test on my Ubuntu 20.04 machine and report back
  • mp3chaps vLatest from pip3 (at time of reporting)
  • Python 3.9.0b4

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions