Skip to content

Conversation

guidocella
Copy link
Contributor

@guidocella guidocella commented Sep 10, 2025

Revert "ytdl_hook: add option to extract chapters"

This reverts commit df1e71a.

The next commit will make this unused since chapters will only be taken from yt-dlp's JSON.

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 of 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, 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 reverts commit df1e71a.

The next commit will make this unused since chapters will only be taken
from yt-dlp's JSON.
This reverts commit e9c4325.

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 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, 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 mpv-player#16085 added an
option to disable it to fix the misdetection reported in mpv-player#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.
Copy link

@na-na-hi
Copy link
Contributor

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, as it is dead code that never runs if yt-dlp's JSON already contains chapters.

If ytdl_hook still supports youtube-dl and youtube-dl does not extract chapters, then this should not be removed.

There are valid reasons to use youtube-dl instead of yt-dlp, for example it supports some sites that yt-dlp refuses to or removed support because they are considered "piracy sites".

@guidocella
Copy link
Contributor Author

Do those really have chapters only in the description though? Even yt-dlp only uses it in 3 extractors meaning it is uncommon so there's no difference with yt-dlp there. For youtube itself youtube-dl doesn't work at all for me since the last commit is from 4 months ago so I can't even test it lol, but note that this is only for videos where the web player doesn't show the chapter markers and they are only in the description and I can't find such videos at all now. They were common 3 years ago when we last tested it so youtube must have improved this. If I comment self._extract_chapters_from_description in yt_dlp/extractor/youtube/_video.py to verify it yt-dlp still extracts chapters.
I think this is nice for fixing that misdetection bug by default and removing that --ytdl-extract-chapters option before the next release which should have been a script-opt.

Copy link
Member

@sfan5 sfan5 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not tested but LGTM.

@na-na-hi
Copy link
Contributor

Do those really have chapters only in the description though? Even yt-dlp only uses it in 3 extractors meaning it is uncommon so there's no difference with yt-dlp there.

There are many youtube alternatives that are not in that list, many are used by uploaders who cannot or do not use youtube for whatever reason. They serve the same purpose as youtube. yt-dlp not including other websites does not mean they are not useful.

but note that this is only for videos where the web player doesn't show the chapter markers and they are only in the description and I can't find such videos at all now. They were common 3 years ago when we last tested it so youtube must have improved this

Do old videos just magically disappear? In the video you mentioned https://www.youtube.com/watch?v=1v_4dL8l8pQ no chapters shown in web player. yt-dlp priortize extracting the timestamps from "Key moments" which are AI genertated and do not match the timestamps in description.

I think this is nice for fixing that misdetection bug by default

You can just disable it for youtube only. For other websites, it's better to have something than nothing.

@kasper93
Copy link
Member

Revert "ytdl_hook: add option to extract chapters"

Why remove this option? Is yt-dlp itself avoiding each and every issue that our custom parser had that prompted addition of this option?

@guidocella
Copy link
Contributor Author

There are many youtube alternatives that are not in that list, many are used by uploaders who cannot or do not use youtube for whatever reason. They serve the same purpose as youtube. yt-dlp not including other websites does not mean they are not useful.

I don't know when I said they are not useful. I mean that it is not common to have chapters only in the description and not in the API if it's only enabled for 3 extractors. If you grep chapter in yt_dlp/extractor you see that it extracts chapters properly from the API for many other extractors. Also if more websites do need description parsing it is more beneficial to enable it upstream.

Do old videos just magically disappear? In the video you mentioned https://www.youtube.com/watch?v=1v_4dL8l8pQ no chapters shown in web player. yt-dlp priortize extracting the timestamps from "Key moments" which are AI genertated and do not match the timestamps in description.

I meant I can't find old videos without chapter markers so I'm assuming they added them later. Ther was a video linked in the relative IRC discussion 3 years ago but is down now so it can't be tested. mpv already uses the Key moments as chapters on master for that video since yt-dlp's JSON takes priority so there is no difference. But either way yt-dlp would still extract chapters from the description while youtube-dl doesn't even work with youtube.

Why remove this option? Is yt-dlp itself avoiding each and every issue that our custom parser had that prompted addition of this option?

That option never disabled the chapters returned by yt-dlp but only the ones defined by our parser which is removed by the next commit. The only known issue was in our parser.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants