Giter Site home page Giter Site logo

aioyoutube.py's Introduction

aioyoutube.py

An asynchronous python API wrapper for the YouTube Data API. Note, this repository and package is now archived. There are no guarantees the code and information is up to date.

Features

  • Full coverage of all functionality in the YouTube Data API reference guide.
  • Naming convention that matches official documentation.
  • Option to enable debugging feature.
  • Utilizes async and await python syntax.

Installing

pip install aioyoutube.py

Setup

  1. Access the Google API console with a google account.
  2. Create a project in the Google API console.
  3. Enable project access to the YouTube Data API.
  4. Create your credentials and generate an API key.
  5. If applicable, register and generate OAuth 2.0 credentials.

Basic Example

import os
import sys
import asyncio
from aioyoutube import YouTubeClient
from dotenv import load_dotenv

# load secret
load_dotenv()
YOUTUBE_API_KEY = os.getenv('YOUTUBE_API_KEY')

# returns links to the terms entered as arguments to the program
# ex search.py surfing violin
async def search(terms: list):

    client = YouTubeClient.from_connect(key=YOUTUBE_API_KEY)

    tasks = []
    for term in terms:
        tasks.append(client.search(search=term))
    
    results = await asyncio.gather(*tasks)
    for result in results:
        for item in result.json['items']:
            print('https://www.youtube.com/watch?v=' + item['id']['videoId'])
    await client.close()

if __name__ == '__main__':    

    loop = asyncio.get_event_loop()
    loop.run_until_complete(search(sys.argv[1:]))

Requirements

This library requires the aiohttp library which is distrubuted under the Apache 2.0 license.

License

aioyoutube.py is offered under the MIT License.

Links

aioyoutube.py's People

Contributors

im-mde avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar

aioyoutube.py's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.