The API Documentation / Help

If you want in depth details of functions and class here is the docs.

YouTube Class

class youtube.Video(url: str, proxy: str = '', id: int = 1, http: Optional[youtube.Connection.HTTP] = None, name: str = '')[source]

Construct a Video object.

Parameters
  • url (str) – Pass youtube valid video url. ie. https://www.youtube.com/watch?v=9NQqaKz7eyI

  • proxy (str) –

    (optional) pass the proxy url example:

    socks5://admin:admin@127.0.0.1:9050, http://admin:admin@127.0.0.1:8000, https://127.0.0.1:8000

  • id (object) – (optional) Video class id just to identify easily.

  • id – (optional) Pass the HTTP object.

  • name (int) – (optional) if you want specify name.

Return type

None

Returns

None

property author: str

This will return the video author.

Return type

str

Returns

str

property channel: str

This will return the video channel id.

Return type

str

Returns

str

property description: str

This will return the video description.

Return type

str

Returns

str

property get_dict

This will return the raw dict of video streams urls

property keywords: List[str]

This will return the video keywords.

Return type

List[str]

Returns

List[str]

property length: int

This will return the video time in second.

Return type

int

Returns

int

property streams: youtube.Stream.Queue

Will returns Queue

Return type

Queue

Returns

Returns the Queue object

property thumbnail: str

This will return the video thumbnail.

Return type

str

Returns

str

property title: str

This will return the video title.

Return type

str

Returns

str

property videoId: str

This will return the video id.

Return type

str

Returns

str

property views: int

This will return the total video views.

Return type

int

Returns

int

PlayList Class

class youtube.PlayList(url: str, proxy: str = '', process: bool = False)[source]

Construct a PlayList

Parameters
  • url (str) – Pass youtube valid playlist url. ie. https://www.youtube.com/watch?v=9NQqaKz7eyI

  • proxy (str) –

    (optional) pass the proxy url example:

    socks5://admin:admin@127.0.0.1:9050 http://admin:admin@127.0.0.1:8000 https://127.0.0.1:8080

  • process (bool) – (optional) Process will trigger the function for making objects of Video with the list of playlist videos default (False), When (True) it will take some extra time depend on your CPU and Internet speed. Process will use 10 workers to create objects fasts.

downloadall(quality: int) None[source]

This is to download all playlist videos, remember this will download all videos synchronizly. Thiw function will download one file (audio/video) you may not satisfied with the quality.

Quality

Value

HIGH

0

MID

1

LOW

2 or n

Parameters

quality (int) – Pass the quality type

property get_dict

This will return the list of Video if available or will just return the dict of vid and name, Availability of Video objects is depend on your PlayList(url,process=False), process will process all videos to Video objects.

property get_object

This will return the list of Video objects, even when you process=False.

processing()[source]

Processing will process all videos to Video object

Stream Class

class youtube.Stream(stream: Dict[Any, Any], name: str)[source]

Here we will process Stream

Parameters
  • stream (Dict[Any,Any]) – singal dict of stream json

  • name (str) – Pass the video title

check(a: str) str[source]

Here we will take a and return the values, a could be qualityLabel or type qualityLabel: will return resolution of the video type: will return video, audio or both

download(dire: str = '', name: str = '', status: bool = False, connection: int = 8, chunk: int = 5120) youtube.Downloader.Download[source]

This will return the Download

Parameters
  • name (str) – (optional) Pass the name of file name.

  • dire (str) – (optional) Pass the dir for output file with excluding filename.

  • status (bool) – (optional) Pass if you want to enable process bar. Default[False]

  • connection (int) – (optional) Pass number is connection to be create. Default[8]

  • chunk (int) – (optional) Pass the chunk/buffer size for accepting packets. Default[5120]

Return type

Download

Returns

Download object

property format: str

This will return the stream format

Return type

str

Returns

format of video in str

property is_audio: bool

Check is the stream is audio

Return type

bool

Returns

check the stream and return bool(true, false)

property is_both: bool

Check is the stream has audio/video

Return type

bool

Returns

check the stream and return bool(true, false)

property is_video: bool

Check is the stream is video

Return type

bool

Returns

check the stream and return bool(true, false)

property itag: int

