Posted: . At: 10:17 AM. This was 4 months ago. Post ID: 19014
Page permalink. WordPress uses cookies, or tiny pieces of information stored on your computer, to verify who you are. There are cookies for logged in users and for commenters.
These cookies expire two weeks after they are set.


How to get a list of all YouTube videos on a channel with yt-dlp.


Getting a list of all YouTube videos on a channel with yt-dlp is a very simple process. This example will get all of the YouTube video URLs on a channel and then dump them into a text file.

(jcartwright@localhost) 192.168.1.5 Documents  $ yt-dlp --flat-playlist --print-to-file webpage_url buddhist-links.txt https://www.youtube.com/@BuddhismHotlineTV

This is very easy, this gets all videos, including shorts, and puts them in one big list that may be then iterated through with a script.

This is how to list all YouTube video chapters with yt-dlp.

(jcartwright@localhost) 192.168.1.5 jcartwright  $ yt-dlp --dump-json https://www.youtube.com/watch?v=o1jv509M8Zg | jq --raw-output ".chapters[].title"
Car Gadgets Amazon
Fuse splitter
Quick release terminals
Shrink tubes
Round LED headlights
Impact screwdriver
Spray nozzle
Trunk organizer
Exhaust nozzle
Oil trap
Headlight Clarity Restoration Kit
Waterproof rubber markers
Tar cleaner
Clips for fixing mats
Cigarette lighter compressor
Headlight polishing kit
Plasma cutting machine
Chain wrench
Heated massage pad
Spray gun
Tool roll
Sandblasting gun
Combination wrench set
Metal Oil Can
Pneumatic anther puller
Garage heater
Set of anti-dirt covers
Protective film for car radio - h
Telescopic ladder
Reverse hammer for pulling out dents
Loud car horn
Wire marking kit
Rubber strip on door edge
Brake caliper pads
Mini table
Self-adhesive thermal insulation tape
Universal 1 din Android stereo
Diesel pump
Nozzles for sealing broken plastic bumpers
Breather filter

A very interesting trick.

To view all the latest YouTube videos on a YouTube channel, use this example. This will filter the URLs and only show the latest YouTube videos.

Bash
(jcartwright@localhost) 192.168.1.5 jcartwright  $ curl --silent https://www.youtube.com/feeds/videos.xml?channel_id=UCrB8o1tlLKRnPHlpSy3GBFg | htmlq link | awk -F\" '/href=/{if ($2 ~ /watch/) print $2}'
https://www.youtube.com/watch?v=KswJeeUUYug
https://www.youtube.com/watch?v=UgJerfcOp6M
https://www.youtube.com/watch?v=Hp2fyJWvJI0
https://www.youtube.com/watch?v=Hsn40q0nNdI
https://www.youtube.com/watch?v=thV6pkjgoFA
https://www.youtube.com/watch?v=THxRUU5wzXA
https://www.youtube.com/watch?v=VTHOEivNMyo
https://www.youtube.com/watch?v=vpItkznY6V8
https://www.youtube.com/watch?v=1--Ee-PKXMY
https://www.youtube.com/watch?v=3ZkSRMelB6c
https://www.youtube.com/watch?v=_78VGVzsChY
https://www.youtube.com/watch?v=5OQuL_kjpBc
https://www.youtube.com/watch?v=LLvbW6Fupjg
https://www.youtube.com/watch?v=8FyYYT-gzT0
https://www.youtube.com/watch?v=4ersRixTb00

This is the most useful trick, I needed to filter the URLs so it does not show the channel URL and other unneeded content.

I am using this awk example to parse the links from the HTML.

  1. -F\": Sets the field separator to a double quote ("), which is used to separate the attributes within the HTML tags.
  2. /href=/{print $2}: This matches lines containing the href= attribute and prints the second field, which is the link URL enclosed within double quotes.
awk -F\" '/href=/{print $2}'

To filter out the unwanted extra links, I do it like this.

awk -F\" '/href=/{if ($2 !~ /watch/) print $2}'

if ($2 !~ /watch/): This condition checks if the second field (the URL) does NOT match the pattern “/watch/”. If the condition is true, the URL is printed.

I ended up using this.

awk -F\" '/href=/{if ($2 ~ /watch/) print $2}'

This will only match these lines.

Bash
https://www.youtube.com/watch?v=KswJeeUUYug
https://www.youtube.com/watch?v=UgJerfcOp6M
https://www.youtube.com/watch?v=Hp2fyJWvJI0
https://www.youtube.com/watch?v=Hsn40q0nNdI
https://www.youtube.com/watch?v=thV6pkjgoFA
https://www.youtube.com/watch?v=THxRUU5wzXA
https://www.youtube.com/watch?v=VTHOEivNMyo
https://www.youtube.com/watch?v=vpItkznY6V8
https://www.youtube.com/watch?v=1--Ee-PKXMY
https://www.youtube.com/watch?v=3ZkSRMelB6c
https://www.youtube.com/watch?v=_78VGVzsChY
https://www.youtube.com/watch?v=5OQuL_kjpBc
https://www.youtube.com/watch?v=LLvbW6Fupjg
https://www.youtube.com/watch?v=8FyYYT-gzT0
https://www.youtube.com/watch?v=4ersRixTb00

The most useful YouTube trick to get a nice list of all the latest YouTube videos on a channel.


2 thoughts on “How to get a list of all YouTube videos on a channel with yt-dlp.”

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.