Revert "ytdl_hook: add chapters by parsing video's description"

This reverts commit e9c43258b8.

yt-dlp implemented its own parsing to extract chapters from the
descriptions of videos without chapter markers in the player over 3
years ago in https://github.com/yt-dlp/yt-dlp/commit/0fe51254 (the PR is
even inspired by mpv). Actually it was present even earlier in
youtube-dl but was removed for unknown reasons in
https://github.com/ytdl-org/youtube-dl/commit/67299f23d8b1894120e875edf97440de87e22308.
So we can remove our parsing code, as it is dead code that never runs if
yt-dlp's JSON already contains chapters.

And it seems that such videos without chapter markers are rare or
non-existing by now anyway - we can't find any.
https://www.youtube.com/watch?v=1v_4dL8l8pQ is linked from the yt-dlp PR
with the above commit, but now yt-dlp returns the Key moments as
chapters, so it can't be used for testing.

Our parsing was actually worse than yt-dlp's, because #16085 added an
option to disable it to fix the misdetection reported in #16081, but
yt-dlp correctly returns no chapter for that video
(https://www.youtube.com/watch?v=1v_4dL8l8pQ). So this code branch was
only running for misdetections, and by removing it that option is not
needed.
This commit is contained in:
Guido Cella
2025-09-10 16:58:31 +02:00
committed by sfan5
parent acd3378c9b
commit a58e9e596b
-31
View File
@@ -250,35 +250,6 @@ local function url_is_safe(url)
return safe
end
local function time_to_secs(time_string)
local ret
local a, b, c = time_string:match("(%d+):(%d%d?):(%d%d)")
if a ~= nil then
ret = (a*3600 + b*60 + c)
else
a, b = time_string:match("(%d%d?):(%d%d)")
if a ~= nil then
ret = (a*60 + b)
end
end
return ret
end
local function extract_chapters(data, video_length)
local ret = {}
for line in data:gmatch("[^\r\n]+") do
local time = time_to_secs(line)
if time and (time < video_length) then
table.insert(ret, {time = time, title = line})
end
end
table.sort(ret, function(a, b) return a.time < b.time end)
return ret
end
local function is_whitelisted(url)
url = url:match("https?://(.+)")
@@ -829,8 +800,6 @@ local function add_single_video(json)
end
table.insert(chapter_list, {time=chapter.start_time, title=title})
end
elseif json.description ~= nil and json.duration ~= nil then
chapter_list = extract_chapters(json.description, json.duration)
end
-- set start time