heesoo-jang / youtube-stat2data

youtube-stat2data lets you easily download the list of videos and their metadata of channels you're interested in.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

📥 youtube-stat2data

youtube-stat2data lets you easily download the list of videos and their metadata as a csv file

  • Example of an output data table (pulled from CNN's Youtube channel)
title video_id video_description published_date like_count favorite_count view_count comment_count
Chinese tennis star denies making sexual assault allegation 3dUlbiAojo4 Chinese tennis star Peng Shuai has denied making sexual assault allegations against a retired Communist Party leader, following more than a month of growing concern about her safety and whereabouts that led to the Women's Tennis Association pulling out of China. CNN's Selina Wang has more. #CNN #News 2021-12-20T14:54:45Z 1093 0 82726 1343
How close is the US to civil war? Closer than you think, study says 6AS11SbvLmM CNN's Michael Holmes talks with Professor Barbara Walter of the University of California San Diego about her work on a task force that tries to predict where outside the US a civil war is likely to break out. Walter says the two best predictors of whether violence is likely to occur currently exist in the US and have emerged at a "surprisingly fast rate." #CNN #News 2021-12-20T13:14:16Z 8826 0 51557 345

(back to top)

Description

  • Interested in downloading a set of metadata from videos of a specific Youtube channel?
  • youtube-stat2data is a simple tool that is solely built for that purpose.
  • With just the channel ID, you can get a full list of meta data including title, published date, video_description, view_count , like_count, favorite_count , and comment_count.
  • youtube-stat2data uses YouTube Data API (v3) and Youtube Analytics API.

(back to top)

QnA

  1. Why did you iterate the Youtube API request monthly? Can't you just get all the Youtube data at one request?
  • Based on my experience, the Youtube API does not seem to give more than 501 videos at once. So, even though a Youtube channel has more than 10,000 videos uploaded on its channel, one API request will give less than 501 videos at once. I circumvented this issue by putting API requests for each month over the period of time I wanted.
  1. Why do I need 3 API keys to run youtube-stat2data?
  • If you're pulling more than 5,000 videos (which I believe would often be the case), you immediately hit the quota limit with one API key. In this situation, the API request would not provide you with all the data you need. Google allows users to create multiple API keys for free, so there's no loss on your side. Using multiple API keys and rotating them helps circumvent the issue of meeting the quota limit right away.

(back to top)

Getting Started

To use youtube-stat2data, you need to know your Youtube API Key(s) and the channel ID of the Youtube channel you want to get data from.

How to get Youtube_API_Key(s)

How to get the channel ID

channel_id you would use to pull the metadata is different from the name of the channel.

  1. If you go to the homescreen of a Youtube channel, the URL link will include the name of the channel. For example, the url link of CNN's Youtube channel is youtube.com/user/CNN in the following screenshot. screenshot1

  2. Click on one of the videos of the youtube channel. The new URL link is for that specific video (the red box). Click on the name of the channel below the video, which is the one directed by the red arrow in the image below. screenshot1

  3. You are now back on the homescreen of the Youtube channel again, but you get a different URL. The last part of this URL is the channel ID. For example, the new URL link for CNN's Youtube channel is https://www.youtube.com/channel/UCupvZG-5ko_eiXAupbDfxWw (see image below). The channel ID for CNN's Youtube channel is "UCupvZG-5ko_eiXAupbDfxWw". screenshot1

(back to top)

Reference

Interested in using youtube-stat2data and citing my GitHub Repository? This WikiHow page shows you how to cite a GitHub Repository.

(back to top)

License

Distributed under the MIT License. See LICENSE.txt for more information.

(back to top)

Contact

Heesoo Jang - @HeesooJang2

(back to top)

About

youtube-stat2data lets you easily download the list of videos and their metadata of channels you're interested in.

License:MIT License


Languages

Language:Python 100.0%