Skip to content

Instantly share code, notes, and snippets.

@bitingsock
Last active July 15, 2023 06:14
Show Gist options
  • Save bitingsock/19c3094cc8680bb7b97b09aaf7d11176 to your computer and use it in GitHub Desktop.
Save bitingsock/19c3094cc8680bb7b97b09aaf7d11176 to your computer and use it in GitHub Desktop.
stops the demuxer from downloading more if it is already past --end
local maxBytes = mp.get_property("demuxer-max-bytes")
local function stopCache()
local state = mp.get_property_native("demuxer-cache-state")
if state and state["cache-end"] and tonumber(state["cache-end"]) > tonumber(mp.get_property("end")) then
mp.set_property("demuxer-max-bytes",0)
print("stop")
mp.unobserve_property(stopCache)
end
end
local function look()
if mp.get_property("end") ~= "none" then
maxBytes = mp.get_property("demuxer-max-bytes")
mp.observe_property("time-pos", "number", stopCache)
end
end
look()
mp.add_key_binding("alt+c", "restore", function() mp.set_property("demuxer-max-bytes",maxBytes); print("continue"); end)
mp.add_key_binding("alt+x", "look", look)
@lamyergeier
Copy link

Thank you so much!

@bitingsock
Copy link
Author

bitingsock commented Aug 29, 2021

This, of course, relies on the fact that mp.set_property("demuxer-max-bytes",0) doesn't just delete the cache which I would have thought it might. Hopefully this does not change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment