youtube-dlc
youtube-dlc copied to clipboard
[Embedding youtube-dlc] Custom hooks for post processing
Someone (@Coder-Iro) was interested in hooks for post processing https://github.com/ytdl-org/youtube-dl/issues/26543
So here it is https://github.com/blackjack4494/youtube-dlc/tree/custom-hooks-postprocessor-debug
I kept all the print()
commands so it's easier to see what is going on.
You can add your very own custom hooks for basically all post processor since the hooks are added for all [pp] in YoutubeDL.py
https://github.com/blackjack4494/youtube-dlc/blob/27750db2a1334a73740a95a7174f966bfa30d7e8/youtube_dlc/postprocessor/ffmpeg.py#L666-L675
[ppc] add_progress_hook
[ppc] _hook_progress
{'status': 'pre', 'action': 'subtitle_conversion'}
[ffmpeg]-[ffmpegsubtitleconvertor]
[ppc] _hook_progress
{'status': 'finished', 'action': 'subtitle_conversion', 'orignal_subtitles': ['__REDACTED__.en-US.vtt'], 'converted_subtitles': ['__REDACTED__.en-US.srt']}
[ppc] past ffmpegpp hook_progress
[ppc] _hook_progress
[ppc] report_progress
{'status': 'post', 'action': 'subtitle_conversion'}
In addition to that there is even a decorator (@decorator_hook
)
https://github.com/blackjack4494/youtube-dlc/blob/27750db2a1334a73740a95a7174f966bfa30d7e8/youtube_dlc/postprocessor/ffmpeg.py#L603-L609
If you want to test it yourself just pull/download the branch and execute the file custom_hook.py
I will wait for some response (feedback always welcomed).
If there is more interest I will provide some basic support in youtube-dlc that you can use with official source so you don't need to build it yourself.
Hooks are currently designed to only pass along informations so basically a one way. However it is possible to let youtube-dlc react to another hook (would require some heavier modifications) so that you can tell youtube-dlc within your own project to pause/stop or to skip a step.