Skip to main content

YouTube search without official API - fast, reliable, and free

Project description

irotechlab-yt-search

PyPI version Python 3.7+ License: MIT

YouTube search without official API - fast, reliable, and completely free.

📌 Features

  • 🔍 Search videos, channels, and playlists without API key
  • Async/await support for high performance
  • 🎯 Filter by type (video, channel, playlist, live, movie)
  • 📊 Sort by relevance, upload date, view count, rating
  • 🌍 Region and language support
  • 🔄 Pagination for unlimited results
  • 📹 Video info extraction (title, channel, views, likes, comments)
  • 💬 Comment scraping with replies
  • 📑 Chapter extraction
  • 🛡️ Rate limiting and retry logic
  • 📦 Clean dataclass models (Video, Channel, Playlist)

📦 Installation

pip install irotechlab-yt-search

Or install from source:

git clone https://github.com/irotechlab/irotechlab-yt-search
cd irotechlab-yt-search
pip install -e .

🚀 Quick Start

import asyncio
from irotechlab_yt_search import YouTubeSearch

async def main():
    search = YouTubeSearch()
    
    # Search for videos
    videos = await search.search("python programming", max_results=5)
    
    for video in videos:
        print(f"{video.title}")
        print(f"  Channel: {video.channel}")
        print(f"  Views: {video.views}")
        print(f"  URL: {video.url}\n")
    
    await search.close()

asyncio.run(main())

📹 Video Info

from irotechlab_yt_search import VideoInfo, extract_video_id

async def get_video_info():
    info = VideoInfo()
    
    video_url = "https://youtube.com/watch?v=VIDEO_ID"
    video_id = extract_video_id(video_url)
    
    details = await info.get_video_info(video_id)
    
    print(f"Title: {details['title']}")
    print(f"Views: {details['views']}")
    print(f"Likes: {details['likes']}")
    print(f"Comments: {details['comment_count']}")
    
    await info.close()

📺 Channel Info

from irotechlab_yt_search import ChannelInfo

async def get_channel():
    channel_info = ChannelInfo()
    channel = await channel_info.get_channel_info("@channelname")
    
    print(f"Name: {channel['name']}")
    print(f"Subscribers: {channel['subscribers']}")
    print(f"Videos: {channel['video_count']}")
    
    await channel_info.close()

📋 Playlist Info

from irotechlab_yt_search import PlaylistInfo

async def get_playlist():
    playlist_info = PlaylistInfo()
    playlist = await playlist_info.get_playlist_info("PLAYLIST_ID", max_videos=10)
    
    print(f"Title: {playlist['title']}")
    print(f"Author: {playlist['author']}")
    print(f"Videos: {playlist['video_count']}")
    
    for video in playlist['videos']:
        print(f"  - {video['title']}")
    
    await playlist_info.close()

🔍 Advanced Search

Filter by type

# Only videos
videos = await search.search(
    "python tutorial",
    filter_type="video",
    max_results=10
)

Sort results

# Sort by view count
videos = await search.search(
    "python tutorial",
    sort_by="view_count"
)

# Sort by upload date
videos = await search.search(
    "python tutorial",
    sort_by="upload_date"
)

Region and language

videos = await search.search(
    "python tutorial",
    region_code="IN",
    language="hi"
)

🛠️ API Reference

YouTubeSearch

Parameters:

  • query (str): Search query
  • max_results (int): Maximum number of results (default: 10)
  • filter_type (str): all, video, channel, playlist, movie, live
  • sort_by (str): relevance, upload_date, view_count, rating
  • region_code (str): Two-letter country code
  • language (str): Language code

Returns: List[Video]

Video Object

@dataclass
class Video:
    id: str
    title: str
    channel: str
    channel_id: Optional[str]
    url: str
    thumbnail: str
    duration: str
    duration_seconds: Optional[int]
    views: str
    view_count: Optional[int]
    published: str
    published_date: Optional[datetime]
    is_live: bool

📂 Examples

Check the examples/ directory for more usage examples:

  • basic_search.py - Simple search
  • advanced_search.py - Advanced filtering and sorting
  • all_in_one.py - Complete demo of all features

🤝 Contributing

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

📞 Support & Community

📄 License

MIT License - see LICENSE file for details

⚠️ Disclaimer

This package scrapes YouTube's internal API and may break if YouTube changes their structure. Use responsibly and respect YouTube's terms of service.


Made with ❤️ by IrotechLab

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

irotechlab_yt_search-1.0.0.tar.gz (26.4 kB view details)

Uploaded Source

Built Distribution

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

irotechlab_yt_search-1.0.0-py3-none-any.whl (29.1 kB view details)

Uploaded Python 3

File details

Details for the file irotechlab_yt_search-1.0.0.tar.gz.

File metadata

  • Download URL: irotechlab_yt_search-1.0.0.tar.gz
  • Upload date:
  • Size: 26.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for irotechlab_yt_search-1.0.0.tar.gz
Algorithm Hash digest
SHA256 aeee78d69bcb865fd82d4901b43b61b38bcee324fa96cce5c9811b37ea5efb91
MD5 e088ae7ba8968ca122f1671cea7e5c07
BLAKE2b-256 752fc41ae6969fe1731443e1e7b0dc5092f22012fb06fd8e1f3d654f88e22afa

See more details on using hashes here.

Provenance

The following attestation bundles were made for irotechlab_yt_search-1.0.0.tar.gz:

Publisher: python-publish.yml on IROTECHLAB/irotechlab-yt-search

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file irotechlab_yt_search-1.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for irotechlab_yt_search-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 86a0ea6006482380516355e6103a225ae96210e08535265a1b65cd4807c34237
MD5 d0b0242665dc22da44d64c093c9ccf26
BLAKE2b-256 c0212aab5386b276aa6207731d79aadfbe6c818a7070d4fc6f54591bd8ae063d

See more details on using hashes here.

Provenance

The following attestation bundles were made for irotechlab_yt_search-1.0.0-py3-none-any.whl:

Publisher: python-publish.yml on IROTECHLAB/irotechlab-yt-search

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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