How to search among Youtube videos and extract their metadata using an easy interface.
Project description
An Easy Wrapper for Youtube API 3.0
YouTube is one of the main sources of education, entertainment, advertisement, and much more. This service has so much data that one can use to run data science projects or build machine learning products. For example, YouTube video comments can be an excellent source of NLP projects. YouTube API enables you to search for videos matching specific search criteria but it might be a bit confusing for some people. This library provides you a very easy interface to extract Youtube video metadata including title, comments, and stats. Hope you enjoy it.
Note- You must setup your credentials before being able to use this library. To learn how to setup credentials,
read this link: Extracting YouTube Comments with YouTube API & Python.
This is an excellent post about Youtube API service, and help you step-by-step configure the credentials. You need to
enter the CREDENTIALS_PATH
when you want to initialize the youtube-easy-api
library. For more information, you can
look at the examples below.
Library
The library requires the following libraries:
- google-api-python-client
- google-auth-oauthlib
Install
It can be installed using pip:
pip install youtube-easy-api
Make sure the pip
is upgraded to the latest version.
Usage
The library currently support the methods below.
search_videos_by_keywords
get_video_details
You can search Youtube service by passing a search_keyword
to the search_videos_by_keywords
method. You will
receive an ordered lists of videos according to the search configs.
from youtube_easy_api.easy_wrapper import *
easy_wrapper = YoutubeEasyWrapper()
easy_wrapper.initialize(credentials_path=CREDENTIALS_PATH)
search_keyword = 'python'
results = easy_wrapper.search_videos_by_keywords(q=search_keyword,
part='id,snippet',
type='video',
order='relevance')
order_id = 1
video_id = results[order_id]['video_id']
print(video_id)
'_uQrJ0TkZlc'
You can also extract the metadata of a video by passing its video_id
to the method get_video_details
.
from youtube_easy_api.easy_wrapper import *
easy_wrapper = YoutubeEasyWrapper()
easy_wrapper.initialize(credentials_path=CREDENTIALS_PATH)
metadata = easy_wrapper.get_video_details(video_id='rdjnkb4ONWk')
print(metadata['title'])
'The Pink Panther Show Episode 59 - Slink Pink'
And, that's pretty much it!
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for youtube_easy_api-0.1.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3c5418775686dca84743c579a20396fe59e0dd7e9415e39cf61497441083c580 |
|
MD5 | 0feb257159f02786c59a65f3f7253544 |
|
BLAKE2b-256 | b10696afd24c08d1d7d5ae3add5f4b89ca4999b868c51c5eed105cf2b3976ba1 |