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

TubeCtrl

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 tubectrl

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 tubectrl 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

tubectrl-0.2.0.tar.gz (13.6 kB view details)

Uploaded Source

Built Distribution

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

tubectrl-0.2.0-py3-none-any.whl (19.3 kB view details)

Uploaded Python 3

File details

Details for the file tubectrl-0.2.0.tar.gz.

File metadata

  • Download URL: tubectrl-0.2.0.tar.gz
  • Upload date:
  • Size: 13.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.3

File hashes

Hashes for tubectrl-0.2.0.tar.gz
Algorithm Hash digest
SHA256 5bc4478ee6d62b4d0a23eae59b24d4d1c0b4a4c9b253ae8aff88e90346cecdab
MD5 cf9de94d63d0255c2142c18bb8ac316a
BLAKE2b-256 0090e20337317ff926ad764d55f019d6a9a4d311f8fefd9d08a4734aa73d2926

See more details on using hashes here.

File details

Details for the file tubectrl-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: tubectrl-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 19.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.3

File hashes

Hashes for tubectrl-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7e4efb769c6a91e5c43db1fadd23f9c02a3697171c817f7923b3dcc0d2857911
MD5 0407553725fe6edaf001668510524c62
BLAKE2b-256 324e0e308fe1f4da95e43bb42a27fbcc33bedfda3a333278c9402a8dff42a4f4

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