add target_directory() docstring
Browse files- pytube/cipher.py +1 -1
- pytube/helpers.py +12 -2
- pytube/query.py +1 -1
- pytube/streams.py +1 -3
pytube/cipher.py
CHANGED
@@ -144,7 +144,7 @@ def get_transform_map(js: str, var: str) -> Dict:
|
|
144 |
return mapper
|
145 |
|
146 |
|
147 |
-
def reverse(arr: List,
|
148 |
"""Reverse elements in a list.
|
149 |
|
150 |
This function is equivalent to:
|
|
|
144 |
return mapper
|
145 |
|
146 |
|
147 |
+
def reverse(arr: List, _: Optional[Any]):
|
148 |
"""Reverse elements in a list.
|
149 |
|
150 |
This function is equivalent to:
|
pytube/helpers.py
CHANGED
@@ -6,7 +6,7 @@ import os
|
|
6 |
import pprint
|
7 |
import re
|
8 |
import warnings
|
9 |
-
from typing import TypeVar, Callable
|
10 |
|
11 |
from pytube.exceptions import RegexMatchError
|
12 |
|
@@ -138,7 +138,17 @@ def deprecated(reason: str) -> Callable:
|
|
138 |
return decorator
|
139 |
|
140 |
|
141 |
-
def target_directory(output_path: str) -> str:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
142 |
if output_path:
|
143 |
if not os.path.isabs(output_path):
|
144 |
output_path = os.path.join(os.getcwd(), output_path)
|
|
|
6 |
import pprint
|
7 |
import re
|
8 |
import warnings
|
9 |
+
from typing import TypeVar, Callable, Optional
|
10 |
|
11 |
from pytube.exceptions import RegexMatchError
|
12 |
|
|
|
138 |
return decorator
|
139 |
|
140 |
|
141 |
+
def target_directory(output_path: Optional[str]) -> str:
|
142 |
+
"""
|
143 |
+
Function for determining target directory of a download.
|
144 |
+
Returns an absolute path (if relative one given) or the current
|
145 |
+
path (if none given). Makes directory if it does not exist.
|
146 |
+
|
147 |
+
:type output_path: str
|
148 |
+
:rtype: str
|
149 |
+
:returns:
|
150 |
+
An absolute directory path as a string.
|
151 |
+
"""
|
152 |
if output_path:
|
153 |
if not os.path.isabs(output_path):
|
154 |
output_path = os.path.join(os.getcwd(), output_path)
|
pytube/query.py
CHANGED
@@ -296,7 +296,7 @@ class StreamQuery:
|
|
296 |
|
297 |
"""
|
298 |
return (
|
299 |
-
self.filter(only_audio=True,
|
300 |
.order_by("resolution")
|
301 |
.asc()
|
302 |
.last()
|
|
|
296 |
|
297 |
"""
|
298 |
return (
|
299 |
+
self.filter(only_audio=True, audio_codec=codec)
|
300 |
.order_by("resolution")
|
301 |
.asc()
|
302 |
.last()
|
pytube/streams.py
CHANGED
@@ -72,9 +72,7 @@ class Stream:
|
|
72 |
# Same as above, except for the format profile attributes.
|
73 |
self.set_attributes_from_dict(self.fmt_profile)
|
74 |
|
75 |
-
# The player configuration
|
76 |
-
# title.
|
77 |
-
# TODO(nficano): this should be moved to the monostate.
|
78 |
self.player_config_args = player_config_args
|
79 |
|
80 |
# 'video/webm; codecs="vp8, vorbis"' -> 'video/webm', ['vp8', 'vorbis']
|
|
|
72 |
# Same as above, except for the format profile attributes.
|
73 |
self.set_attributes_from_dict(self.fmt_profile)
|
74 |
|
75 |
+
# The player configuration, contains info like the video title.
|
|
|
|
|
76 |
self.player_config_args = player_config_args
|
77 |
|
78 |
# 'video/webm; codecs="vp8, vorbis"' -> 'video/webm', ['vp8', 'vorbis']
|