deepsource code linting
Browse files- pytube/contrib/playlist.py +1 -1
- pytube/request.py +4 -3
pytube/contrib/playlist.py
CHANGED
@@ -70,7 +70,7 @@ class Playlist:
|
|
70 |
# The above only returns 100 or fewer links
|
71 |
# Simulating a browser request for the load more link
|
72 |
load_more_url = self._load_more_url(req)
|
73 |
-
while len(load_more_url): # there is an url found
|
74 |
logger.debug("load more url: %s", load_more_url)
|
75 |
req = request.get(load_more_url)
|
76 |
load_more = json.loads(req)
|
|
|
70 |
# The above only returns 100 or fewer links
|
71 |
# Simulating a browser request for the load more link
|
72 |
load_more_url = self._load_more_url(req)
|
73 |
+
while len(load_more_url) > 0: # there is an url found
|
74 |
logger.debug("load more url: %s", load_more_url)
|
75 |
req = request.get(load_more_url)
|
76 |
load_more = json.loads(req)
|
pytube/request.py
CHANGED
@@ -7,7 +7,7 @@ from urllib.request import urlopen
|
|
7 |
|
8 |
|
9 |
def get(
|
10 |
-
url
|
11 |
):
|
12 |
"""Send an http GET request.
|
13 |
|
@@ -21,15 +21,16 @@ def get(
|
|
21 |
The size in bytes of each chunk.
|
22 |
"""
|
23 |
|
24 |
-
# https://github.com/nficano/pytube/pull/465
|
25 |
req = Request(url, headers={"User-Agent": "Mozilla/5.0"})
|
26 |
response = urlopen(req)
|
27 |
|
28 |
if streaming:
|
29 |
return stream_response(response, chunk_size)
|
30 |
-
|
|
|
31 |
# https://github.com/nficano/pytube/issues/160
|
32 |
return {k.lower(): v for k, v in response.info().items()}
|
|
|
33 |
return response.read().decode("utf-8")
|
34 |
|
35 |
|
|
|
7 |
|
8 |
|
9 |
def get(
|
10 |
+
url, headers=False, streaming=False, chunk_size=8 * 1024,
|
11 |
):
|
12 |
"""Send an http GET request.
|
13 |
|
|
|
21 |
The size in bytes of each chunk.
|
22 |
"""
|
23 |
|
|
|
24 |
req = Request(url, headers={"User-Agent": "Mozilla/5.0"})
|
25 |
response = urlopen(req)
|
26 |
|
27 |
if streaming:
|
28 |
return stream_response(response, chunk_size)
|
29 |
+
|
30 |
+
if headers:
|
31 |
# https://github.com/nficano/pytube/issues/160
|
32 |
return {k.lower(): v for k, v in response.info().items()}
|
33 |
+
|
34 |
return response.read().decode("utf-8")
|
35 |
|
36 |
|