84 print("SSL error, retrying")
85 continue
86 # Happens not deterministically sometimes.
87 if not "onResponseReceivedActions" in data: 88 print("Missing onResponseReceivedActions, retrying")
89 with open("error.json", "w") as f:
90 json.dump(data, f, indent=4)
38
39def getContinuationToken(videoIds, contents):
40 lastContent = contents[-1]
41 if not "continuationItemRenderer" in lastContent: 42 return videoIds
43 return lastContent["continuationItemRenderer"]["continuationEndpoint"][
44 "continuationCommand"
29
30def treatContents(videoIds, contents):
31 for content in contents:
32 if not "richItemRenderer" in content: 33 break
34 videoId = content["richItemRenderer"]["content"]["videoRenderer"]["videoId"]
35 videoIds.add(videoId)
Tests for membership should use the form x not in the_list
rather than not x in the_list
. The former example is simply more readable.
if not x in authors:
authors.append(x)
if x not in authors:
authors.append(x)