replace fp with file_path
Browse files- pytube/cipher.py +1 -1
- pytube/streams.py +4 -5
pytube/cipher.py
CHANGED
@@ -53,7 +53,7 @@ def get_initial_function_name(js: str) -> str:
|
|
53 |
regex = re.compile(pattern)
|
54 |
results = regex.search(js)
|
55 |
if results:
|
56 |
-
logger.debug("finished regex search, matched: {pattern}".format(pattern=
|
57 |
return results.group(1)
|
58 |
|
59 |
raise RegexMatchError(caller="get_initial_function_name", pattern="multiple")
|
|
|
53 |
regex = re.compile(pattern)
|
54 |
results = regex.search(js)
|
55 |
if results:
|
56 |
+
logger.debug("finished regex search, matched: {pattern}".format(pattern=pattern))
|
57 |
return results.group(1)
|
58 |
|
59 |
raise RegexMatchError(caller="get_initial_function_name", pattern="multiple")
|
pytube/streams.py
CHANGED
@@ -236,21 +236,20 @@ class Stream:
|
|
236 |
prefix=safe_filename(filename_prefix), filename=filename,
|
237 |
)
|
238 |
|
239 |
-
|
240 |
-
fp = os.path.join(output_path, filename)
|
241 |
bytes_remaining = self.filesize
|
242 |
logger.debug(
|
243 |
-
"downloading (%s total bytes) file to %s", self.filesize,
|
244 |
)
|
245 |
|
246 |
-
with open(
|
247 |
for chunk in request.get(self.url, streaming=True):
|
248 |
# reduce the (bytes) remainder by the length of the chunk.
|
249 |
bytes_remaining -= len(chunk)
|
250 |
# send to the on_progress callback.
|
251 |
self.on_progress(chunk, fh, bytes_remaining)
|
252 |
self.on_complete(fh)
|
253 |
-
return
|
254 |
|
255 |
def stream_to_buffer(self) -> io.BytesIO:
|
256 |
"""Write the media stream to buffer
|
|
|
236 |
prefix=safe_filename(filename_prefix), filename=filename,
|
237 |
)
|
238 |
|
239 |
+
file_path = os.path.join(output_path, filename)
|
|
|
240 |
bytes_remaining = self.filesize
|
241 |
logger.debug(
|
242 |
+
"downloading (%s total bytes) file to %s", self.filesize, file_path,
|
243 |
)
|
244 |
|
245 |
+
with open(file_path, "wb") as fh:
|
246 |
for chunk in request.get(self.url, streaming=True):
|
247 |
# reduce the (bytes) remainder by the length of the chunk.
|
248 |
bytes_remaining -= len(chunk)
|
249 |
# send to the on_progress callback.
|
250 |
self.on_progress(chunk, fh, bytes_remaining)
|
251 |
self.on_complete(fh)
|
252 |
+
return file_path
|
253 |
|
254 |
def stream_to_buffer(self) -> io.BytesIO:
|
255 |
"""Write the media stream to buffer
|