-
Notifications
You must be signed in to change notification settings - Fork 475
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
extend _parse_extinf to allow for #EXIINF tags like #EXTINF:-1 tvg-i… #145
base: master
Are you sure you want to change the base?
Conversation
5 similar comments
Thank you for contributing to this project @cbaurtx |
https://tools.ietf.org/html/draft-pantos-http-live-streaming-23#section-4.3.2.1 The correct format for the EXTINF is:
It seems that there is no space for |
And our parser already takes the |
@leandromoreira thank you! |
What I did was just a quick hack. So I am all for improving this. I reckon I will run into similar requirements as you.
@mauricioabreu |
Addendum: Should we generate a dictionary with the attributes of the #EXTINF tag in case the non-strict option is selected? |
For the question about where should we be looking to implement new features, yes it's https://tools.ietf.org/html/rfc8216 About the https://github.com/globocom/m3u8/blob/master/tests/test_parser.py#L324-L335 |
by the way maybe we need to document this feature at the home page with the title "Custom parsers for non-standard tags" #130 and use the very test example to show it. |
Thank you for the quick reply. I am good with sticking to https://tools.ietf.org/html/rfc8216. I might have a wrong picture of custom tags. I thought these are new tags and not variations / extensions of existing tags. Or would you overload existing tag parsing with new functions? |
Here you can see the implementation https://github.com/globocom/m3u8/pull/130/files#diff-f843380fa3bcd9ed49ae136974fa3aecR154 And here some usage: SIMPLE_PLAYLIST_WITH_CUSTOM_TAGS = '''#EXTM3U
#EXT-X-MOVIE: million dollar baby
#EXT-X-TARGETDURATION:5220
#EXTINF:5220,
http://media.example.com/entire.ts
#EXT-X-ENDLIST
'''
def test_simple_playlist_with_custom_tags():
def get_movie(line, data, lineno):
custom_tag = line.split(':')
if len(custom_tag) == 2:
data['movie'] = custom_tag[1].strip()
data = m3u8.parse(playlists.SIMPLE_PLAYLIST_WITH_CUSTOM_TAGS, strict=False, custom_tags_parser=get_movie)
assert data['movie'] == 'million dollar baby'
assert 5220 == data['targetduration']
assert 0 == data['media_sequence']
assert ['http://media.example.com/entire.ts'] == [c['uri'] for c in data['segments']]
assert [5220] == [c['duration'] for c in data['segments']] |
@leandromoreira "Custom tag parser" is a very powerful functionality, but the problem is in the order of calling it. Line 194 in 2ea6877
It would better to change the priority of calling custom_tags_parser in such a way that it would be called first before calling any other parse* functions. Then we would be able to customize even parsing #EXTINF tag, so it would help to parse other non-standard attributes (tvg-id, group-title, etc.) instead of forking and patching the current repo (what I actually do) What do you think about it? I'll try to prepare a pull request with these changes and examples of use |
@SerhiyRomanov thanks I'm okay with this approach, what do you think? @mauricioabreu |
I think that we must be aware that the main parser should also be called. Or we always call the custom parser or adding some kind of TAG check to call it. |
@leandromoreira I am ok with that @SerhiyRomanov tell me if you need any help with your pull request |
@mauricioabreu I've made it #247 Would be happy to get your comments. |
Nice job @SerhiyRomanov . It would be great to have a custom dumper as well. |
@rokam Yes, I'm thinking about it. But it seems slightly complicated to implement such functionality with current implementations of dumps(). I will create an issue for it after my PR become merged |
I cannot find a spec for supporting attributes in
I don't think to support the iptv dialect will do any harm. It's more like a superset of RFC8216 that won't break the compatibility. |
…d=....., Title