This will return the stream format

Return type

int

Returns

itag of video in int

property url: str

This will return the URL of thie Stream

Return type

str

Returns

url of video in str

Queue Class

class youtube.Queue(data: List[youtube.Stream.Stream], repeat: bool = False)[source]

We will manage the Stream queues here

Parameters
  • data (List[Stream]) – pass the dict of Stream objects.

  • repeat (bool) – if you re generating Queue object from inside the function.

property all: List[youtube.Stream.Stream]

all will return the Stream objects in list

Return type

List of Stream

Returns

list of Stream objects

property ffhigh: youtube.Stream.FFMPEG

Processing with highest quality video and audio

Return type

FFMPEG

Returns

FFMPEG object

property fflow: youtube.Stream.FFMPEG

Processing with lowest quality video and audio

Return type

FFMPEG

Returns

FFMPEG object

property ffmid: youtube.Stream.FFMPEG

Processing with mid quality video and audio

Return type

FFMPEG

Returns

FFMPEG object

ffresolution(quality: str) youtube.Stream.FFMPEG[source]

Processing audio/video depend on resolution

Parameters

quality (int) – pass the quality type, Examples. (‘144’, ‘240’, ‘360’, ‘480’, ‘720’, ‘1080’) more/less depend on your video.

Return type

FFMPEG

Returns

FFMPEG object

format(f: str) youtube.Stream.Queue[source]

This will return all streams with format match

Parameters

f (str) – pass the format type ie. ‘mp4’.

Return type

Queue

Returns

Queue object

property get_audios: youtube.Stream.Queue

This will return all audios stream without video.

Return type

Queue

Returns

Queue object

property get_both: youtube.Stream.Queue

This will return all audios/video stream.

Return type

Queue

Returns

Queue object

get_itag(i: int) Optional[youtube.Stream.Stream][source]

This will return the stream, matched with i <arg>

Parameters

i (int) – pass the itag id for match.

Return type

Union[Stream, None]

Returns

Will return Stream or None

property get_videos: youtube.Stream.Queue

This will return all videos stream without audio.

Return type

Queue

Returns

Queue object

high(ff: bool = False) youtube.Stream.Stream[source]

High will return the highest quality stream.

Parameters

ff (bool) – this input is not for the user please ignore.

Return type

Stream

Returns

Stream object

static init(data: List[youtube.Stream.Stream]) List[youtube.Stream.Stream][source]

Here we will return the List[Stream] after removing ‘ignore_itag’

low(ff: bool = False) youtube.Stream.Stream[source]

Low will return the lowest quality stream.

Parameters

ff (bool) – this input is not for the user please ignore.

Return type

Stream

Returns

Stream object

mid(ff: bool = False) youtube.Stream.Stream[source]

Mid will return the normal quality stream.

Parameters

ff (bool) – this input is not for the user please ignore.

Return type

Stream

Returns

Stream object

resolution(quality) youtube.Stream.FFMPEG[source]

Processing audio/video depend on resolution

Return type

FFMPEG

Returns

FFMPEG object

FFMPEG Class

class youtube.FFMPEG(av: List[youtube.Stream.Stream])[source]

Here we will download 2 stream audio/video, and copy them in one file with ffmpeg

Parameters

av (List[Stream]) – pass the stream of audio and video in list,

Return type

None

Returns

Nothing will get return

check_ffmpeg()[source]

Checking if FFMPEG installed or not

Return type

bool

Returns

check status in (True/False)

download(dire: str = '', name: str = '', status: bool = False, connection: int = 8, chunk: int = 5120) str[source]

