code
stringlengths
66
870k
docstring
stringlengths
19
26.7k
func_name
stringlengths
1
138
language
stringclasses
1 value
repo
stringlengths
7
68
path
stringlengths
5
324
url
stringlengths
46
389
license
stringclasses
7 values
def regex_search(pattern: str, string: str, group: int) -> str: """Shortcut method to search a string for a given pattern. :param str pattern: A regular expression pattern. :param str string: A target string to search. :param int group: Index of group to return. :rtype: ...
Shortcut method to search a string for a given pattern. :param str pattern: A regular expression pattern. :param str string: A target string to search. :param int group: Index of group to return. :rtype: str or tuple :returns: Substring pattern matches.
regex_search
python
pytube/pytube
pytube/helpers.py
https://github.com/pytube/pytube/blob/master/pytube/helpers.py
Unlicense
def setup_logger(level: int = logging.ERROR, log_filename: Optional[str] = None) -> None: """Create a configured instance of logger. :param int level: Describe the severity level of the logs to handle. """ fmt = "[%(asctime)s] %(levelname)s in %(module)s: %(message)s" date_fmt = "%H:%M:%S" ...
Create a configured instance of logger. :param int level: Describe the severity level of the logs to handle.
setup_logger
python
pytube/pytube
pytube/helpers.py
https://github.com/pytube/pytube/blob/master/pytube/helpers.py
Unlicense
def target_directory(output_path: Optional[str] = None) -> str: """ Function for determining target directory of a download. Returns an absolute path (if relative one given) or the current path (if none given). Makes directory if it does not exist. :type output_path: str :rtype: str :re...
Function for determining target directory of a download. Returns an absolute path (if relative one given) or the current path (if none given). Makes directory if it does not exist. :type output_path: str :rtype: str :returns: An absolute directory path as a string.
target_directory
python
pytube/pytube
pytube/helpers.py
https://github.com/pytube/pytube/blob/master/pytube/helpers.py
Unlicense
def uniqueify(duped_list: List) -> List: """Remove duplicate items from a list, while maintaining list order. :param List duped_list List to remove duplicates from :return List result De-duplicated list """ seen: Dict[Any, bool] = {} result = [] for item in duped_list: ...
Remove duplicate items from a list, while maintaining list order. :param List duped_list List to remove duplicates from :return List result De-duplicated list
uniqueify
python
pytube/pytube
pytube/helpers.py
https://github.com/pytube/pytube/blob/master/pytube/helpers.py
Unlicense
def generate_all_html_json_mocks(): """Regenerate the video mock json files for all current test videos. This should automatically output to the test/mocks directory. """ test_vid_ids = [ '2lAe1cqCOXo', '5YceQ8YqYMc', 'irauhITDrsE', 'm8uHb5jIGN8', 'QRS8MkLhQmM', ...
Regenerate the video mock json files for all current test videos. This should automatically output to the test/mocks directory.
generate_all_html_json_mocks
python
pytube/pytube
pytube/helpers.py
https://github.com/pytube/pytube/blob/master/pytube/helpers.py
Unlicense
def create_mock_html_json(vid_id) -> Dict[str, Any]: """Generate a json.gz file with sample html responses. :param str vid_id YouTube video id :return dict data Dict used to generate the json.gz file """ from pytube import YouTube gzip_filename = 'yt-video-%s-html.json.gz' % vi...
Generate a json.gz file with sample html responses. :param str vid_id YouTube video id :return dict data Dict used to generate the json.gz file
create_mock_html_json
python
pytube/pytube
pytube/helpers.py
https://github.com/pytube/pytube/blob/master/pytube/helpers.py
Unlicense
def __init__(self, client='ANDROID_MUSIC', use_oauth=False, allow_cache=True): """Initialize an InnerTube object. :param str client: Client to use for the object. Default to web because it returns the most playback types. :param bool use_oauth: Whether or not...
Initialize an InnerTube object. :param str client: Client to use for the object. Default to web because it returns the most playback types. :param bool use_oauth: Whether or not to authenticate to YouTube. :param bool allow_cache: Allows caching o...
__init__
python
pytube/pytube
pytube/innertube.py
https://github.com/pytube/pytube/blob/master/pytube/innertube.py
Unlicense
def cache_tokens(self): """Cache tokens to file if allowed.""" if not self.allow_cache: return data = { 'access_token': self.access_token, 'refresh_token': self.refresh_token, 'expires': self.expires } if not os.path.exists(_cache_...
Cache tokens to file if allowed.
cache_tokens
python
pytube/pytube
pytube/innertube.py
https://github.com/pytube/pytube/blob/master/pytube/innertube.py
Unlicense
def refresh_bearer_token(self, force=False): """Refreshes the OAuth token if necessary. :param bool force: Force-refresh the bearer token. """ if not self.use_oauth: return # Skip refresh if it's not necessary and not forced if self.expires > time...
Refreshes the OAuth token if necessary. :param bool force: Force-refresh the bearer token.
refresh_bearer_token
python
pytube/pytube
pytube/innertube.py
https://github.com/pytube/pytube/blob/master/pytube/innertube.py
Unlicense
def _call_api(self, endpoint, query, data): """Make a request to a given endpoint with the provided query parameters and data.""" # Remove the API key if oauth is being used. if self.use_oauth: del query['key'] endpoint_url = f'{endpoint}?{parse.urlencode(query)}' he...
Make a request to a given endpoint with the provided query parameters and data.
_call_api
python
pytube/pytube
pytube/innertube.py
https://github.com/pytube/pytube/blob/master/pytube/innertube.py
Unlicense
def browse(self): """Make a request to the browse endpoint. TODO: Figure out how we can use this """ # endpoint = f'{self.base_url}/browse' # noqa:E800 ... # return self._call_api(endpoint, query, self.base_data) # noqa:E800
Make a request to the browse endpoint. TODO: Figure out how we can use this
browse
python
pytube/pytube
pytube/innertube.py
https://github.com/pytube/pytube/blob/master/pytube/innertube.py
Unlicense
def config(self): """Make a request to the config endpoint. TODO: Figure out how we can use this """ # endpoint = f'{self.base_url}/config' # noqa:E800 ... # return self._call_api(endpoint, query, self.base_data) # noqa:E800
Make a request to the config endpoint. TODO: Figure out how we can use this
config
python
pytube/pytube
pytube/innertube.py
https://github.com/pytube/pytube/blob/master/pytube/innertube.py
Unlicense
def guide(self): """Make a request to the guide endpoint. TODO: Figure out how we can use this """ # endpoint = f'{self.base_url}/guide' # noqa:E800 ... # return self._call_api(endpoint, query, self.base_data) # noqa:E800
Make a request to the guide endpoint. TODO: Figure out how we can use this
guide
python
pytube/pytube
pytube/innertube.py
https://github.com/pytube/pytube/blob/master/pytube/innertube.py
Unlicense
def next(self): """Make a request to the next endpoint. TODO: Figure out how we can use this """ # endpoint = f'{self.base_url}/next' # noqa:E800 ... # return self._call_api(endpoint, query, self.base_data) # noqa:E800
Make a request to the next endpoint. TODO: Figure out how we can use this
next
python
pytube/pytube
pytube/innertube.py
https://github.com/pytube/pytube/blob/master/pytube/innertube.py
Unlicense
def player(self, video_id): """Make a request to the player endpoint. :param str video_id: The video id to get player info for. :rtype: dict :returns: Raw player info results. """ endpoint = f'{self.base_url}/player' query = { ...
Make a request to the player endpoint. :param str video_id: The video id to get player info for. :rtype: dict :returns: Raw player info results.
player
python
pytube/pytube
pytube/innertube.py
https://github.com/pytube/pytube/blob/master/pytube/innertube.py
Unlicense
def search(self, search_query, continuation=None): """Make a request to the search endpoint. :param str search_query: The query to search. :rtype: dict :returns: Raw search query results. """ endpoint = f'{self.base_url}/search' query = { ...
Make a request to the search endpoint. :param str search_query: The query to search. :rtype: dict :returns: Raw search query results.
search
python
pytube/pytube
pytube/innertube.py
https://github.com/pytube/pytube/blob/master/pytube/innertube.py
Unlicense
def verify_age(self, video_id): """Make a request to the age_verify endpoint. Notable examples of the types of video this verification step is for: * https://www.youtube.com/watch?v=QLdAhwSBZ3w * https://www.youtube.com/watch?v=hc0ZDaAZQT0 :param str video_id: The v...
Make a request to the age_verify endpoint. Notable examples of the types of video this verification step is for: * https://www.youtube.com/watch?v=QLdAhwSBZ3w * https://www.youtube.com/watch?v=hc0ZDaAZQT0 :param str video_id: The video id to get player info for. :rt...
verify_age
python
pytube/pytube
pytube/innertube.py
https://github.com/pytube/pytube/blob/master/pytube/innertube.py
Unlicense
def get_transcript(self, video_id): """Make a request to the get_transcript endpoint. This is likely related to captioning for videos, but is currently untested. """ endpoint = f'{self.base_url}/get_transcript' query = { 'videoId': video_id, } query.u...
Make a request to the get_transcript endpoint. This is likely related to captioning for videos, but is currently untested.
get_transcript
python
pytube/pytube
pytube/innertube.py
https://github.com/pytube/pytube/blob/master/pytube/innertube.py
Unlicense
def get_format_profile(itag: int) -> Dict: """Get additional format information for a given itag. :param str itag: YouTube format identifier code. """ itag = int(itag) if itag in ITAGS: res, bitrate = ITAGS[itag] else: res, bitrate = None, None return { "reso...
Get additional format information for a given itag. :param str itag: YouTube format identifier code.
get_format_profile
python
pytube/pytube
pytube/itags.py
https://github.com/pytube/pytube/blob/master/pytube/itags.py
Unlicense
def parse_for_all_objects(html, preceding_regex): """Parses input html to find all matches for the input starting point. :param str html: HTML to be parsed for an object. :param str preceding_regex: Regex to find the string preceding the object. :rtype list: :returns: A list...
Parses input html to find all matches for the input starting point. :param str html: HTML to be parsed for an object. :param str preceding_regex: Regex to find the string preceding the object. :rtype list: :returns: A list of dicts created from parsing the objects.
parse_for_all_objects
python
pytube/pytube
pytube/parser.py
https://github.com/pytube/pytube/blob/master/pytube/parser.py
Unlicense
def parse_for_object(html, preceding_regex): """Parses input html to find the end of a JavaScript object. :param str html: HTML to be parsed for an object. :param str preceding_regex: Regex to find the string preceding the object. :rtype dict: :returns: A dict created from p...
Parses input html to find the end of a JavaScript object. :param str html: HTML to be parsed for an object. :param str preceding_regex: Regex to find the string preceding the object. :rtype dict: :returns: A dict created from parsing the object.
parse_for_object
python
pytube/pytube
pytube/parser.py
https://github.com/pytube/pytube/blob/master/pytube/parser.py
Unlicense
def find_object_from_startpoint(html, start_point): """Parses input html to find the end of a JavaScript object. :param str html: HTML to be parsed for an object. :param int start_point: Index of where the object starts. :rtype dict: :returns: A dict created from parsing the...
Parses input html to find the end of a JavaScript object. :param str html: HTML to be parsed for an object. :param int start_point: Index of where the object starts. :rtype dict: :returns: A dict created from parsing the object.
find_object_from_startpoint
python
pytube/pytube
pytube/parser.py
https://github.com/pytube/pytube/blob/master/pytube/parser.py
Unlicense
def parse_for_object_from_startpoint(html, start_point): """JSONifies an object parsed from HTML. :param str html: HTML to be parsed for an object. :param int start_point: Index of where the object starts. :rtype dict: :returns: A dict created from parsing the object. ""...
JSONifies an object parsed from HTML. :param str html: HTML to be parsed for an object. :param int start_point: Index of where the object starts. :rtype dict: :returns: A dict created from parsing the object.
parse_for_object_from_startpoint
python
pytube/pytube
pytube/parser.py
https://github.com/pytube/pytube/blob/master/pytube/parser.py
Unlicense
def throttling_array_split(js_array): """Parses the throttling array into a python list of strings. Expects input to begin with `[` and close with `]`. :param str js_array: The javascript array, as a string. :rtype: list: :returns: A list of strings representing splits on `,` in th...
Parses the throttling array into a python list of strings. Expects input to begin with `[` and close with `]`. :param str js_array: The javascript array, as a string. :rtype: list: :returns: A list of strings representing splits on `,` in the throttling array.
throttling_array_split
python
pytube/pytube
pytube/parser.py
https://github.com/pytube/pytube/blob/master/pytube/parser.py
Unlicense
def __init__(self, fmt_streams): """Construct a :class:`StreamQuery <StreamQuery>`. param list fmt_streams: list of :class:`Stream <Stream>` instances. """ self.fmt_streams = fmt_streams self.itag_index = {int(s.itag): s for s in fmt_streams}
Construct a :class:`StreamQuery <StreamQuery>`. param list fmt_streams: list of :class:`Stream <Stream>` instances.
__init__
python
pytube/pytube
pytube/query.py
https://github.com/pytube/pytube/blob/master/pytube/query.py
Unlicense
def filter( self, fps=None, res=None, resolution=None, mime_type=None, type=None, subtype=None, file_extension=None, abr=None, bitrate=None, video_codec=None, audio_codec=None, only_audio=None, only_video=Non...
Apply the given filtering criterion. :param fps: (optional) The frames per second. :type fps: int or None :param resolution: (optional) Alias to ``res``. :type res: str or None :param res: (optional) The video resolut...
filter
python
pytube/pytube
pytube/query.py
https://github.com/pytube/pytube/blob/master/pytube/query.py
Unlicense
def order_by(self, attribute_name: str) -> "StreamQuery": """Apply a sort order. Filters out stream the do not have the attribute. :param str attribute_name: The name of the attribute to sort by. """ has_attribute = [ s for s in self.fmt_streams ...
Apply a sort order. Filters out stream the do not have the attribute. :param str attribute_name: The name of the attribute to sort by.
order_by
python
pytube/pytube
pytube/query.py
https://github.com/pytube/pytube/blob/master/pytube/query.py
Unlicense
def get_by_resolution(self, resolution: str) -> Optional[Stream]: """Get the corresponding :class:`Stream <Stream>` for a given resolution. Stream must be a progressive mp4. :param str resolution: Video resolution i.e. "720p", "480p", "360p", "240p", "144p" :rtype: :class:`...
Get the corresponding :class:`Stream <Stream>` for a given resolution. Stream must be a progressive mp4. :param str resolution: Video resolution i.e. "720p", "480p", "360p", "240p", "144p" :rtype: :class:`Stream <Stream>` or None :returns: The :class:`Stream <St...
get_by_resolution
python
pytube/pytube
pytube/query.py
https://github.com/pytube/pytube/blob/master/pytube/query.py
Unlicense
def get_lowest_resolution(self) -> Optional[Stream]: """Get lowest resolution stream that is a progressive mp4. :rtype: :class:`Stream <Stream>` or None :returns: The :class:`Stream <Stream>` matching the given itag or None if not found. """ return ( ...
Get lowest resolution stream that is a progressive mp4. :rtype: :class:`Stream <Stream>` or None :returns: The :class:`Stream <Stream>` matching the given itag or None if not found.
get_lowest_resolution
python
pytube/pytube
pytube/query.py
https://github.com/pytube/pytube/blob/master/pytube/query.py
Unlicense
def get_audio_only(self, subtype: str = "mp4") -> Optional[Stream]: """Get highest bitrate audio stream for given codec (defaults to mp4) :param str subtype: Audio subtype, defaults to mp4 :rtype: :class:`Stream <Stream>` or None :returns: The :class:`Stream <Str...
Get highest bitrate audio stream for given codec (defaults to mp4) :param str subtype: Audio subtype, defaults to mp4 :rtype: :class:`Stream <Stream>` or None :returns: The :class:`Stream <Stream>` matching the given itag or None if not found.
get_audio_only
python
pytube/pytube
pytube/query.py
https://github.com/pytube/pytube/blob/master/pytube/query.py
Unlicense
def first(self) -> Optional[Stream]: """Get the first :class:`Stream <Stream>` in the results. :rtype: :class:`Stream <Stream>` or None :returns: the first result of this query or None if the result doesn't contain any streams. """ try: retur...
Get the first :class:`Stream <Stream>` in the results. :rtype: :class:`Stream <Stream>` or None :returns: the first result of this query or None if the result doesn't contain any streams.
first
python
pytube/pytube
pytube/query.py
https://github.com/pytube/pytube/blob/master/pytube/query.py
Unlicense
def last(self): """Get the last :class:`Stream <Stream>` in the results. :rtype: :class:`Stream <Stream>` or None :returns: Return the last result of this query or None if the result doesn't contain any streams. """ try: return self.fmt_strea...
Get the last :class:`Stream <Stream>` in the results. :rtype: :class:`Stream <Stream>` or None :returns: Return the last result of this query or None if the result doesn't contain any streams.
last
python
pytube/pytube
pytube/query.py
https://github.com/pytube/pytube/blob/master/pytube/query.py
Unlicense
def count(self, value: Optional[str] = None) -> int: # pragma: no cover """Get the count of items in the list. :rtype: int """ if value: return self.fmt_streams.count(value) return len(self)
Get the count of items in the list. :rtype: int
count
python
pytube/pytube
pytube/query.py
https://github.com/pytube/pytube/blob/master/pytube/query.py
Unlicense
def get_by_language_code( self, lang_code: str ) -> Optional[Caption]: # pragma: no cover """Get the :class:`Caption <Caption>` for a given ``lang_code``. :param str lang_code: The code that identifies the caption language. :rtype: :class:`Caption <Caption>` or None ...
Get the :class:`Caption <Caption>` for a given ``lang_code``. :param str lang_code: The code that identifies the caption language. :rtype: :class:`Caption <Caption>` or None :returns: The :class:`Caption <Caption>` matching the given ``lang_code`` or None if ...
get_by_language_code
python
pytube/pytube
pytube/query.py
https://github.com/pytube/pytube/blob/master/pytube/query.py
Unlicense
def get(url, extra_headers=None, timeout=socket._GLOBAL_DEFAULT_TIMEOUT): """Send an http GET request. :param str url: The URL to perform the GET request for. :param dict extra_headers: Extra headers to add to the request :rtype: str :returns: UTF-8 encoded string of respons...
Send an http GET request. :param str url: The URL to perform the GET request for. :param dict extra_headers: Extra headers to add to the request :rtype: str :returns: UTF-8 encoded string of response
get
python
pytube/pytube
pytube/request.py
https://github.com/pytube/pytube/blob/master/pytube/request.py
Unlicense
def post(url, extra_headers=None, data=None, timeout=socket._GLOBAL_DEFAULT_TIMEOUT): """Send an http POST request. :param str url: The URL to perform the POST request for. :param dict extra_headers: Extra headers to add to the request :param dict data: The data to send on the P...
Send an http POST request. :param str url: The URL to perform the POST request for. :param dict extra_headers: Extra headers to add to the request :param dict data: The data to send on the POST request :rtype: str :returns: UTF-8 encoded string of response
post
python
pytube/pytube
pytube/request.py
https://github.com/pytube/pytube/blob/master/pytube/request.py
Unlicense
def seq_stream( url, timeout=socket._GLOBAL_DEFAULT_TIMEOUT, max_retries=0 ): """Read the response in sequence. :param str url: The URL to perform the GET request for. :rtype: Iterable[bytes] """ # YouTube expects a request sequence number as part of the parameters. split_url = parse...
Read the response in sequence. :param str url: The URL to perform the GET request for. :rtype: Iterable[bytes]
seq_stream
python
pytube/pytube
pytube/request.py
https://github.com/pytube/pytube/blob/master/pytube/request.py
Unlicense
def stream( url, timeout=socket._GLOBAL_DEFAULT_TIMEOUT, max_retries=0 ): """Read the response in chunks. :param str url: The URL to perform the GET request for. :rtype: Iterable[bytes] """ file_size: int = default_range_size # fake filesize to start downloaded = 0 while downloa...
Read the response in chunks. :param str url: The URL to perform the GET request for. :rtype: Iterable[bytes]
stream
python
pytube/pytube
pytube/request.py
https://github.com/pytube/pytube/blob/master/pytube/request.py
Unlicense
def seq_filesize(url): """Fetch size in bytes of file at given URL from sequential requests :param str url: The URL to get the size of :returns: int: size in bytes of remote file """ total_filesize = 0 # YouTube expects a request sequence number as part of the parameters. split_url = parse....
Fetch size in bytes of file at given URL from sequential requests :param str url: The URL to get the size of :returns: int: size in bytes of remote file
seq_filesize
python
pytube/pytube
pytube/request.py
https://github.com/pytube/pytube/blob/master/pytube/request.py
Unlicense
def head(url): """Fetch headers returned http GET request. :param str url: The URL to perform the GET request for. :rtype: dict :returns: dictionary of lowercase headers """ response_headers = _execute_request(url, method="HEAD").info() return {k.lower(): v for k, v in respo...
Fetch headers returned http GET request. :param str url: The URL to perform the GET request for. :rtype: dict :returns: dictionary of lowercase headers
head
python
pytube/pytube
pytube/request.py
https://github.com/pytube/pytube/blob/master/pytube/request.py
Unlicense
def __init__( self, stream: Dict, monostate: Monostate ): """Construct a :class:`Stream <Stream>`. :param dict stream: The unscrambled data extracted from YouTube. :param dict monostate: Dictionary of data shared across all instances of :class:`St...
Construct a :class:`Stream <Stream>`. :param dict stream: The unscrambled data extracted from YouTube. :param dict monostate: Dictionary of data shared across all instances of :class:`Stream <Stream>`.
__init__
python
pytube/pytube
pytube/streams.py
https://github.com/pytube/pytube/blob/master/pytube/streams.py
Unlicense
def is_adaptive(self) -> bool: """Whether the stream is DASH. :rtype: bool """ # if codecs has two elements (e.g.: ['vp8', 'vorbis']): 2 % 2 = 0 # if codecs has one element (e.g.: ['vp8']) 1 % 2 = 1 return bool(len(self.codecs) % 2)
Whether the stream is DASH. :rtype: bool
is_adaptive
python
pytube/pytube
pytube/streams.py
https://github.com/pytube/pytube/blob/master/pytube/streams.py
Unlicense
def parse_codecs(self) -> Tuple[Optional[str], Optional[str]]: """Get the video/audio codecs from list of codecs. Parse a variable length sized list of codecs and returns a constant two element tuple, with the video codec as the first element and audio as the second. Returns None if one...
Get the video/audio codecs from list of codecs. Parse a variable length sized list of codecs and returns a constant two element tuple, with the video codec as the first element and audio as the second. Returns None if one is not available (adaptive only). :rtype: tuple ...
parse_codecs
python
pytube/pytube
pytube/streams.py
https://github.com/pytube/pytube/blob/master/pytube/streams.py
Unlicense
def filesize(self) -> int: """File size of the media stream in bytes. :rtype: int :returns: Filesize (in bytes) of the stream. """ if self._filesize == 0: try: self._filesize = request.filesize(self.url) except HTTPError as e: ...
File size of the media stream in bytes. :rtype: int :returns: Filesize (in bytes) of the stream.
filesize
python
pytube/pytube
pytube/streams.py
https://github.com/pytube/pytube/blob/master/pytube/streams.py
Unlicense
def filesize_kb(self) -> float: """File size of the media stream in kilobytes. :rtype: float :returns: Rounded filesize (in kilobytes) of the stream. """ if self._filesize_kb == 0: try: self._filesize_kb = float(ceil(request.filesize(self....
File size of the media stream in kilobytes. :rtype: float :returns: Rounded filesize (in kilobytes) of the stream.
filesize_kb
python
pytube/pytube
pytube/streams.py
https://github.com/pytube/pytube/blob/master/pytube/streams.py
Unlicense
def filesize_mb(self) -> float: """File size of the media stream in megabytes. :rtype: float :returns: Rounded filesize (in megabytes) of the stream. """ if self._filesize_mb == 0: try: self._filesize_mb = float(ceil(request.filesize(self....
File size of the media stream in megabytes. :rtype: float :returns: Rounded filesize (in megabytes) of the stream.
filesize_mb
python
pytube/pytube
pytube/streams.py
https://github.com/pytube/pytube/blob/master/pytube/streams.py
Unlicense
def filesize_gb(self) -> float: """File size of the media stream in gigabytes. :rtype: float :returns: Rounded filesize (in gigabytes) of the stream. """ if self._filesize_gb == 0: try: self._filesize_gb = float(ceil(request.filesize(self....
File size of the media stream in gigabytes. :rtype: float :returns: Rounded filesize (in gigabytes) of the stream.
filesize_gb
python
pytube/pytube
pytube/streams.py
https://github.com/pytube/pytube/blob/master/pytube/streams.py
Unlicense
def filesize_approx(self) -> int: """Get approximate filesize of the video Falls back to HTTP call if there is not sufficient information to approximate :rtype: int :returns: size of video in bytes """ if self._monostate.duration and self.bitrate: bits_in_by...
Get approximate filesize of the video Falls back to HTTP call if there is not sufficient information to approximate :rtype: int :returns: size of video in bytes
filesize_approx
python
pytube/pytube
pytube/streams.py
https://github.com/pytube/pytube/blob/master/pytube/streams.py
Unlicense
def download( self, output_path: Optional[str] = None, filename: Optional[str] = None, filename_prefix: Optional[str] = None, skip_existing: bool = True, timeout: Optional[int] = None, max_retries: Optional[int] = 0 ) -> str: """Write the media stream ...
Write the media stream to disk. :param output_path: (optional) Output path for writing media file. If one is not specified, defaults to the current working directory. :type output_path: str or None :param filename: (optional) Output filename (stem only) for w...
download
python
pytube/pytube
pytube/streams.py
https://github.com/pytube/pytube/blob/master/pytube/streams.py
Unlicense
def stream_to_buffer(self, buffer: BinaryIO) -> None: """Write the media stream to buffer :rtype: io.BytesIO buffer """ bytes_remaining = self.filesize logger.info( "downloading (%s total bytes) file to buffer", self.filesize, ) for chunk in request....
Write the media stream to buffer :rtype: io.BytesIO buffer
stream_to_buffer
python
pytube/pytube
pytube/streams.py
https://github.com/pytube/pytube/blob/master/pytube/streams.py
Unlicense
def on_progress( self, chunk: bytes, file_handler: BinaryIO, bytes_remaining: int ): """On progress callback function. This function writes the binary data to the file, then checks if an additional callback is defined in the monostate. This is exposed to allow things like di...
On progress callback function. This function writes the binary data to the file, then checks if an additional callback is defined in the monostate. This is exposed to allow things like displaying a progress bar. :param bytes chunk: Segment of media file binary data, not yet...
on_progress
python
pytube/pytube
pytube/streams.py
https://github.com/pytube/pytube/blob/master/pytube/streams.py
Unlicense
def on_complete(self, file_path: Optional[str]): """On download complete handler function. :param file_path: The file handle where the media is being written to. :type file_path: str :rtype: None """ logger.debug("download finished") on_complete = s...
On download complete handler function. :param file_path: The file handle where the media is being written to. :type file_path: str :rtype: None
on_complete
python
pytube/pytube
pytube/streams.py
https://github.com/pytube/pytube/blob/master/pytube/streams.py
Unlicense
def __repr__(self) -> str: """Printable object representation. :rtype: str :returns: A string representation of a :class:`Stream <Stream>` object. """ parts = ['itag="{s.itag}"', 'mime_type="{s.mime_type}"'] if self.includes_video_track: parts.ext...
Printable object representation. :rtype: str :returns: A string representation of a :class:`Stream <Stream>` object.
__repr__
python
pytube/pytube
pytube/streams.py
https://github.com/pytube/pytube/blob/master/pytube/streams.py
Unlicense
def __init__( self, url: str, on_progress_callback: Optional[Callable[[Any, bytes, int], None]] = None, on_complete_callback: Optional[Callable[[Any, Optional[str]], None]] = None, proxies: Dict[str, str] = None, use_oauth: bool = False, allow_oauth_cache: bool = ...
Construct a :class:`YouTube <YouTube>`. :param str url: A valid YouTube watch URL. :param func on_progress_callback: (Optional) User defined callback function for stream download progress events. :param func on_complete_callback: (Optional) User d...
__init__
python
pytube/pytube
pytube/__main__.py
https://github.com/pytube/pytube/blob/master/pytube/__main__.py
Unlicense
def fmt_streams(self): """Returns a list of streams if they have been initialized. If the streams have not been initialized, finds all relevant streams and initializes them. """ self.check_availability() if self._fmt_streams: return self._fmt_streams ...
Returns a list of streams if they have been initialized. If the streams have not been initialized, finds all relevant streams and initializes them.
fmt_streams
python
pytube/pytube
pytube/__main__.py
https://github.com/pytube/pytube/blob/master/pytube/__main__.py
Unlicense
def check_availability(self): """Check whether the video is available. Raises different exceptions based on why the video is unavailable, otherwise does nothing. """ status, messages = extract.playability_status(self.watch_html) for reason in messages: if st...
Check whether the video is available. Raises different exceptions based on why the video is unavailable, otherwise does nothing.
check_availability
python
pytube/pytube
pytube/__main__.py
https://github.com/pytube/pytube/blob/master/pytube/__main__.py
Unlicense
def vid_info(self): """Parse the raw vid info and return the parsed result. :rtype: Dict[Any, Any] """ if self._vid_info: return self._vid_info innertube = InnerTube(use_oauth=self.use_oauth, allow_cache=self.allow_oauth_cache) innertube_response = innertub...
Parse the raw vid info and return the parsed result. :rtype: Dict[Any, Any]
vid_info
python
pytube/pytube
pytube/__main__.py
https://github.com/pytube/pytube/blob/master/pytube/__main__.py
Unlicense
def bypass_age_gate(self): """Attempt to update the vid_info by bypassing the age gate.""" innertube = InnerTube( client='ANDROID_EMBED', use_oauth=self.use_oauth, allow_cache=self.allow_oauth_cache ) innertube_response = innertube.player(self.video_id...
Attempt to update the vid_info by bypassing the age gate.
bypass_age_gate
python
pytube/pytube
pytube/__main__.py
https://github.com/pytube/pytube/blob/master/pytube/__main__.py
Unlicense
def caption_tracks(self) -> List[pytube.Caption]: """Get a list of :class:`Caption <Caption>`. :rtype: List[Caption] """ raw_tracks = ( self.vid_info.get("captions", {}) .get("playerCaptionsTracklistRenderer", {}) .get("captionTracks", []) ) ...
Get a list of :class:`Caption <Caption>`. :rtype: List[Caption]
caption_tracks
python
pytube/pytube
pytube/__main__.py
https://github.com/pytube/pytube/blob/master/pytube/__main__.py
Unlicense
def thumbnail_url(self) -> str: """Get the thumbnail url image. :rtype: str """ thumbnail_details = ( self.vid_info.get("videoDetails", {}) .get("thumbnail", {}) .get("thumbnails") ) if thumbnail_details: thumbnail_details ...
Get the thumbnail url image. :rtype: str
thumbnail_url
python
pytube/pytube
pytube/__main__.py
https://github.com/pytube/pytube/blob/master/pytube/__main__.py
Unlicense
def publish_date(self): """Get the publish date. :rtype: datetime """ if self._publish_date: return self._publish_date self._publish_date = extract.publish_date(self.watch_html) return self._publish_date
Get the publish date. :rtype: datetime
publish_date
python
pytube/pytube
pytube/__main__.py
https://github.com/pytube/pytube/blob/master/pytube/__main__.py
Unlicense
def title(self) -> str: """Get the video title. :rtype: str """ if self._title: return self._title try: self._title = self.vid_info['videoDetails']['title'] except KeyError: # Check_availability will raise the correct exception in mos...
Get the video title. :rtype: str
title
python
pytube/pytube
pytube/__main__.py
https://github.com/pytube/pytube/blob/master/pytube/__main__.py
Unlicense
def author(self) -> str: """Get the video author. :rtype: str """ if self._author: return self._author self._author = self.vid_info.get("videoDetails", {}).get( "author", "unknown" ) return self._author
Get the video author. :rtype: str
author
python
pytube/pytube
pytube/__main__.py
https://github.com/pytube/pytube/blob/master/pytube/__main__.py
Unlicense
def metadata(self) -> Optional[YouTubeMetadata]: """Get the metadata for the video. :rtype: YouTubeMetadata """ if self._metadata: return self._metadata else: self._metadata = extract.metadata(self.initial_data) return self._metadata
Get the metadata for the video. :rtype: YouTubeMetadata
metadata
python
pytube/pytube
pytube/__main__.py
https://github.com/pytube/pytube/blob/master/pytube/__main__.py
Unlicense
def __init__(self, url: str, proxies: Optional[Dict[str, str]] = None): """Construct a :class:`Channel <Channel>`. :param str url: A valid YouTube channel URL. :param proxies: (Optional) A dictionary of proxies to use for web requests. """ super().__init_...
Construct a :class:`Channel <Channel>`. :param str url: A valid YouTube channel URL. :param proxies: (Optional) A dictionary of proxies to use for web requests.
__init__
python
pytube/pytube
pytube/contrib/channel.py
https://github.com/pytube/pytube/blob/master/pytube/contrib/channel.py
Unlicense
def html(self): """Get the html for the /videos page. :rtype: str """ if self._html: return self._html self._html = request.get(self.videos_url) return self._html
Get the html for the /videos page. :rtype: str
html
python
pytube/pytube
pytube/contrib/channel.py
https://github.com/pytube/pytube/blob/master/pytube/contrib/channel.py
Unlicense
def playlists_html(self): """Get the html for the /playlists page. Currently unused for any functionality. :rtype: str """ if self._playlists_html: return self._playlists_html else: self._playlists_html = request.get(self.playlists_url) ...
Get the html for the /playlists page. Currently unused for any functionality. :rtype: str
playlists_html
python
pytube/pytube
pytube/contrib/channel.py
https://github.com/pytube/pytube/blob/master/pytube/contrib/channel.py
Unlicense
def community_html(self): """Get the html for the /community page. Currently unused for any functionality. :rtype: str """ if self._community_html: return self._community_html else: self._community_html = request.get(self.community_url) ...
Get the html for the /community page. Currently unused for any functionality. :rtype: str
community_html
python
pytube/pytube
pytube/contrib/channel.py
https://github.com/pytube/pytube/blob/master/pytube/contrib/channel.py
Unlicense
def featured_channels_html(self): """Get the html for the /channels page. Currently unused for any functionality. :rtype: str """ if self._featured_channels_html: return self._featured_channels_html else: self._featured_channels_html = request.ge...
Get the html for the /channels page. Currently unused for any functionality. :rtype: str
featured_channels_html
python
pytube/pytube
pytube/contrib/channel.py
https://github.com/pytube/pytube/blob/master/pytube/contrib/channel.py
Unlicense
def about_html(self): """Get the html for the /about page. Currently unused for any functionality. :rtype: str """ if self._about_html: return self._about_html else: self._about_html = request.get(self.about_url) return self._about_ht...
Get the html for the /about page. Currently unused for any functionality. :rtype: str
about_html
python
pytube/pytube
pytube/contrib/channel.py
https://github.com/pytube/pytube/blob/master/pytube/contrib/channel.py
Unlicense
def _extract_videos(raw_json: str) -> Tuple[List[str], Optional[str]]: """Extracts videos from a raw json page :param str raw_json: Input json extracted from the page or the last server response :rtype: Tuple[List[str], Optional[str]] :returns: Tuple containing a list of up ...
Extracts videos from a raw json page :param str raw_json: Input json extracted from the page or the last server response :rtype: Tuple[List[str], Optional[str]] :returns: Tuple containing a list of up to 100 video watch ids and a continuation token, if more videos are av...
_extract_videos
python
pytube/pytube
pytube/contrib/channel.py
https://github.com/pytube/pytube/blob/master/pytube/contrib/channel.py
Unlicense
def playlist_id(self): """Get the playlist id. :rtype: str """ if self._playlist_id: return self._playlist_id self._playlist_id = extract.playlist_id(self._input_url) return self._playlist_id
Get the playlist id. :rtype: str
playlist_id
python
pytube/pytube
pytube/contrib/playlist.py
https://github.com/pytube/pytube/blob/master/pytube/contrib/playlist.py
Unlicense
def html(self): """Get the playlist page html. :rtype: str """ if self._html: return self._html self._html = request.get(self.playlist_url) return self._html
Get the playlist page html. :rtype: str
html
python
pytube/pytube
pytube/contrib/playlist.py
https://github.com/pytube/pytube/blob/master/pytube/contrib/playlist.py
Unlicense
def ytcfg(self): """Extract the ytcfg from the playlist page html. :rtype: dict """ if self._ytcfg: return self._ytcfg self._ytcfg = extract.get_ytcfg(self.html) return self._ytcfg
Extract the ytcfg from the playlist page html. :rtype: dict
ytcfg
python
pytube/pytube
pytube/contrib/playlist.py
https://github.com/pytube/pytube/blob/master/pytube/contrib/playlist.py
Unlicense
def initial_data(self): """Extract the initial data from the playlist page html. :rtype: dict """ if self._initial_data: return self._initial_data else: self._initial_data = extract.initial_data(self.html) return self._initial_data
Extract the initial data from the playlist page html. :rtype: dict
initial_data
python
pytube/pytube
pytube/contrib/playlist.py
https://github.com/pytube/pytube/blob/master/pytube/contrib/playlist.py
Unlicense
def sidebar_info(self): """Extract the sidebar info from the playlist page html. :rtype: dict """ if self._sidebar_info: return self._sidebar_info else: self._sidebar_info = self.initial_data['sidebar'][ 'playlistSidebarRenderer']['items']...
Extract the sidebar info from the playlist page html. :rtype: dict
sidebar_info
python
pytube/pytube
pytube/contrib/playlist.py
https://github.com/pytube/pytube/blob/master/pytube/contrib/playlist.py
Unlicense
def _paginate( self, until_watch_id: Optional[str] = None ) -> Iterable[List[str]]: """Parse the video links from the page source, yields the /watch?v= part from video link :param until_watch_id Optional[str]: YouTube Video watch id until which the playlist should be rea...
Parse the video links from the page source, yields the /watch?v= part from video link :param until_watch_id Optional[str]: YouTube Video watch id until which the playlist should be read. :rtype: Iterable[List[str]] :returns: Iterable of lists of YouTube watch ids
_paginate
python
pytube/pytube
pytube/contrib/playlist.py
https://github.com/pytube/pytube/blob/master/pytube/contrib/playlist.py
Unlicense
def _build_continuation_url(self, continuation: str) -> Tuple[str, dict, dict]: """Helper method to build the url and headers required to request the next page of videos :param str continuation: Continuation extracted from the json response of the last page :rtype: Tuple[str...
Helper method to build the url and headers required to request the next page of videos :param str continuation: Continuation extracted from the json response of the last page :rtype: Tuple[str, dict, dict] :returns: Tuple of an url and required headers for the next http ...
_build_continuation_url
python
pytube/pytube
pytube/contrib/playlist.py
https://github.com/pytube/pytube/blob/master/pytube/contrib/playlist.py
Unlicense
def trimmed(self, video_id: str) -> Iterable[str]: """Retrieve a list of YouTube video URLs trimmed at the given video ID i.e. if the playlist has video IDs 1,2,3,4 calling trimmed(3) returns [1,2] :type video_id: str video ID to trim the returned list of playlist URLs at ...
Retrieve a list of YouTube video URLs trimmed at the given video ID i.e. if the playlist has video IDs 1,2,3,4 calling trimmed(3) returns [1,2] :type video_id: str video ID to trim the returned list of playlist URLs at :rtype: List[str] :returns: List of ...
trimmed
python
pytube/pytube
pytube/contrib/playlist.py
https://github.com/pytube/pytube/blob/master/pytube/contrib/playlist.py
Unlicense
def url_generator(self): """Generator that yields video URLs. :Yields: Video URLs """ for page in self._paginate(): for video in page: yield self._video_url(video)
Generator that yields video URLs. :Yields: Video URLs
url_generator
python
pytube/pytube
pytube/contrib/playlist.py
https://github.com/pytube/pytube/blob/master/pytube/contrib/playlist.py
Unlicense
def last_updated(self) -> Optional[date]: """Extract the date that the playlist was last updated. For some playlists, this will be a specific date, which is returned as a datetime object. For other playlists, this is an estimate such as "1 week ago". Due to the fact that this value is r...
Extract the date that the playlist was last updated. For some playlists, this will be a specific date, which is returned as a datetime object. For other playlists, this is an estimate such as "1 week ago". Due to the fact that this value is returned as a string, pytube does a best-effort parsin...
last_updated
python
pytube/pytube
pytube/contrib/playlist.py
https://github.com/pytube/pytube/blob/master/pytube/contrib/playlist.py
Unlicense
def length(self): """Extract the number of videos in the playlist. :return: Playlist video count :rtype: int """ count_text = self.sidebar_info[0]['playlistSidebarPrimaryInfoRenderer'][ 'stats'][0]['runs'][0]['text'] count_text = count_text.replace(',','') ...
Extract the number of videos in the playlist. :return: Playlist video count :rtype: int
length
python
pytube/pytube
pytube/contrib/playlist.py
https://github.com/pytube/pytube/blob/master/pytube/contrib/playlist.py
Unlicense
def views(self): """Extract view count for playlist. :return: Playlist view count :rtype: int """ # "1,234,567 views" views_text = self.sidebar_info[0]['playlistSidebarPrimaryInfoRenderer'][ 'stats'][1]['simpleText'] # "1,234,567" count_text =...
Extract view count for playlist. :return: Playlist view count :rtype: int
views
python
pytube/pytube
pytube/contrib/playlist.py
https://github.com/pytube/pytube/blob/master/pytube/contrib/playlist.py
Unlicense
def __init__(self, query): """Initialize Search object. :param str query: Search query provided by the user. """ self.query = query self._innertube_client = InnerTube(client='WEB') # The first search, without a continuation, is structured differently ...
Initialize Search object. :param str query: Search query provided by the user.
__init__
python
pytube/pytube
pytube/contrib/search.py
https://github.com/pytube/pytube/blob/master/pytube/contrib/search.py
Unlicense
def completion_suggestions(self): """Return query autocompletion suggestions for the query. :rtype: list :returns: A list of autocomplete suggestions provided by YouTube for the query. """ if self._completion_suggestions: return self._completion_suggestio...
Return query autocompletion suggestions for the query. :rtype: list :returns: A list of autocomplete suggestions provided by YouTube for the query.
completion_suggestions
python
pytube/pytube
pytube/contrib/search.py
https://github.com/pytube/pytube/blob/master/pytube/contrib/search.py
Unlicense
def results(self): """Return search results. On first call, will generate and return the first set of results. Additional results can be generated using ``.get_next_results()``. :rtype: list :returns: A list of YouTube objects. """ if self._results: ...
Return search results. On first call, will generate and return the first set of results. Additional results can be generated using ``.get_next_results()``. :rtype: list :returns: A list of YouTube objects.
results
python
pytube/pytube
pytube/contrib/search.py
https://github.com/pytube/pytube/blob/master/pytube/contrib/search.py
Unlicense
def get_next_results(self): """Use the stored continuation string to fetch the next set of results. This method does not return the results, but instead updates the results property. """ if self._current_continuation: videos, continuation = self.fetch_and_parse(self._current...
Use the stored continuation string to fetch the next set of results. This method does not return the results, but instead updates the results property.
get_next_results
python
pytube/pytube
pytube/contrib/search.py
https://github.com/pytube/pytube/blob/master/pytube/contrib/search.py
Unlicense
def fetch_and_parse(self, continuation=None): """Fetch from the innertube API and parse the results. :param str continuation: Continuation string for fetching results. :rtype: tuple :returns: A tuple of a list of YouTube objects and a continuation string. ...
Fetch from the innertube API and parse the results. :param str continuation: Continuation string for fetching results. :rtype: tuple :returns: A tuple of a list of YouTube objects and a continuation string.
fetch_and_parse
python
pytube/pytube
pytube/contrib/search.py
https://github.com/pytube/pytube/blob/master/pytube/contrib/search.py
Unlicense
def fetch_query(self, continuation=None): """Fetch raw results from the innertube API. :param str continuation: Continuation string for fetching results. :rtype: dict :returns: The raw json object returned by the innertube API. """ query_results =...
Fetch raw results from the innertube API. :param str continuation: Continuation string for fetching results. :rtype: dict :returns: The raw json object returned by the innertube API.
fetch_query
python
pytube/pytube
pytube/contrib/search.py
https://github.com/pytube/pytube/blob/master/pytube/contrib/search.py
Unlicense
def load_and_init_from_playback_file(filename, mock_urlopen): """Load a gzip json playback file and create YouTube instance.""" pb = load_playback_file(filename) # Mock the responses to YouTube mock_url_open_object = mock.Mock() mock_url_open_object.read.side_effect = [ pb['watch_html'].enc...
Load a gzip json playback file and create YouTube instance.
load_and_init_from_playback_file
python
pytube/pytube
tests/conftest.py
https://github.com/pytube/pytube/blob/master/tests/conftest.py
Unlicense
def playlist_html(): """Youtube playlist HTML loaded on 2020-01-25 from https://www.youtube.com/playlist?list=PLzMcBGfZo4-mP7qA9cagf68V06sko5otr """ file_path = os.path.join( os.path.dirname(os.path.realpath(__file__)), "mocks", "playlist.html.gz", ) with gzip.open(file_p...
Youtube playlist HTML loaded on 2020-01-25 from https://www.youtube.com/playlist?list=PLzMcBGfZo4-mP7qA9cagf68V06sko5otr
playlist_html
python
pytube/pytube
tests/conftest.py
https://github.com/pytube/pytube/blob/master/tests/conftest.py
Unlicense
def playlist_submenu_html(): """Youtube playlist HTML loaded on 2020-01-24 from https://www.youtube.com/playlist?list=PLZHQObOWTQDMsr9K-rj53DwVRMYO3t5Yr """ file_path = os.path.join( os.path.dirname(os.path.realpath(__file__)), "mocks", "playlist_submenu.html.gz", ) with ...
Youtube playlist HTML loaded on 2020-01-24 from https://www.youtube.com/playlist?list=PLZHQObOWTQDMsr9K-rj53DwVRMYO3t5Yr
playlist_submenu_html
python
pytube/pytube
tests/conftest.py
https://github.com/pytube/pytube/blob/master/tests/conftest.py
Unlicense
def stream_dict(): """Youtube instance initialized with video id WXxV9g7lsFE.""" file_path = os.path.join( os.path.dirname(os.path.realpath(__file__)), "mocks", "yt-video-WXxV9g7lsFE-html.json.gz", ) with gzip.open(file_path, "rb") as f: content = json.loads(f.read().deco...
Youtube instance initialized with video id WXxV9g7lsFE.
stream_dict
python
pytube/pytube
tests/conftest.py
https://github.com/pytube/pytube/blob/master/tests/conftest.py
Unlicense
def channel_videos_html(): """Youtube channel HTML loaded on 2021-05-05 from https://www.youtube.com/c/ProgrammingKnowledge/videos """ file_path = os.path.join( os.path.dirname(os.path.realpath(__file__)), "mocks", "channel-videos.html.gz", ) with gzip.open(file_path, 'rb...
Youtube channel HTML loaded on 2021-05-05 from https://www.youtube.com/c/ProgrammingKnowledge/videos
channel_videos_html
python
pytube/pytube
tests/conftest.py
https://github.com/pytube/pytube/blob/master/tests/conftest.py
Unlicense
def base_js(): """Youtube base.js files retrieved on 2022-02-04 and 2022-04-15 from https://www.youtube.com/watch?v=vmzxpUsN0uA and https://www.youtube.com/watch?v=Y4-GSFKZmEg respectively """ base_js_files = [] for file in ["base.js-2022-02-04.gz", "base.js-2022-04-15.gz"]: file_path = ...
Youtube base.js files retrieved on 2022-02-04 and 2022-04-15 from https://www.youtube.com/watch?v=vmzxpUsN0uA and https://www.youtube.com/watch?v=Y4-GSFKZmEg respectively
base_js
python
pytube/pytube
tests/conftest.py
https://github.com/pytube/pytube/blob/master/tests/conftest.py
Unlicense
def test_safe_filename(): """Unsafe characters get stripped from generated filename""" assert helpers.safe_filename("abc1245$$") == "abc1245" assert helpers.safe_filename("abc##") == "abc"
Unsafe characters get stripped from generated filename
test_safe_filename
python
pytube/pytube
tests/test_helpers.py
https://github.com/pytube/pytube/blob/master/tests/test_helpers.py
Unlicense
def test_filters(test_input, expected, cipher_signature): """Ensure filters produce the expected results.""" result = [s.itag for s in cipher_signature.streams.filter(**test_input)] assert result == expected
Ensure filters produce the expected results.
test_filters
python
pytube/pytube
tests/test_query.py
https://github.com/pytube/pytube/blob/master/tests/test_query.py
Unlicense
def test_empty(test_input, cipher_signature): """Ensure :meth:`~pytube.StreamQuery.last` and :meth:`~pytube.StreamQuery.first` return None if the resultset is empty. """ query = cipher_signature.streams.filter(video_codec="vp20") fn = getattr(query, test_input) assert fn() is None
Ensure :meth:`~pytube.StreamQuery.last` and :meth:`~pytube.StreamQuery.first` return None if the resultset is empty.
test_empty
python
pytube/pytube
tests/test_query.py
https://github.com/pytube/pytube/blob/master/tests/test_query.py
Unlicense
def test_order_by(cipher_signature): """Ensure :meth:`~pytube.StreamQuery.order_by` sorts the list of :class:`Stream <Stream>` instances in the expected order. """ itags = [ s.itag for s in cipher_signature.streams.filter(type="audio").order_by("itag") ] expected_itags = [ ...
Ensure :meth:`~pytube.StreamQuery.order_by` sorts the list of :class:`Stream <Stream>` instances in the expected order.
test_order_by
python
pytube/pytube
tests/test_query.py
https://github.com/pytube/pytube/blob/master/tests/test_query.py
Unlicense
def test_order_by_descending(cipher_signature): """Ensure :meth:`~pytube.StreamQuery.desc` sorts the list of :class:`Stream <Stream>` instances in the reverse order. """ # numerical values itags = [ s.itag for s in cipher_signature.streams.filter(type="audio") .order_by("itag...
Ensure :meth:`~pytube.StreamQuery.desc` sorts the list of :class:`Stream <Stream>` instances in the reverse order.
test_order_by_descending
python
pytube/pytube
tests/test_query.py
https://github.com/pytube/pytube/blob/master/tests/test_query.py
Unlicense