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

Empty duration default/exception #344

Open
radujica opened this issue Nov 9, 2023 · 0 comments
Open

Empty duration default/exception #344

radujica opened this issue Nov 9, 2023 · 0 comments

Comments

@radujica
Copy link

radujica commented Nov 9, 2023

As raised in radujica/tospotify#27, looks like some music players can store playlists with missing duration in #EXTINF, e.g.

#EXTINF:,Song

which leads to an exception such as

File "/home/serenity/.local/lib/python3.10/site-packages/m3u8/init.py", line 49, in load
return _load_from_file(uri, custom_tags_parser)
File "/home/serenity/.local/lib/python3.10/site-packages/m3u8/init.py", line 56, in _load_from_file
return M3U8(raw_content, base_uri=base_uri, custom_tags_parser=custom_tags_parser)
File "/home/serenity/.local/lib/python3.10/site-packages/m3u8/model.py", line 153, in init
self.data = parse(content, strict, custom_tags_parser)
File "/home/serenity/.local/lib/python3.10/site-packages/m3u8/parser.py", line 143, in parse
_parse_extinf(line, data, state, lineno, strict)
File "/home/serenity/.local/lib/python3.10/site-packages/m3u8/parser.py", line 261, in _parse_extinf
state['segment']['duration'] = float(duration)
ValueError: could not convert string to float: ''

Now according to https://en.wikipedia.org/wiki/M3U, that's technically invalid m3u format, however could perhaps show a better error OR ignore and default to duration=0?

Something like this for option 2: #343

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