Skip to main content

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:

  • urllib
  • google-api-python-client
  • google_auth_oauthlib
  • google

Install

It can be installed using pip:

pip install youtube-easy-api

Make sure the pip is upgraded to the latest version.

Usage

You can search Youtube service using a keyword, and 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 = 0
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.

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

youtube_easy_api-0.0.5.tar.gz (4.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

youtube_easy_api-0.0.5-py3-none-any.whl (4.8 kB view details)

Uploaded Python 3

File details

Details for the file youtube_easy_api-0.0.5.tar.gz.

File metadata

  • Download URL: youtube_easy_api-0.0.5.tar.gz
  • Upload date:
  • Size: 4.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.2.0.post20200714 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/3.8.3

File hashes

Hashes for youtube_easy_api-0.0.5.tar.gz
Algorithm Hash digest
SHA256 3f2fe5fd15cab1eb05c82d85ffb48029ccacc627940e53c739e1b3239ac12471
MD5 1db5f09a74c058a13273ac272ec6994d
BLAKE2b-256 9f974de2156c8b81f9749f37154d86a7d61ec6323ae2414f86d252670807ef27

See more details on using hashes here.

File details

Details for the file youtube_easy_api-0.0.5-py3-none-any.whl.

File metadata

  • Download URL: youtube_easy_api-0.0.5-py3-none-any.whl
  • Upload date:
  • Size: 4.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.2.0.post20200714 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/3.8.3

File hashes

Hashes for youtube_easy_api-0.0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 7eb01f3ce072c5a77afdcb616f2d12671635607a29dcea12a2a40de17ec05a88
MD5 10c31bc38932f7b9029280a501c026df
BLAKE2b-256 462bb6bdcd9939040150a1998d729c4ac3394ddde7eb445ff32312e289c84835

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page