Skip to content

Commit b961c8e

Browse files
committed
Revert "ytdl_hook: add chapters by parsing video's description"
This reverts commit e9c4325. yt-dlp implemented its own parsing to extract chapters from the descriptions in videos without chapter markers in the player over 3 years ago in yt-dlp/yt-dlp@0fe51254 (the PR is even inspired by mpv). Actually it was present even earlier in youtube-dl but was removed for unknown reasons in ytdl-org/youtube-dl@67299f2. So we can remove our parsing code. A sample video without chapter markers is https://www.youtube.com/watch?v=PoFkd42WvQA (because the chapters don't start at 0:00?) - you can test that mpv still shows chapters after this commit. Actually both mpv and yt-dlp seem to only extract 8 chapters from this description for some reason, so neither was working perfectly anyway. And it seems that such videos without chapter markers are rare by now anyway - we can't find any other. 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).
1 parent 5253108 commit b961c8e

File tree

1 file changed

+0
-31
lines changed

1 file changed

+0
-31
lines changed

player/lua/ytdl_hook.lua

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -250,35 +250,6 @@ local function url_is_safe(url)
250250
return safe
251251
end
252252

253-
local function time_to_secs(time_string)
254-
local ret
255-
256-
local a, b, c = time_string:match("(%d+):(%d%d?):(%d%d)")
257-
if a ~= nil then
258-
ret = (a*3600 + b*60 + c)
259-
else
260-
a, b = time_string:match("(%d%d?):(%d%d)")
261-
if a ~= nil then
262-
ret = (a*60 + b)
263-
end
264-
end
265-
266-
return ret
267-
end
268-
269-
local function extract_chapters(data, video_length)
270-
local ret = {}
271-
272-
for line in data:gmatch("[^\r\n]+") do
273-
local time = time_to_secs(line)
274-
if time and (time < video_length) then
275-
table.insert(ret, {time = time, title = line})
276-
end
277-
end
278-
table.sort(ret, function(a, b) return a.time < b.time end)
279-
return ret
280-
end
281-
282253
local function is_whitelisted(url)
283254
url = url:match("https?://(.+)")
284255

@@ -829,8 +800,6 @@ local function add_single_video(json)
829800
end
830801
table.insert(chapter_list, {time=chapter.start_time, title=title})
831802
end
832-
elseif json.description ~= nil and json.duration ~= nil then
833-
chapter_list = extract_chapters(json.description, json.duration)
834803
end
835804

836805
-- set start time

0 commit comments

Comments
 (0)