This will return bool value as video download convert status`

Parameters
  • name (str) – (optional) Pass the name of file name.

  • dire (str) – (optional) Pass the dir for output file with excluding filename.

  • status (bool) – (optional) Pass if you want to enable process bar. Default[False]

  • connection (int) – (optional) Pass number is connection to be create. Default[8]

  • chunk (int) – (optional) Pass the chunk/buffer size for accepting packets. Default[5120]

Return type

str

Returns

name of the file

Cipher Class

class youtube.Cipher(js: str)[source]

Here we will decrypt the signature of youtube videos

js is the raw string javascript of base.js

Parameters

js (str) – pass javascript of base.js

Return type

None

Returns

nothing

static Func_check(s: str) Callable[[List[str], int], List[str]][source]

This will check compair the js function and return the python object

Parameters

s (str) – pass the js fuction

Return type

object

Returns

will return python object

example:

>>> Func_check('TY:function(a){a.reverse()')
<function Reverse at 0x7fd281937710>
static Get_funs(js: str) List[str][source]

Will return the method of encryption

Parameters

js (str) – pass the raw js of base.js

Return type

List[str]

Returns

the decipher method/algorithm in list of strings

example:

>>> Get_funs(js)
... ['wv.TY(a,37)', 'wv.vd(a,10)', 'wv.TY(a,7)', 'wv.A3(a,1)', 'wv.vd(a,13)', 'wv.A3(a,2)', 'wv.vd(a,15)']
Get_funs_objects(funs: List[str]) Dict[str, Callable[[List[str], int], List[str]]][source]

This function will return the dict with javascript function name and object

Parameters

funs (List[str]) – pass the list of function

Return type

Dict[str, Callable[[List[str],int], List[str]]]

Returns

dict of function name and function object

example:

>>> Get_funs_objects(['TY:function(a){a.reverse()}', 'A3:function(a,b){a.splice(0,b)}',
        'vd:function(a,b){var c=a[0];a[0]=a[b%a.length];a[b%a.length]=c}}'])
{'TY': <function Reverse at 0x7f0f9cfce7a0>, 'A3': <function Splice at 0x7f0f9cfd63b0>, 
        'vd': <function Switch at 0x7f0f9cfd6710>}
static Get_js_funcs(js: str, var: str) List[str][source]

will return the js raw function as string

Parameters
  • js (str) – raw js html

  • var (str) – js variable name

Return type

List[str]

Returns

the variable content/program from base.js

Example.

>>> Get_js_funcs(js, var)
... ['TY:function(a){a.reverse()', 'A3:function(a,b){a.splice(0,b)', 
        'vd:function(a,b){var c=a[0];a[0]=a[b%a.length];a[b%a.length]=c}']
Get_signature(sig: List[str]) str[source]

This function will return decipher signarure

Parameters

sig (list[str]) – cipher signature provied by youtube

Return type

str

Returns

will return decipher signature

static Parsec_js_methods(s: str) Tuple[str, int][source]

This the parse the methods

Example:

>>> Parsec_js_methods("wv.TY(a,37)")
('TY',37)

Download Class

class youtube.Download(url: str, dire: str = '', name: str = '', status: bool = False, connection: int = 8, chunk: int = 5120)[source]

This Download will download streams with multi-connections.

Parameters
  • url (str) – Pass the download link

  • name (str) – (optional) Pass the name of file name.

  • dire (str) – (optional) Pass the dir for output file with excluding filename.

  • status (bool) – (optional) Pass if you want to enable process bar. Default[False]

  • connection (int) – (optional) Pass number is connection to be create. Default[8]

  • chunk (int) – (optional) Pass the chunk/buffer size for accepting packets. Default[5120]

Return type

str

Returns

the file name

start() str[source]

Start will fire up the downloading

Search Class

class youtube.Search(query: str, country: str = '', proxy: str = '', process: bool = False)[source]

This will search your query on youtube and will return videos.

Parameters
  • query (str) – Pass the query for search.

  • country (str) – (optional) Pass the ISO 2 country code.

  • proxy (str) –

    (optional) pass the proxy url example:

    socks5://admin:admin@127.0.0.1:9050 http://admin:admin@127.0.0.1:8000 https://127.0.0.1:8080

  • process (bool) – (optional) Process will trigger the function for making objects of Video with the list of playlist videos default (False), When (True) it will take some extra time depend on your CPU and Internet speed. Process will use 10 workers to create objects fasts.

Return type

None

Returns

None

property first

Will return the first search video.

Return type

Video

Returns

This will return Video of first search video.

property get_dict

This will return the list of Video if available or will just return the dict of vid and name, Availability of Video objects is depend on your Search(query,process=False), process will process all videos to Video objects.

property get_object

This will return the list of Video objects, even when you process=False.

processing()[source]

Processing will process all videos to Video object