Skip to main content

A python library that wraps around the YouTube V3 API. You can use it find and manage YouTube resources including Videos, Playlists, Channels and Comments.

Project description

youtube

Overview

A python library that wraps around the YouTube V3 API. You can use it find and manage YouTube resources including Videos, Playlists, Channels and Comments.

The library is modelled after Google's own documentation.

Requirements

  • Python 3.10+
  • Works on Linux, Windows, macOS, BSD

Installation

pip install oryks-youtube

Get started

To get started, you need a verified Google Account and Google API keys with the correct permissions.

How to Get A Google API Key

Follow the instructions in this short article to get an API key.

To get a particular video using the videos' id:

  1. Create an instance of the YouTube API passing in the path to the downloaded client secret file:
from youtube import YouTube

client_secrets_file = '/home/lyle/Downloads/secrets.json'
youtube = YouTube(client_secrets_file)
youtube.authenticate()
  1. Use the video id to find the video:
video = youtube.find_video_by_id('rfscVS0vtbw')
  1. To find many videos using their id's:
ids = ['rfscVS0vtbw', 'TFa38ONq5PY']
videos = youtube.find_videos(ids)
  1. To find the most popular videos in a given region e.g Kenya, pass in the region code:
popular_kenyan_videos = youtube.find_most_popular_video_by_region('ke')
  1. To search for videos (this returns an iterator):
from youtube.schemas import (
    SearchFilter, SearchOptionalParameters, SearchPart, YouTubeResponse, YouTubeRequest
)
from typing import Iterator
from youtube.models import Video

query: str = 'Python programming videos'
max_results: int = 10
part: SearchPart = SearchPart()
optional_parameters: SearchOptionalParameters = SearchOptionalParameters(
    q=query,
    maxResults=max_results,
    type=['video', 'playlist', 'channel']
)
search_request: YouTubeRequest = YouTubeRequest(
    part=part,
    optional_parameters=optional_parameters
)
video_iterator: Iterator = youtube.get_search_iterator(search_request)
videos: list[Video] = next(video_iterator)

Documentation and Tutorials

To learn more about the library including the documentation and tutorials, check out the libraries' documentation.

How to Contribute

To contribute, chack out the contribution guideline.

License

The API uses an MIT License

Developer

Lyle Okoth – @lylethedesigner on twitter

lyle okoth on medium

My email is lyceokoth@gmail.com

Here is my GitHub Profile

You can also find me on Linkedin

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

oryks-youtube-0.14.1.tar.gz (27.3 kB view details)

Uploaded Source

Built Distribution

oryks_youtube-0.14.1-py3-none-any.whl (49.3 kB view details)

Uploaded Python 3

File details

Details for the file oryks-youtube-0.14.1.tar.gz.

File metadata

  • Download URL: oryks-youtube-0.14.1.tar.gz
  • Upload date:
  • Size: 27.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.12

File hashes

Hashes for oryks-youtube-0.14.1.tar.gz
Algorithm Hash digest
SHA256 1053663fcaa9b4bd1ea2688d497743372c554a9502cf4cf06cac1ab32dea3370
MD5 7ba9169fd5ec7c694f803eda2e814465
BLAKE2b-256 15850bc6874ab7eda3396499c6497b4d89f9999383f9801316a58253db120420

See more details on using hashes here.

File details

Details for the file oryks_youtube-0.14.1-py3-none-any.whl.

File metadata

File hashes

Hashes for oryks_youtube-0.14.1-py3-none-any.whl
Algorithm Hash digest
SHA256 1e9db38883436d5acc9c9d1af517f9c3cc60cf2840c0bd957775731e49be1626
MD5 67163d7956d6dd342b50194ba34ea5b8
BLAKE2b-256 929b5bee89d05fe1e32c933e3e0a706b1777de218feb4309ca5bcffdbe3f257c

See more details on using hashes here.

Supported by

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