RUVIDEO
Поделитесь видео 🙏

How to use an API with Python | Use YouTube Data API to get channel statistics and metadata

Using the YouTube data API v3, and Python code, I show the code that collects YouTube channel statistics, likes, view count, subscriber count and a bit more. The process explained here is similar if you want to write Python code to work with other APIs, so although some of the names are YouTube specific, the method is the same for working with any API.

The output is written to a CSV, using csv.Dictwriter to map dictionaries onto output rows.


⏵My code starts at 6:11
⏵Error running from IDE at 26:47
⏵Watch testing from CLI at 27:52
⏵Talking about API quotas at 33:05


This code makes use of the 'get' function when we do not know whether a key : value pair will exist or not. Using 'get' stops us getting 'Key not found'.


Also I demonstrate that editors can throw errors which you don't get if you run the script directly from the CLI.

I show you where to get example code, where to test your code, and explain the logic to get the 'resources' and select the relevant values to write to your output file.

You also get to see csv.Dictwriter being used, and only writing the headers once. There was an error early in the video where the comments weren't appearing in the final csv, I removed a #, and then it worked!

It only prints the first comment however, so I will alter the code, and either put all the comments into one cell, on one row - very difficult to read - or make a new row for each comment, but this will give many rows with duplicate video_id's. I may opt for the latter as I would make it more suitable for future use with a database, rather than CSV.


Useful reference:
⏵https://github.com/youtube/api-samples
⏵https://github.com/youtube/api-samples/blob/master/python/comment_threads.py

✔ Code available at : https://github.com/RGGH/rng/blob/master/youtube-download-comments.py
✔ See my other YouTube API code here : https://github.com/RGGH/rng


☕☕☕ Buy Dr Pi a Coffee...or Tea! : https://www.buymeacoffee.com/DrPi ☕☕☕

Что делает видео по-настоящему запоминающимся? Наверное, та самая атмосфера, которая заставляет забыть о времени. Когда вы заходите на RUVIDEO, чтобы посмотреть онлайн «How to use an API with Python | Use YouTube Data API to get channel statistics and metadata», вы рассчитываете на нечто большее, чем просто загрузку плеера. И мы это понимаем. Контент такого уровня заслуживает того, чтобы его смотрели в HD 1080, без дрожания картинки и бесконечного буферизации.

Честно говоря, Rutube сегодня — это кладезь уникальных находок, которые часто теряются в общем шуме. Мы же вытаскиваем на поверхность самое интересное. Будь то динамичный экшн, глубокий разбор темы от любимого автора или просто уютное видео для настроения — всё это доступно здесь бесплатно и без лишних формальностей. Никаких «заполните анкету, чтобы продолжить». Только вы, ваш экран и качественный поток.

Если вас зацепило это видео, не забудьте взглянуть на похожие материалы в блоке справа. Мы откалибровали наши алгоритмы так, чтобы они подбирали контент не просто «по тегам», а по настроению и смыслу. Ведь в конечном итоге, онлайн-кинотеатр — это не склад файлов, а место, где каждый вечер можно найти свою историю. Приятного вам отдыха на RUVIDEO!

Видео взято из открытых источников Rutube. Если вы правообладатель, обратитесь к первоисточнику.