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, seechannel_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 usingchannel_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, seechannel_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.proxies (
dict
, optional) – A dictionary with the proxies you want to use. Ex:{'https': 'http://username:password@101.102.103.104:3128'}
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
- scrapetube.get_search(query: str, limit: int | None = None, sleep: int = 1, sort_by: typing_extensions.Literal[relevance, upload_date, view_count, rating] = 'relevance', results_type: typing_extensions.Literal[video, channel, playlist, movie] = 'video', proxies: dict | None = None) Generator[dict, None, None]
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”.proxies (
dict
, optional) – A dictionary with the proxies you want to use. Ex:{'https': 'http://username:password@101.102.103.104:3128'}
- scrapetube.get_playlist(playlist_id: str, limit: int | None = None, sleep: int = 1, proxies: dict | None = None) 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.proxies (
dict
, optional) – A dictionary with the proxies you want to use. Ex:{'https': 'http://username:password@101.102.103.104:3128'}