Posted: . At: 10:14 AM. This was 4 months ago. Post ID: 18959
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.



Sponsored



How to get video information from YouTube in JSON format and parse it.


Getting video information from the YouTube website is very easy, it is possible to directly download a JSON file containing all information about a YouTube video. The example below shows how to get the video ID, title, description, and duration info from a certain YouTube video.

Bash
(jcartwright@localhost) 192.168.1.5 Documents  $ yt-dlp https://www.youtube.com/watch?v=3ZkSRMelB6c --skip-download --dump-single-json --no-check-certificate --restrict-filenames --ignore-no-formats-error | jq -r '.id,.title,.description,.duration_string,.release_date'
3ZkSRMelB6c
Snake Giveaway 🐍
Regular Donations: https://streamelements.com/bhdonos/tip
Special Donations: https://streamelements.com/bhdonos_special/tip
Website: https://www.BuddhismHotline.org/
Discord: https://discord.com/invite/vs44Yc3FZ8

No animals were harmed in this livestream, Jones runs an animal rescue and is trained to handle these snakes.
2:04:00
20231219

This is the command I used.

Bash
yt-dlp https://www.youtube.com/watch?v=3ZkSRMelB6c --skip-download --dump-single-json\
 --no-check-certificate --restrict-filenames --ignore-no-formats-error | jq -r \
 '.id,.title,.description,.duration_string,.release_date'

Here is another example, this will get the resolution as well.

Bash
(jcartwright@localhost) 192.168.1.5 Documents  $ yt-dlp https://www.youtube.com/watch?v=3ZkSRMelB6c --skip-download --dump-single-json --no-check-certificate --restrict-filenames --ignore-no-formats-error | jq -r '.id,.fulltitle,.description,.duration_string,.release_timestamp,.format_note,.resolution'
3ZkSRMelB6c
Snake Giveaway 🐍
Regular Donations: https://streamelements.com/bhdonos/tip
Special Donations: https://streamelements.com/bhdonos_special/tip
Website: https://www.BuddhismHotline.org/
Discord: https://discord.com/invite/vs44Yc3FZ8

No animals were harmed in this livestream, Jones runs an animal rescue and is trained to handle these snakes.
2:04:00
1703026892
1080p60+medium
1920x1080

This shows that it is easy to download a JSON file listing all information about a YouTube video. This might be very useful to someone out there.

And, using rsstail it is easy to list the last 20 videos on a YouTube channel.

Bash
(jcartwright@localhost) 192.168.1.5 Documents  $ rsstail -n 40 -t -p -l -u https://www.youtube.com/feeds/videos.xml?channel_id=UCrB8o1tlLKRnPHlpSy3GBFg
2023/12/22 10:07:35  Pubdate: 2023/12/21 20:47:28  Title: Christmas Cancelled ❌🎅                              Link: https://www.youtube.com/watch?v=1--Ee-PKXMY  
2023/12/22 10:07:35  Pubdate: 2023/12/21 05:08:26  Title: Snake Giveaway 🐍                                    Link: https://www.youtube.com/watch?v=3ZkSRMelB6c  
2023/12/22 10:07:35  Pubdate: 2023/12/19 18:13:14  Title: Praising the Grinch ❌🎄                              Link: https://www.youtube.com/watch?v=_78VGVzsChY  
2023/12/22 10:07:35  Pubdate: 2023/12/18 04:09:09  Title: Respect your Elders.                                Link: https://www.youtube.com/watch?v=5OQuL_kjpBc  
2023/12/22 10:07:35  Pubdate: 2023/12/16 10:30:14  Title: Helping the "Homeless"                              Link: https://www.youtube.com/watch?v=LLvbW6Fupjg  
2023/12/22 10:07:35  Pubdate: 2023/12/16 23:53:28  Title: I'M BEING BLACKMAILED.                              Link: https://www.youtube.com/watch?v=8FyYYT-gzT0  
2023/12/22 10:07:35  Pubdate: 2023/12/10 03:28:26  Title: Stop Being Poor.                                    Link: https://www.youtube.com/watch?v=4ersRixTb00  
2023/12/22 10:07:35  Pubdate: 2023/12/17 09:16:48  Title: Daddy Love You?                                     Link: https://www.youtube.com/watch?v=GgvdKYATzf8  
2023/12/22 10:07:35  Pubdate: 2023/12/17 07:05:05  Title: BAN GTA 6                                           Link: https://www.youtube.com/watch?v=UkgBU8nXggY  
2023/12/22 10:07:35  Pubdate: 2023/12/06 10:09:57  Title: Come Out 🌈                                          Link: https://www.youtube.com/watch?v=nYq8s8iq63s  
2023/12/22 10:07:35  Pubdate: 2023/12/03 09:24:52  Title: How to Make Friends.                                Link: https://www.youtube.com/watch?v=s3UxCs8ntSI  
2023/12/22 10:07:35  Pubdate: 2023/12/01 12:09:39  Title: Mathis Peace Talk 🕊️                                Link: https://www.youtube.com/watch?v=g-3KBEEqH4E  
2023/12/22 10:07:35  Pubdate: 2023/12/08 22:38:58  Title: I'm Suing You.                                      Link: https://www.youtube.com/watch?v=pAjqLcqBD9I  
2023/12/22 10:07:35  Pubdate: 2023/11/26 06:11:49  Title: Thanksgiving is Racist.                             Link: https://www.youtube.com/watch?v=RLuQburQNwI  
2023/12/22 10:07:35  Pubdate: 2023/11/22 07:00:10  Title: Share your Feelings.                                Link: https://www.youtube.com/watch?v=xUR87oBJDKQ

This command is very simple.

Bash
rsstail -n 40 -t -p -l -u https://www.youtube.com/feeds/videos.xml?channel_id=UCrB8o1tlLKRnPHlpSy3GBFg

This makes it easy, using xmlstarlet is very complicated.

This is all done without needing the YouTube API and a key. So very handy indeed.


Leave a Comment

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