Hey guys, I need to integrate n8n with YouTube to extract subtitles from videos. can someone help me?
Hey @laschuk, I am afraid this is not an option the YouTube in n8n offers. So you would need to use the HTTP Request node here to call the respective API directly.
For example like so:
Simply change the videoId
parameter on the first HTTP Request node (and possibly adjust the language to search for on the Set node). This would give you the captions of a video (assuming your YouTube account has sufficient permissions):
oh my god! that’s perfeect! looks like u did this so easily!
do you know how can i remove time from captions?
thx so much!
Hi @laschuk, you can specify the format you want using the tfmt
parameter provided by the download enpdoint.
So you could consider setting their sbv
format which seems to be the most straightforward one
Then, after downloading and reading the subtitles, you could strip the unwanted timecodes using regular expressions. An example one (probably not the best one, but the best one I can write) would be /\d+:\d{2}:\d{2}\.\d{3},\d+:\d{2}:\d{2}\.\d{3}\n+/gm
.
In the example workflow, this could look like so:
Wooow! thx so much
@MutedJam This works great as far as the download captions node. It fires a 403 error, is there something I need to add to my credentials in Google console?
Sounds like a permissions problem. Are you the owner of the video you’re trying to extract subtitles from?
Yes but different account. Had to also refresh the Youtube credentials in N8N. For anyone else, YT also have a new Subtitle permission scope.
This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.