Skip to content

stream.hls: customizable playlist reload times #2925

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

Merged

Conversation

bastimeyer
Copy link
Member

Adds support for customizable HLS playlist reload times via --hls-playlist-reload-time.

Values can be

  • numbers (float) greater than 2 - self-explanatory
  • "segment" - sets refresh time to the duration of the last segment
  • "live-edge" - sets refresh time to the sum of durations of the live-edge - 1 last segments

For all other values, falls back to the playlist's target_duration if it is set, otherwise does the same as live-edge (this logic got changed, was segment before), and if no target duration and no segments are present, then the default value of 15 is used.

Also renames HLSStreamWorker._set_playlist_reload_time to HLSStreamWorker._playlist_reload_time and sets the reload time from its return value instead.


The changes are rather trivial, but I'd like to improve the integration tests a bit. It currently only tests one playlist refresh. Ideally, multiple playlists should be tested, but I couldn't set up a simple method spy with unittest.mock. Help and feedback is appreciated.

@codecov
Copy link

codecov bot commented Apr 21, 2020

Codecov Report

Merging #2925 into master will increase coverage by 0.12%.
The diff coverage is 93.75%.

@@            Coverage Diff             @@
##           master    #2925      +/-   ##
==========================================
+ Coverage   52.59%   52.72%   +0.12%     
==========================================
  Files         250      250              
  Lines       15715    15737      +22     
==========================================
+ Hits         8266     8298      +32     
+ Misses       7449     7439      -10     

@gravyboat
Copy link
Member

Do we care this doesn't work on 2.7? I'd rather just note that it doesn't. We already have PRs open to remove it.

@bastimeyer
Copy link
Member Author

To be honest, I didn't properly check my changes regarding Python 2 (lack of experience) before submitting and also didn't run local tests on Python 2.

I wasn't expecting this to be included in 1.4.0 anyway, but if somebody feels like it's important, then this can be fixed of course. Just wanted to get this out for review before I forget about it.

via --hls-playlist-reload-time
@bastimeyer bastimeyer force-pushed the stream/hls/playlist-reload-time branch from 0e7c494 to bc1544b Compare April 21, 2020 07:03
@back-to back-to mentioned this pull request Jul 6, 2020
@gravyboat
Copy link
Member

Now that we're past that pycountry hurdle I'm going to merge this since the next release will drop 2.7 support. Thanks @bastimeyer.

@gravyboat gravyboat merged commit bf1460c into streamlink:master Jul 27, 2020
@bastimeyer bastimeyer deleted the stream/hls/playlist-reload-time branch January 19, 2021 23:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants