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.
(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.
-F\"
: Sets the field separator to a double quote ("
), which is used to separate the attributes within the HTML tags./href=/{print $2}
: This matches lines containing thehref=
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.
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.
Oh WordPress ruined the command formatting. I think you can figure this out.
Both things can also be achieved with just yt-dlp.
Print chapter titles:
yt-dlp –print “%(chapters.:.title)#l” https://www.youtube.com/watch?v=o1jv509M8Zg
Print 15 latest videos:
yt-dlp –flat-playlist –lazy-playlist -I :15 –print url https://www.youtube.com/playlist?list=UUrB8o1tlLKRnPHlpSy3GBFg