Skip to main content

A Python library for collecting YouTube data including channel videos, hashtag videos, keyword search, comments, and channel profiles

Project description

YouTube Collector

A Python library for collecting YouTube data including channel videos, hashtag videos, keyword search, comments, and channel profiles.

Features

  • Collect posts by hashtag
  • Collect tagged posts for a user
  • Collect posts from brand accounts
  • Collect comments from posts
  • Support for multiple API providers (RocketAPI and SocialAPI4)
  • Rate limiting and error handling
  • Pagination support
  • Time-based filtering

Installation

pip install youtube-collector

Usage

Collecting Channel Videos

from youtube_collector import YouTubeBrandCollector

collector = YouTubeBrandCollector(api_key="your_api_key")
videos = collector.collect_brand_posts(channel_id="your_channel_id")
print(videos)

Collecting Hashtag Videos

from youtube_collector import YouTubeHashtagCollector

collector = YouTubeHashtagCollector(api_key="your_api_key")
videos = collector.collect_posts_by_hashtag(hashtag_key="your_hashtag")
print(videos)

Collecting Keyword Videos

from youtube_collector import YouTubeKeywordCollector

collector = YouTubeKeywordCollector(api_key="your_api_key")
videos = collector.collect_posts_by_keyword(keyword="your_keyword")
print(videos)

Collecting Comments

from youtube_collector import YouTubeCommentCollector

collector = YouTubeCommentCollector(api_key="your_api_key")
comments = collector.collect_comments(video_id="your_video_id")
print(comments)

Collecting Channel Profile

from youtube_collector import YouTubeProfileCollector

collector = YouTubeProfileCollector(api_key="your_api_key")
profile = collector.collect_profile(channel_id="your_channel_id")
print(profile)

Collecting Recent Videos

from youtube_collector import YouTubeRecentPostCollector

collector = YouTubeRecentPostCollector(api_key="your_api_key")
videos = collector.collect_recent_posts(channel_id="your_channel_id")
print(videos)

Configuration

The library supports various configuration options:

  • api: Choose between "rocketapi" or "social4" (default: "rocketapi")
  • max_hashtag_post_retry: Maximum retries for hashtag posts (default: 3)
  • max_tagged_post_retry: Maximum retries for tagged posts (default: 3)
  • max_brand_post_retry: Maximum retries for brand posts (default: 3)
  • max_comment_retry: Maximum retries for comments (default: 3)
  • rate_limit_delay: Delay between API calls in seconds (default: 2)

Error Handling

The library includes built-in error handling and retry mechanisms:

  • Automatic retry on API failures
  • Rate limiting to prevent API throttling
  • Time-based filtering to limit data collection
  • Exception handling for malformed responses

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

This project is licensed under the MIT License - see the LICENSE file for details.

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

youtube_collector-0.0.1.tar.gz (9.8 kB view details)

Uploaded Source

Built Distribution

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

youtube_collector-0.0.1-py3-none-any.whl (16.3 kB view details)

Uploaded Python 3

File details

Details for the file youtube_collector-0.0.1.tar.gz.

File metadata

  • Download URL: youtube_collector-0.0.1.tar.gz
  • Upload date:
  • Size: 9.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.9.6

File hashes

Hashes for youtube_collector-0.0.1.tar.gz
Algorithm Hash digest
SHA256 059872a3d3ab939bd2584d8bcffdf8770c9ab4d8cca679862e9756ac95bf13e5
MD5 254689de41627b2ee670da07acd169c1
BLAKE2b-256 6a54b062563688fad4a4c070f076ccc1c7f6bac09411708607150bf67c47ef0d

See more details on using hashes here.

File details

Details for the file youtube_collector-0.0.1-py3-none-any.whl.

File metadata

File hashes

Hashes for youtube_collector-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 bdaa449d2d6b9f388d3f58535d54e5e91f8e656f90449e38e101a954a6eccf65
MD5 47a76499660f44958c30f0e50a1ddf8d
BLAKE2b-256 c3eb70a18d84658b062533081bc9c1738956f6669297921b10cb44fae9514bc1

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