more mypy typing
Browse files- pytube/cipher.py +4 -4
pytube/cipher.py
CHANGED
@@ -16,7 +16,7 @@ signature and decoding it.
|
|
16 |
|
17 |
import re
|
18 |
from itertools import chain
|
19 |
-
from typing import List, Tuple
|
20 |
|
21 |
from pytube.exceptions import RegexMatchError
|
22 |
from pytube.helpers import regex_search, create_logger
|
@@ -86,7 +86,7 @@ def get_transform_plan(js: str) -> List[str]:
|
|
86 |
return regex_search(pattern, js, group=1).split(";")
|
87 |
|
88 |
|
89 |
-
def get_transform_object(js: str, var: str):
|
90 |
"""Extract the "transform object".
|
91 |
|
92 |
The "transform object" contains the function definitions referenced in the
|
@@ -120,7 +120,7 @@ def get_transform_object(js: str, var: str):
|
|
120 |
return results.group(1).replace("\n", " ").split(", ")
|
121 |
|
122 |
|
123 |
-
def get_transform_map(js, var):
|
124 |
"""Build a transform function lookup.
|
125 |
|
126 |
Build a lookup table of obfuscated JavaScript function names to the
|
@@ -198,7 +198,7 @@ def swap(arr, b):
|
|
198 |
return list(chain([arr[r]], arr[1:r], [arr[0]], arr[r + 1 :]))
|
199 |
|
200 |
|
201 |
-
def map_functions(js_func):
|
202 |
"""For a given JavaScript transform function, return the Python equivalent.
|
203 |
|
204 |
:param str js_func:
|
|
|
16 |
|
17 |
import re
|
18 |
from itertools import chain
|
19 |
+
from typing import List, Tuple, Dict, Callable
|
20 |
|
21 |
from pytube.exceptions import RegexMatchError
|
22 |
from pytube.helpers import regex_search, create_logger
|
|
|
86 |
return regex_search(pattern, js, group=1).split(";")
|
87 |
|
88 |
|
89 |
+
def get_transform_object(js: str, var: str) -> List[str]:
|
90 |
"""Extract the "transform object".
|
91 |
|
92 |
The "transform object" contains the function definitions referenced in the
|
|
|
120 |
return results.group(1).replace("\n", " ").split(", ")
|
121 |
|
122 |
|
123 |
+
def get_transform_map(js: str, var: str) -> Dict:
|
124 |
"""Build a transform function lookup.
|
125 |
|
126 |
Build a lookup table of obfuscated JavaScript function names to the
|
|
|
198 |
return list(chain([arr[r]], arr[1:r], [arr[0]], arr[r + 1 :]))
|
199 |
|
200 |
|
201 |
+
def map_functions(js_func: str) -> Callable:
|
202 |
"""For a given JavaScript transform function, return the Python equivalent.
|
203 |
|
204 |
:param str js_func:
|