Nick Ficano
commited on
Commit
·
1020439
1
Parent(s):
f4c1990
explicit exception imports, removed unused method
Browse files- pytube/api.py +8 -17
pytube/api.py
CHANGED
|
@@ -1,7 +1,6 @@
|
|
| 1 |
from __future__ import unicode_literals
|
| 2 |
|
| 3 |
-
|
| 4 |
-
from .exceptions import *
|
| 5 |
from .tinyjs import *
|
| 6 |
from .models import Video
|
| 7 |
from .utils import safe_filename
|
|
@@ -148,8 +147,8 @@ class YouTube(object):
|
|
| 148 |
"""Return a filtered list of videos given an extention and resolution
|
| 149 |
criteria.
|
| 150 |
|
| 151 |
-
:
|
| 152 |
-
:
|
| 153 |
"""
|
| 154 |
results = []
|
| 155 |
for v in self.videos:
|
|
@@ -167,8 +166,8 @@ class YouTube(object):
|
|
| 167 |
|
| 168 |
https://gist.github.com/2009119)
|
| 169 |
|
| 170 |
-
:
|
| 171 |
-
:
|
| 172 |
"""
|
| 173 |
elem = path[0]
|
| 174 |
# Get first element in tuple, and check if it contains a list.
|
|
@@ -216,14 +215,6 @@ class YouTube(object):
|
|
| 216 |
|
| 217 |
return videoinfo
|
| 218 |
|
| 219 |
-
def _findBetween(self, s, first, last):
|
| 220 |
-
try:
|
| 221 |
-
start = s.index(first) + len(first)
|
| 222 |
-
end = s.index(last, start)
|
| 223 |
-
return s[start:end]
|
| 224 |
-
except ValueError:
|
| 225 |
-
return ""
|
| 226 |
-
|
| 227 |
def _get_video_info(self):
|
| 228 |
"""This is responsable for executing the request, extracting the
|
| 229 |
necessary details, and populating the different video resolutions and
|
|
@@ -321,8 +312,8 @@ class YouTube(object):
|
|
| 321 |
def _cipher(self, s, url):
|
| 322 |
"""Get the signature using the cipher implemented in the JavaScript code
|
| 323 |
|
| 324 |
-
:
|
| 325 |
-
:
|
| 326 |
"""
|
| 327 |
# TODO: refactor removing tinyJS
|
| 328 |
|
|
@@ -362,7 +353,7 @@ class YouTube(object):
|
|
| 362 |
suspect this is suppose to act as a deterrent.. Nothing some regulular
|
| 363 |
expressions couldn't handle.
|
| 364 |
|
| 365 |
-
:
|
| 366 |
"""
|
| 367 |
itag = re.findall('itag=(\d+)', text)
|
| 368 |
if itag and len(itag) is 1:
|
|
|
|
| 1 |
from __future__ import unicode_literals
|
| 2 |
|
| 3 |
+
from .exceptions import MultipleObjectsReturned, YouTubeError, CipherError
|
|
|
|
| 4 |
from .tinyjs import *
|
| 5 |
from .models import Video
|
| 6 |
from .utils import safe_filename
|
|
|
|
| 147 |
"""Return a filtered list of videos given an extention and resolution
|
| 148 |
criteria.
|
| 149 |
|
| 150 |
+
:param extention: The desired file extention (e.g.: mp4).
|
| 151 |
+
:param resolution: The desired video broadcasting standard.
|
| 152 |
"""
|
| 153 |
results = []
|
| 154 |
for v in self.videos:
|
|
|
|
| 166 |
|
| 167 |
https://gist.github.com/2009119)
|
| 168 |
|
| 169 |
+
:param path: A tuple representing a path to a node within a tree.
|
| 170 |
+
:param data: The data containing the tree.
|
| 171 |
"""
|
| 172 |
elem = path[0]
|
| 173 |
# Get first element in tuple, and check if it contains a list.
|
|
|
|
| 215 |
|
| 216 |
return videoinfo
|
| 217 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 218 |
def _get_video_info(self):
|
| 219 |
"""This is responsable for executing the request, extracting the
|
| 220 |
necessary details, and populating the different video resolutions and
|
|
|
|
| 312 |
def _cipher(self, s, url):
|
| 313 |
"""Get the signature using the cipher implemented in the JavaScript code
|
| 314 |
|
| 315 |
+
:param s: Signature
|
| 316 |
+
:param url: url of JavaScript file
|
| 317 |
"""
|
| 318 |
# TODO: refactor removing tinyJS
|
| 319 |
|
|
|
|
| 353 |
suspect this is suppose to act as a deterrent.. Nothing some regulular
|
| 354 |
expressions couldn't handle.
|
| 355 |
|
| 356 |
+
:param text: The malformed data contained within each url node.
|
| 357 |
"""
|
| 358 |
itag = re.findall('itag=(\d+)', text)
|
| 359 |
if itag and len(itag) is 1:
|