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

Cannot import ogg #20

Open
barbeque-squared opened this issue Mar 31, 2020 · 1 comment
Open

Cannot import ogg #20

barbeque-squared opened this issue Mar 31, 2020 · 1 comment

Comments

@barbeque-squared
Copy link
Contributor

Newer songs have started to use the ogg format in favour of mp3. Example: A Final Twilight

I have created a fix for this problem in a branch, by just using the general mutagen importer instead of the mp3-specific one: https://github.com/barbeque-squared/ponytone/tree/import-ogg
However, I literally cannot tests if this actually works in browsers, otherwise I'd have created a pull request instead.

For reference, without the fix you get this error when importing ogg:

$ docker exec ponytone_web_1 python importmlk.py https://www.mylittlekaraoke.com/store/beta/dotmlk/Community/4EverfreeBrony%20-%20A%20Final%20Twilight%20%28Cover%29.tar.mlk  postgres://postgres:postgres@db:5432/postgres
Traceback (most recent call last):
  File "importmlk.py", line 155, in <module>
    info = song_info(tar, filename)
  File "importmlk.py", line 82, in song_info
    duration = mutagen.mp3.MP3(tar.extractfile(mp3_path)).info.length
  File "/usr/local/lib/python3.6/site-packages/mutagen/_file.py", line 49, in __init__
    self.load(*args, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/mutagen/_util.py", line 129, in wrapper
    return func(self, h, *args, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/mutagen/id3/_file.py", line 406, in load
    self.info = self._Info(fileobj, offset)
  File "/usr/local/lib/python3.6/site-packages/mutagen/_util.py", line 158, in wrapper
    return func(*args, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/mutagen/mp3/__init__.py", line 396, in __init__
    raise HeaderNotFoundError("can't sync to MPEG frame")
mutagen.mp3.HeaderNotFoundError: can't sync to MPEG frame
@barbeque-squared
Copy link
Contributor Author

A further change might be to check if the file is actually an mp3 or ogg to prevent random formats that don't work in browsers from getting in. Or do it the way it is already done if the extension is mp3 (and throw an error if it can't figure it out), do the same for ogg, and throw a more human-readable error if it's anything else.

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

1 participant