mpv icon indicating copy to clipboard operation
mpv copied to clipboard

ytdl_hook: can't play videos from Steam store page (no unique URLs)

Open orbea opened this issue 4 months ago • 4 comments

mpv Information

mpv v0.40.0-287-g194ce88ac Copyright © 2000-2025 mpv/MPlayer/mplayer2 projects
libplacebo version: v7.351.0
FFmpeg version: 7.1.1
FFmpeg library versions:
   libavcodec      61.19.101
   libavdevice     61.3.100
   libavfilter     10.4.100
   libavformat     61.7.100
   libavutil       59.39.100
   libswresample   5.3.100
   libswscale      8.3.100

Other Information

- Linux version: Gentoo
- Kernel Version: 6.12.42
- GPU Model: Advanced Micro Devices, Inc. [AMD/ATI] [1002:7550]
- Mesa/GPU Driver Version: Mesa 25.3.0-devel (git-cc0dc4b566)
- Window Manager and Version: https://github.com/conformal/spectrwm/commit/5dcffa21804f9cebc857d2a6931c2bd6f7380139
- yt-dlp version: https://github.com/yt-dlp/yt-dlp/commit/526410b4af9c1ca73aa3503cdaf4d32e42308fd6
- Source of mpv: Official Gentoo ebuild.
- Latest known working version: N/A
- Issue started after the following happened: 

After yt-dlp fixed steam urls (https://github.com/yt-dlp/yt-dlp/pull/14008)
I noticed some steam pages cause lau to crash.
Using yt-dlp to download the videos without mpv does work.

Reproduction Steps

\mpv --no-config --log-file=/tmp/output.txt https://store.steampowered.com/app/2581410/Stygian_Outer_Gods/

Expected Behavior

It should play the 5 videos on the page.

Actual Behavior

[ytdl_hook] 
[ytdl_hook] stack traceback:
[ytdl_hook] 	@ytdl_hook.lua:1191: in function 'on_load_hook'
[ytdl_hook] 	@ytdl_hook.lua:1195: in function 'fn'
[ytdl_hook] 	mp.defaults:609: in function 'handler'
[ytdl_hook] 	mp.defaults:522: in function 'call_event_handlers'
[ytdl_hook] 	mp.defaults:564: in function 'dispatch_events'
[ytdl_hook] 	mp.defaults:515: in function <mp.defaults:514>
[ytdl_hook] 	[C]: at 0x558419f8a430
[ytdl_hook] 	[C]: at 0x558419f88850
[ytdl_hook] Lua error: @ytdl_hook.lua:1143: attempt to index local 'site' (a nil value)
client removed during hook handling
Failed to recognize file format.
Exiting... (Errors when loading file)

Log File

output.txt

Sample Files

Two example links:

https://store.steampowered.com/app/2581410/Stygian_Outer_Gods/ https://store.steampowered.com/app/2108180/Swordhaven_Iron_Conspiracy/

I carefully read all instruction and confirm that I did the following:

  • [x] I tested with the latest mpv version to validate that the issue is not already fixed.
  • [x] I provided all required information including system and mpv version.
  • [x] I produced the log file with the exact same set of files, parameters, and conditions used in "Reproduction Steps", with the addition of --log-file=output.txt.
  • [x] I produced the log file while the behaviors described in "Actual Behavior" were actively observed.
  • [x] I attached the full, untruncated log file.
  • [x] I attached the backtrace in the case of a crash.

orbea avatar Aug 22 '25 22:08 orbea

Clear error behavior:

diff --git a/player/lua/ytdl_hook.lua b/player/lua/ytdl_hook.lua
index ae5316a749..100381f236 100644
--- a/player/lua/ytdl_hook.lua
+++ b/player/lua/ytdl_hook.lua
@@ -1140,7 +1140,9 @@ local function run_ytdl_hook(url)
                 local playlist_url = nil
 
                 -- links without protocol as returned by --flat-playlist
-                if not site:find("://") then
+                if not site then
+                    msg.error("Playlist entry does not have unique URL, can't add it.")
+                elseif not site:find("://") then
                     -- youtube extractor provides only IDs,
                     -- others come prefixed with the extractor name and ":"
                     local prefix = site:find(":") and "ytdl://" or

Root cause: when there's a playlist, ytdl_hook expects each entry to have an unique URL so that it can make up an M3U. This isn't the case here.

To fix this mpv could instead expand into e.g. https://store.steampowered.com/app/2581410/#ytdlid:257187196 (and later parse this out of the URL again) to reference a specific playlist entry.

sfan5 avatar Aug 22 '25 22:08 sfan5

Isn't this an issue with yt-dlp itself? I've tried yt-dlp -F <url> with both examples from the OP and both return playlists with 0 items. Granted, mpv shouldn't crash but that seems fixed with 80d2a6a.

WhitePeter avatar Nov 13 '25 06:11 WhitePeter

This worked for me and returned a playlist at the time.

sfan5 avatar Nov 13 '25 11:11 sfan5

It also worked for me at the time and this was reported to yt-dlp. https://github.com/yt-dlp/yt-dlp/issues/15014

It was also already fixed for yt-dlp in an unmerged PR. https://github.com/yt-dlp/yt-dlp/pull/15028

However it still doesn't work with mpv even with the above PR.

orbea avatar Nov 13 '25 14:11 orbea