Welcome to Scrapetube’s documentation!

This module will help you scrape youtube without the official youtube api and without selenium.

With this module you can:

  • Get all videos from a Youtube channel.

  • Get all videos from a playlist.

  • Search youtube.

Reference

scrapetube.get_channel(channel_id: str | None = None, channel_url: str | None = None, channel_username: str | None = None, limit: int | None = None, sleep: float = 1, proxies: dict | None = None, sort_by: typing_extensions.Literal[newest, oldest, popular] = 'newest', content_type: typing_extensions.Literal[videos, shorts, streams] = 'videos') Generator[dict, None, None]

Get videos for a channel.

Parameters:
  • channel_id (str, optional) – The channel id from the channel you want to get the videos for. If you prefer to use the channel url instead, see channel_url below.

  • channel_url (str, optional) – The url to the channel you want to get the videos for. Since there is a few type’s of channel url’s, you can use the one you want by passing it here instead of using channel_id.

  • channel_username (str, optional) – The username from the channel you want to get the videos for. Ex. LinusTechTips (without the @). If you prefer to use the channel url instead, see channel_url above.

  • limit (int, optional) – Limit the number of videos you want to get.

  • sleep (int, optional) – Seconds to sleep between API calls to youtube, in order to prevent getting blocked. Defaults to 1.

  • sort_by (str, optional) – In what order to retrieve to videos. Pass one of the following values. "newest": Get the new videos first. "oldest": Get the old videos first. "popular": Get the popular videos first. Defaults to “newest”.

  • content_type (str, optional) – In order to get content type. Pass one of the following values. "videos": Videos "shorts": Shorts "streams": Streams

Search youtube and get videos.

Parameters:
  • query (str) – The term you want to search for.

  • limit (int, optional) – Limit the number of videos you want to get.

  • sleep (int, optional) – Seconds to sleep between API calls to youtube, in order to prevent getting blocked. Defaults to 1.

  • sort_by (str, optional) – In what order to retrieve to videos. Pass one of the following values. "relevance": Get the new videos in order of relevance. "upload_date": Get the new videos first. "view_count": Get the popular videos first. "rating": Get videos with more likes first. Defaults to “relevance”.

  • results_type (str, optional) – What type you want to search for. Pass one of the following values: "video"|"channel"|"playlist"|"movie". Defaults to “video”.

scrapetube.get_playlist(playlist_id: str, limit: int | None = None, sleep: int = 1) Generator[dict, None, None]

Get videos for a playlist.

Parameters:
  • playlist_id (str) – The playlist id from the playlist you want to get the videos for.

  • limit (int, optional) – Limit the number of videos you want to get.

  • sleep (int, optional) – Seconds to sleep between API calls to youtube, in order to prevent getting blocked. Defaults to 1.