[packages/mpv] upstream change adding delay to ytdl hook; rel 13

atler atler at pld-linux.org
Thu Oct 29 00:45:36 CET 2026


commit c1ef0310265a1df6ea4cf65a13ba6bc372f6aff9
Author: Jan Palus <atler at pld-linux.org>
Date:   Thu Oct 29 00:44:00 2026 +0100

    upstream change adding delay to ytdl hook; rel 13
    
    from https://github.com/mpv-player/mpv/pull/18193

 mpv.spec           |  4 ++-
 yt-dlp-delay.patch | 91 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 94 insertions(+), 1 deletion(-)
---
diff --git a/mpv.spec b/mpv.spec
index d9dac04..ea1bac1 100644
--- a/mpv.spec
+++ b/mpv.spec
@@ -25,7 +25,7 @@ Summary:	Movie player based on MPlayer and mplayer2
 Summary(pl.UTF-8):	Odtwarzacz filmów oparty na projektach MPlayer i mplayer2
 Name:		mpv
 Version:	0.41.0
-Release:	12
+Release:	13
 License:	GPL v2+
 Group:		Applications/Multimedia
 #Source0Download: http://github.com/mpv-player/mpv/releases
@@ -33,6 +33,7 @@ Source0:	https://github.com/mpv-player/mpv/archive/v%{version}/%{name}-%{version
 # Source0-md5:	fa40a0fedeaf0a77127e238a39b9d4c4
 Source1:	%{name}.conf
 Patch0:		v4lrequest.patch
+Patch1:		yt-dlp-delay.patch
 URL:		http://mpv.io/
 BuildRequires:	EGL-devel
 BuildRequires:	Mesa-libgbm-devel >= 17.1.0
@@ -206,6 +207,7 @@ Dopełnianie parametrów mpv dla powłoki ZSH.
 %prep
 %setup -q
 %{?with_v4l2_request:%patch -P0 -p1}
+%patch -P1 -p1
 
 %build
 %meson \
diff --git a/yt-dlp-delay.patch b/yt-dlp-delay.patch
new file mode 100644
index 0000000..dca6b88
--- /dev/null
+++ b/yt-dlp-delay.patch
@@ -0,0 +1,91 @@
+From ff5657999d16823adc2629ec0550236bf752c9a2 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Kacper=20Michaj=C5=82ow?= <kasper93 at gmail.com>
+Date: Sat, 27 Jun 2026 00:35:21 +0200
+Subject: [PATCH] ytdl_hook: defer loading until the formats become available
+
+yt-dlp can provide time at which formats become available
+`available_at`. Sleep until the requested time.
+
+Fixes: #18192
+---
+ player/lua/ytdl_hook.lua | 30 +++++++++++++++++++++++++++---
+ 1 file changed, 27 insertions(+), 3 deletions(-)
+
+diff --git a/player/lua/ytdl_hook.lua b/player/lua/ytdl_hook.lua
+index 0ceb1715cfad7..701bc2ae61e4d 100644
+--- a/player/lua/ytdl_hook.lua
++++ b/player/lua/ytdl_hook.lua
+@@ -29,6 +29,7 @@ local chapter_list = {}
+ local chapter_list = {}
+ local playlist_cookies = {}
+ local playlist_metadata = {}
++local stream_delay = 0
+ 
+ local function Set (t)
+     local set = {}
+@@ -635,6 +636,17 @@ local function formats_to_edl(json, formats, use_all_formats)
+     return res
+ end
+ 
++-- Seconds to wait before the formats become available
++local function get_stream_delay(formats)
++    local available_at = 0
++    for _, track in ipairs(formats or {}) do
++        if type(track.available_at) == "number" then
++            available_at = math.max(available_at, track.available_at)
++        end
++    end
++    return available_at > 0 and math.max(0, available_at - os.time()) or 0
++end
++
+ local function add_single_video(json)
+     local streamurl = ""
+     local format_info = ""
+@@ -648,6 +660,9 @@ local function add_single_video(json)
+                     and requested_formats[1].cookies
+                     or json.cookies
+ 
++    stream_delay = math.max(stream_delay,
++        get_stream_delay(has_requested_formats and requested_formats or {json}))
++
+     if o.use_manifests and valid_manifest(json) then
+         -- prefer manifest_url if present
+         format_info = "manifest"
+@@ -868,6 +883,7 @@ end
+ 
+ local function run_ytdl_hook(url)
+     local start_time = os.clock()
++    stream_delay = 0
+ 
+     -- strip ytdl://
+     if url:find("ytdl://") == 1 then
+@@ -1153,7 +1169,7 @@ local function run_ytdl_hook(url)
+     msg.debug('script running time: '..os.clock()-start_time..' seconds')
+ end
+ 
+-local function on_load_hook(load_fail)
++local function on_load_hook(load_fail, hook)
+     local url = mp.get_property("stream-open-filename", "")
+     local force = url:find("^ytdl://") ~= nil
+     local early = force or o.try_ytdl_first or is_whitelisted(url)
+@@ -1164,10 +1180,18 @@ local function on_load_hook(load_fail)
+         return
+     end
+     run_ytdl_hook(url)
++
++    -- defer loading until the formats become available
++    if stream_delay > 0 then
++        msg.info(("Waiting %.2f seconds for the stream to become available...")
++                 :format(stream_delay))
++        hook:defer()
++        mp.add_timeout(stream_delay, function() hook:cont() end)
++    end
+ end
+ 
+-mp.add_hook("on_load", 10, function() on_load_hook(false) end)
+-mp.add_hook("on_load_fail", 10, function() on_load_hook(true) end)
++mp.add_hook("on_load", 10, function(hook) on_load_hook(false, hook) end)
++mp.add_hook("on_load_fail", 10, function(hook) on_load_hook(true, hook) end)
+ 
+ mp.add_hook("on_load", 20, function ()
+     msg.verbose('playlist hook')
================================================================

---- gitweb:

http://git.pld-linux.org/gitweb.cgi/packages/mpv.git/commitdiff/c1ef0310265a1df6ea4cf65a13ba6bc372f6aff9



More information about the pld-cvs-commit mailing list