aboutsummaryrefslogtreecommitdiffstats
path: root/youtube/playlist.py
diff options
context:
space:
mode:
authorJames Taylor <user234683@users.noreply.github.com>2018-10-01 18:01:05 -0700
committerJames Taylor <user234683@users.noreply.github.com>2018-10-01 18:01:05 -0700
commitdd800485f0646fbaf49b9c65aa18fc4d18c62c5b (patch)
treed6d231f64d1fc3a24b3227fdd8e7743d722f693b /youtube/playlist.py
parent03f5ccbacb92313efa709aa8c07f9c1514edf504 (diff)
downloadyt-local-dd800485f0646fbaf49b9c65aa18fc4d18c62c5b.tar.lz
yt-local-dd800485f0646fbaf49b9c65aa18fc4d18c62c5b.tar.xz
yt-local-dd800485f0646fbaf49b9c65aa18fc4d18c62c5b.zip
add latency/readtime reporting for more things, round the numbers by reasonable amount
Diffstat (limited to 'youtube/playlist.py')
-rw-r--r--youtube/playlist.py11
1 files changed, 5 insertions, 6 deletions
diff --git a/youtube/playlist.py b/youtube/playlist.py
index d146b92..c16dc7f 100644
--- a/youtube/playlist.py
+++ b/youtube/playlist.py
@@ -46,9 +46,9 @@ headers_1 = (
('X-YouTube-Client-Version', '2.20180614'),
)
-def playlist_first_page(playlist_id):
+def playlist_first_page(playlist_id, report_text = "Retrieved playlist"):
url = 'https://m.youtube.com/playlist?list=' + playlist_id + '&ajax=1&disable_polymer=true'
- content = common.fetch_url(url, common.mobile_ua + headers_1)
+ content = common.fetch_url(url, common.mobile_ua + headers_1, report_text=report_text)
if content[0:4] == b")]}'":
content = content[4:]
content = json.loads(common.uppercase_escape(content.decode('utf-8')))
@@ -66,12 +66,11 @@ def get_videos_ajax(playlist_id, page):
'X-YouTube-Client-Name': '2',
'X-YouTube-Client-Version': '1.20180508',
}
- print("Sending playlist ajax request")
- content = common.fetch_url(url, headers)
+
+ content = common.fetch_url(url, headers, report_text="Retrieved playlist")
'''with open('debug/playlist_debug', 'wb') as f:
f.write(content)'''
content = content[4:]
- print("Finished recieving playlist response")
info = json.loads(common.uppercase_escape(content.decode('utf-8')))
return info
@@ -88,7 +87,7 @@ def get_playlist_page(query_string):
this_page_json = first_page_json
else:
tasks = (
- gevent.spawn(playlist_first_page, playlist_id ),
+ gevent.spawn(playlist_first_page, playlist_id, report_text="Retrieved playlist info" ),
gevent.spawn(get_videos_ajax, playlist_id, page)
)
gevent.joinall(tasks)