You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

yt-api-wrapper

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

yt-api-wrapper

A YouTube web scraper/wrapper for fetching video metadata and search results.

1.0.4
pipPyPI
Maintainers
1

Fast and lightweight youtube scraper for python

Warning: The user/developer is solely responsible for the use of this code, I am not responsible for copyrights and YouTube restrictions. It is for educational purposes only, do not misuse it.

Installing

pip install yt-api-wrapper

How to use?

It is very simple to use and only one line. Below are some examples:

>>> from yt_api_wrapper import YouTubeAPIWrapper # Import the library
>>> yt = YouTubeAPIWrapper() # Create API wrapper
>>> yt.auto_complete('pytho') # Auto Complete example
INFO:yt_api_wrapper.yt_api_wrapper:Fetching autocomplete for query: 'pyth'
INFO:yt_api_wrapper.yt_api_wrapper:Found 14 suggestions
['python', 'pythagorean theorem', 'python download', 'python programming', 'pythagorean theorem calculator', 'python compiler', 'python online', 'python dictionary', 'pythagoras', 'python snake', 'pythagorean identities', 'python online compiler', 'pythagorean triples', 'python for loop']

>>> video = yt.get_video_info('dQw4w9WgXcQ') # Get video info with one line
INFO:yt_api_wrapper.yt_api_wrapper:Fetching video info for ID: dQw4w9WgXcQ
INFO:yt_api_wrapper.yt_api_wrapper:Successfully extracted info for video: Rick Astley - Never Gonna Give You Up (Official Video) (4K Remaster)

>>> results = yt.search_videos('python course') # Search videos
INFO:yt_api_wrapper.yt_api_wrapper:Searching YouTube for videos: 'python course'

>>> channel = yt.get_channel_info('UCuAXFkgsw1L7xaCfnd5JJOw')

# Asynchronous usage

>>> import asyncio
>>> from yt_api_wrapper import AsyncYouTubeAPIWrapper
>>> yt_async = AsyncYouTubeAPIWrapper()
>>> async def main():
...     # Asynchronous auto complete
...     suggestions = await yt_async.auto_complete('pytho')
...     print(suggestions)
...     # Asynchronous video info
...     video_info = await yt_async.get_video_info('dQw4w9WgXcQ')
...     print(video_info)
...     # Asynchronous search videos
...     search_results = await yt_async.search_videos('python course')
...     print(search_results)
...     # Asynchronous channel info
...     channel_info = await yt_async.get_channel_info('UCuAXFkgsw1L7xaCfnd5JJOw')
...     print(channel_info)

>>> asyncio.run(main())

Faster JSON Parsing

You can install this library with the orjson optional dependency for faster response parsing:

pip install yt-api-wrapper[orjson]

This will install the orjson library, which is used for faster JSON parsing. If you don't want to use orjson, you can install the library without it:

How to Contribute

  • Fork the repository
  • Create a new branch (git checkout -b feature-name)
  • Make your changes
  • Commit your changes (git commit -m 'Add feature')
  • Push to the branch (git push origin feature-name)
  • Open a Pull Request

FAQs

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts