documentation
Browse files- .gitignore +5 -0
- docs/Makefile +20 -0
- docs/api.rst +66 -0
- docs/conf.py +185 -0
- docs/index.rst +40 -0
- pytube/cipher.py +40 -21
- pytube/request.py +1 -1
- tests/requirements.txt +2 -0
.gitignore
CHANGED
@@ -31,3 +31,8 @@ doc/aws_hostname.1
|
|
31 |
.cache
|
32 |
_run.py
|
33 |
_devfiles/*
|
|
|
|
|
|
|
|
|
|
|
|
31 |
.cache
|
32 |
_run.py
|
33 |
_devfiles/*
|
34 |
+
|
35 |
+
_build
|
36 |
+
_static
|
37 |
+
_templates
|
38 |
+
_autosummary
|
docs/Makefile
ADDED
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Minimal makefile for Sphinx documentation
|
2 |
+
#
|
3 |
+
|
4 |
+
# You can set these variables from the command line.
|
5 |
+
SPHINXOPTS =
|
6 |
+
SPHINXBUILD = python -msphinx
|
7 |
+
SPHINXPROJ = pytube
|
8 |
+
SOURCEDIR = .
|
9 |
+
BUILDDIR = _build
|
10 |
+
|
11 |
+
# Put it first so that "make" without argument is like "make help".
|
12 |
+
help:
|
13 |
+
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
|
14 |
+
|
15 |
+
.PHONY: help Makefile
|
16 |
+
|
17 |
+
# Catch-all target: route all unknown targets to Sphinx using the new
|
18 |
+
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
|
19 |
+
%: Makefile
|
20 |
+
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
|
docs/api.rst
ADDED
@@ -0,0 +1,66 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
.. _api:
|
2 |
+
|
3 |
+
API
|
4 |
+
===
|
5 |
+
|
6 |
+
.. module:: pytube
|
7 |
+
|
8 |
+
|
9 |
+
YouTube Object
|
10 |
+
--------------
|
11 |
+
|
12 |
+
.. autoclass:: YouTube
|
13 |
+
:members:
|
14 |
+
:inherited-members:
|
15 |
+
|
16 |
+
Stream Object
|
17 |
+
-------------
|
18 |
+
|
19 |
+
.. autoclass:: pytube.Stream
|
20 |
+
:members:
|
21 |
+
:inherited-members:
|
22 |
+
|
23 |
+
StreamQuery Object
|
24 |
+
------------------
|
25 |
+
|
26 |
+
.. autoclass:: pytube.query.StreamQuery
|
27 |
+
:members:
|
28 |
+
:inherited-members:
|
29 |
+
|
30 |
+
Extract
|
31 |
+
-------
|
32 |
+
|
33 |
+
.. automodule:: pytube.extract
|
34 |
+
:members:
|
35 |
+
|
36 |
+
Cipher
|
37 |
+
------
|
38 |
+
|
39 |
+
.. automodule:: pytube.cipher
|
40 |
+
:members:
|
41 |
+
|
42 |
+
Exceptions
|
43 |
+
----------
|
44 |
+
|
45 |
+
.. automodule:: pytube.exceptions
|
46 |
+
:members:
|
47 |
+
|
48 |
+
Mixins
|
49 |
+
------
|
50 |
+
|
51 |
+
.. automodule:: pytube.mixins
|
52 |
+
:members:
|
53 |
+
|
54 |
+
|
55 |
+
Helpers
|
56 |
+
-------
|
57 |
+
|
58 |
+
.. automodule:: pytube.helpers
|
59 |
+
:members:
|
60 |
+
|
61 |
+
|
62 |
+
Request
|
63 |
+
-------
|
64 |
+
|
65 |
+
.. automodule:: pytube.request
|
66 |
+
:members:
|
docs/conf.py
ADDED
@@ -0,0 +1,185 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#!/usr/bin/env python3
|
2 |
+
# -*- coding: utf-8 -*-
|
3 |
+
#
|
4 |
+
# pytube documentation build configuration file, created by
|
5 |
+
# sphinx-quickstart on Mon Oct 9 02:11:41 2017.
|
6 |
+
#
|
7 |
+
# This file is execfile()d with the current directory set to its
|
8 |
+
# containing dir.
|
9 |
+
#
|
10 |
+
# Note that not all possible configuration values are present in this
|
11 |
+
# autogenerated file.
|
12 |
+
#
|
13 |
+
# All configuration values have a default; values that are commented out
|
14 |
+
# serve to show the default.
|
15 |
+
# If extensions (or modules to document with autodoc) are in another directory,
|
16 |
+
# add these directories to sys.path here. If the directory is relative to the
|
17 |
+
# documentation root, use os.path.abspath to make it absolute, like shown here.
|
18 |
+
import os
|
19 |
+
import sys
|
20 |
+
|
21 |
+
import sphinx_rtd_theme
|
22 |
+
|
23 |
+
sys.path.insert(0, os.path.abspath('../'))
|
24 |
+
# -- General configuration ------------------------------------------------
|
25 |
+
# If your documentation needs a minimal Sphinx version, state it here.
|
26 |
+
#
|
27 |
+
# needs_sphinx = '1.0'
|
28 |
+
# Add any Sphinx extension module names here, as strings. They can be
|
29 |
+
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
|
30 |
+
# ones.
|
31 |
+
extensions = [
|
32 |
+
'sphinx.ext.autodoc',
|
33 |
+
'sphinx.ext.autosummary',
|
34 |
+
'sphinx.ext.todo',
|
35 |
+
'sphinx.ext.intersphinx',
|
36 |
+
'sphinx.ext.viewcode',
|
37 |
+
]
|
38 |
+
|
39 |
+
autosummary_generate = True
|
40 |
+
|
41 |
+
# Add any paths that contain templates here, relative to this directory.
|
42 |
+
templates_path = ['_templates']
|
43 |
+
|
44 |
+
# The suffix(es) of source filenames.
|
45 |
+
# You can specify multiple suffix as a list of string:
|
46 |
+
#
|
47 |
+
# source_suffix = ['.rst', '.md']
|
48 |
+
source_suffix = '.rst'
|
49 |
+
|
50 |
+
# The master toctree document.
|
51 |
+
master_doc = 'index'
|
52 |
+
|
53 |
+
# General information about the project.
|
54 |
+
project = 'pytube'
|
55 |
+
copyright = '2017, Nick Ficano'
|
56 |
+
author = 'Nick Ficano'
|
57 |
+
|
58 |
+
# The version info for the project you're documenting, acts as replacement for
|
59 |
+
# |version| and |release|, also used in various other places throughout the
|
60 |
+
# built documents.
|
61 |
+
#
|
62 |
+
# The short X.Y version.
|
63 |
+
version = '7.0.1'
|
64 |
+
# The full version, including alpha/beta/rc tags.
|
65 |
+
release = '7.0.1'
|
66 |
+
|
67 |
+
# The language for content autogenerated by Sphinx. Refer to documentation
|
68 |
+
# for a list of supported languages.
|
69 |
+
#
|
70 |
+
# This is also used if you do content translation via gettext catalogs.
|
71 |
+
# Usually you set "language" from the command line for these cases.
|
72 |
+
language = None
|
73 |
+
|
74 |
+
# List of patterns, relative to source directory, that match files and
|
75 |
+
# directories to ignore when looking for source files.
|
76 |
+
# This patterns also effect to html_static_path and html_extra_path
|
77 |
+
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']
|
78 |
+
|
79 |
+
# The name of the Pygments (syntax highlighting) style to use.
|
80 |
+
pygments_style = 'sphinx'
|
81 |
+
|
82 |
+
# If true, `todo` and `todoList` produce output, else they produce nothing.
|
83 |
+
todo_include_todos = True
|
84 |
+
|
85 |
+
intersphinx_mapping = {
|
86 |
+
'python': ('https://docs.python.org/3/', None),
|
87 |
+
}
|
88 |
+
|
89 |
+
|
90 |
+
# -- Options for HTML output ----------------------------------------------
|
91 |
+
|
92 |
+
# The theme to use for HTML and HTML Help pages. See the documentation for
|
93 |
+
# a list of builtin themes.
|
94 |
+
#
|
95 |
+
html_theme = 'sphinx_rtd_theme'
|
96 |
+
html_theme_path = [sphinx_rtd_theme.get_html_theme_path()]
|
97 |
+
|
98 |
+
# Theme options are theme-specific and customize the look and feel of a theme
|
99 |
+
# further. For a list of options available for each theme, see the
|
100 |
+
# documentation.
|
101 |
+
#
|
102 |
+
# html_theme_options = {}
|
103 |
+
|
104 |
+
# Add any paths that contain custom static files (such as style sheets) here,
|
105 |
+
# relative to this directory. They are copied after the builtin static files,
|
106 |
+
# so a file named "default.css" will overwrite the builtin "default.css".
|
107 |
+
html_static_path = ['_static']
|
108 |
+
|
109 |
+
# Custom sidebar templates, must be a dictionary that maps document names
|
110 |
+
# to template names.
|
111 |
+
#
|
112 |
+
# This is required for the alabaster theme
|
113 |
+
# refs: http://alabaster.readthedocs.io/en/latest/installation.html#sidebars
|
114 |
+
html_sidebars = {
|
115 |
+
'**': [
|
116 |
+
'about.html',
|
117 |
+
'navigation.html',
|
118 |
+
'relations.html', # needs 'show_related': True theme option to display
|
119 |
+
'searchbox.html',
|
120 |
+
'donate.html',
|
121 |
+
],
|
122 |
+
}
|
123 |
+
|
124 |
+
|
125 |
+
# -- Options for HTMLHelp output ------------------------------------------
|
126 |
+
|
127 |
+
# Output file base name for HTML help builder.
|
128 |
+
htmlhelp_basename = 'pytubedoc'
|
129 |
+
|
130 |
+
|
131 |
+
# -- Options for LaTeX output ---------------------------------------------
|
132 |
+
|
133 |
+
latex_elements = {
|
134 |
+
# The paper size ('letterpaper' or 'a4paper').
|
135 |
+
#
|
136 |
+
# 'papersize': 'letterpaper',
|
137 |
+
|
138 |
+
# The font size ('10pt', '11pt' or '12pt').
|
139 |
+
#
|
140 |
+
# 'pointsize': '10pt',
|
141 |
+
|
142 |
+
# Additional stuff for the LaTeX preamble.
|
143 |
+
#
|
144 |
+
# 'preamble': '',
|
145 |
+
|
146 |
+
# Latex figure (float) alignment
|
147 |
+
#
|
148 |
+
# 'figure_align': 'htbp',
|
149 |
+
}
|
150 |
+
|
151 |
+
# Grouping the document tree into LaTeX files. List of tuples
|
152 |
+
# (source start file, target name, title,
|
153 |
+
# author, documentclass [howto, manual, or own class]).
|
154 |
+
latex_documents = [
|
155 |
+
(
|
156 |
+
master_doc, 'pytube.tex', 'pytube Documentation',
|
157 |
+
'Nick Ficano', 'manual',
|
158 |
+
),
|
159 |
+
]
|
160 |
+
|
161 |
+
|
162 |
+
# -- Options for manual page output ---------------------------------------
|
163 |
+
|
164 |
+
# One entry per manual page. List of tuples
|
165 |
+
# (source start file, name, description, authors, manual section).
|
166 |
+
man_pages = [
|
167 |
+
(
|
168 |
+
master_doc, 'pytube', 'pytube Documentation',
|
169 |
+
[author], 1,
|
170 |
+
),
|
171 |
+
]
|
172 |
+
|
173 |
+
|
174 |
+
# -- Options for Texinfo output -------------------------------------------
|
175 |
+
|
176 |
+
# Grouping the document tree into Texinfo files. List of tuples
|
177 |
+
# (source start file, target name, title, author,
|
178 |
+
# dir menu entry, description, category)
|
179 |
+
texinfo_documents = [
|
180 |
+
(
|
181 |
+
master_doc, 'pytube', 'pytube Documentation',
|
182 |
+
author, 'pytube', 'One line description of project.',
|
183 |
+
'Miscellaneous',
|
184 |
+
),
|
185 |
+
]
|
docs/index.rst
ADDED
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
.. pytube documentation master file, created by
|
2 |
+
sphinx-quickstart on Mon Oct 9 02:11:41 2017.
|
3 |
+
You can adapt this file completely to your liking, but it should at least
|
4 |
+
contain the root `toctree` directive.
|
5 |
+
|
6 |
+
Welcome to pytube
|
7 |
+
=================
|
8 |
+
|
9 |
+
pytube is a lightweight, dependency-free Python library (and command-line utility) for downloading YouTube Videos.
|
10 |
+
|
11 |
+
Installation
|
12 |
+
------------
|
13 |
+
|
14 |
+
.. code-block:: bash
|
15 |
+
|
16 |
+
pip install pytube
|
17 |
+
|
18 |
+
Getting started
|
19 |
+
---------------
|
20 |
+
|
21 |
+
Coming soon.
|
22 |
+
|
23 |
+
API Reference
|
24 |
+
-------------
|
25 |
+
|
26 |
+
If you are looking for information on a specific function, class or
|
27 |
+
method, this part of the documentation is for you.
|
28 |
+
|
29 |
+
.. toctree::
|
30 |
+
:maxdepth: 2
|
31 |
+
|
32 |
+
api
|
33 |
+
|
34 |
+
|
35 |
+
Indices and tables
|
36 |
+
==================
|
37 |
+
|
38 |
+
* :ref:`genindex`
|
39 |
+
* :ref:`modindex`
|
40 |
+
* :ref:`search`
|
pytube/cipher.py
CHANGED
@@ -53,15 +53,17 @@ def get_transform_plan(js):
|
|
53 |
The contents of the base.js asset file.
|
54 |
|
55 |
Sample Output:
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
|
|
|
|
65 |
|
66 |
"""
|
67 |
name = re.escape(get_initial_function_name(js))
|
@@ -85,10 +87,12 @@ def get_transform_object(js, var):
|
|
85 |
that descrambles the signature.
|
86 |
|
87 |
Sample Output:
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
|
|
|
|
92 |
|
93 |
"""
|
94 |
pattern = r'var %s={(.*?)};' % re.escape(var)
|
@@ -127,7 +131,11 @@ def get_transform_map(js, var):
|
|
127 |
def reverse(arr, b):
|
128 |
"""Reverse elements in a list.
|
129 |
|
130 |
-
This function is equivalent to:
|
|
|
|
|
|
|
|
|
131 |
|
132 |
This method takes an unused ``b`` variable as their transform functions
|
133 |
universally sent two arguments.
|
@@ -143,7 +151,11 @@ def reverse(arr, b):
|
|
143 |
def splice(arr, b):
|
144 |
"""Add/remove items to/from a list.
|
145 |
|
146 |
-
This function is equivalent to:
|
|
|
|
|
|
|
|
|
147 |
|
148 |
Example usage:
|
149 |
~~~~~~~~~~~~~~
|
@@ -157,7 +169,10 @@ def swap(arr, b):
|
|
157 |
"""Swap positions at b modulus the list length.
|
158 |
|
159 |
This function is equivalent to:
|
160 |
-
|
|
|
|
|
|
|
161 |
|
162 |
Example usage:
|
163 |
~~~~~~~~~~~~~~
|
@@ -199,13 +214,17 @@ def parse_function(js_func):
|
|
199 |
Break a JavaScript transform function down into a two element tuple
|
200 |
containing the function name and some integer-based argument.
|
201 |
|
202 |
-
Sample
|
203 |
-
|
204 |
-
|
|
|
|
|
205 |
|
206 |
Sample Output:
|
207 |
-
|
208 |
-
|
|
|
|
|
209 |
|
210 |
:param str js_func:
|
211 |
The JavaScript version of the transform function.
|
|
|
53 |
The contents of the base.js asset file.
|
54 |
|
55 |
Sample Output:
|
56 |
+
|
57 |
+
.. code-block:: python
|
58 |
+
|
59 |
+
['DE.AJ(a,15)',
|
60 |
+
'DE.VR(a,3)',
|
61 |
+
'DE.AJ(a,51)',
|
62 |
+
'DE.VR(a,3)',
|
63 |
+
'DE.kT(a,51)',
|
64 |
+
'DE.kT(a,8)',
|
65 |
+
'DE.VR(a,3)',
|
66 |
+
'DE.kT(a,21)']
|
67 |
|
68 |
"""
|
69 |
name = re.escape(get_initial_function_name(js))
|
|
|
87 |
that descrambles the signature.
|
88 |
|
89 |
Sample Output:
|
90 |
+
|
91 |
+
.. code-block:: python
|
92 |
+
|
93 |
+
['AJ:function(a){a.reverse()}',
|
94 |
+
'VR:function(a,b){a.splice(0,b)}',
|
95 |
+
'kT:function(a,b){var c=a[0];a[0]=a[b%a.length];a[b]=c}']
|
96 |
|
97 |
"""
|
98 |
pattern = r'var %s={(.*?)};' % re.escape(var)
|
|
|
131 |
def reverse(arr, b):
|
132 |
"""Reverse elements in a list.
|
133 |
|
134 |
+
This function is equivalent to:
|
135 |
+
|
136 |
+
.. code-block:: javascript
|
137 |
+
|
138 |
+
function(a, b) { a.reverse() }.
|
139 |
|
140 |
This method takes an unused ``b`` variable as their transform functions
|
141 |
universally sent two arguments.
|
|
|
151 |
def splice(arr, b):
|
152 |
"""Add/remove items to/from a list.
|
153 |
|
154 |
+
This function is equivalent to:
|
155 |
+
|
156 |
+
.. code-block:: javascript
|
157 |
+
|
158 |
+
function(a, b) { a.splice(0, b) }.
|
159 |
|
160 |
Example usage:
|
161 |
~~~~~~~~~~~~~~
|
|
|
169 |
"""Swap positions at b modulus the list length.
|
170 |
|
171 |
This function is equivalent to:
|
172 |
+
|
173 |
+
.. code-block:: javascript
|
174 |
+
|
175 |
+
function(a, b) { var c=a[0];a[0]=a[b%a.length];a[b]=c }.
|
176 |
|
177 |
Example usage:
|
178 |
~~~~~~~~~~~~~~
|
|
|
214 |
Break a JavaScript transform function down into a two element tuple
|
215 |
containing the function name and some integer-based argument.
|
216 |
|
217 |
+
Sample input:
|
218 |
+
|
219 |
+
.. code-block:: javascript
|
220 |
+
|
221 |
+
DE.AJ(a,15)
|
222 |
|
223 |
Sample Output:
|
224 |
+
|
225 |
+
.. code-block:: python
|
226 |
+
|
227 |
+
('AJ', 15)
|
228 |
|
229 |
:param str js_func:
|
230 |
The JavaScript version of the transform function.
|
pytube/request.py
CHANGED
@@ -41,7 +41,7 @@ def get(
|
|
41 |
|
42 |
|
43 |
def stream_response(response, chunk_size=8 * 1024):
|
44 |
-
"""Read the
|
45 |
while True:
|
46 |
buf = response.read(chunk_size)
|
47 |
if not buf:
|
|
|
41 |
|
42 |
|
43 |
def stream_response(response, chunk_size=8 * 1024):
|
44 |
+
"""Read the response in chunks."""
|
45 |
while True:
|
46 |
buf = response.read(chunk_size)
|
47 |
if not buf:
|
tests/requirements.txt
CHANGED
@@ -6,3 +6,5 @@ pre-commit==0.15.0
|
|
6 |
pytest==3.1.3
|
7 |
pytest-cov==2.4.0
|
8 |
pytest-sugar==0.9.0
|
|
|
|
|
|
6 |
pytest==3.1.3
|
7 |
pytest-cov==2.4.0
|
8 |
pytest-sugar==0.9.0
|
9 |
+
sphinx==1.6.4
|
10 |
+
sphinx-rtd-theme==0.2.4
|