From 7a70bc25b59624be82f354d1586091de648ddfe6 Mon Sep 17 00:00:00 2001
From: tech234a <46801700+tech234a@users.noreply.github.com>
Date: Sat, 17 Oct 2020 01:52:16 -0400
Subject: [PATCH] youtube-util: validation for shelf items
---
youtube_channel.py | 26 +++++++++++++++++++++++---
1 file changed, 23 insertions(+), 3 deletions(-)
diff --git a/youtube_channel.py b/youtube_channel.py
index 2a4b133..93f6750 100644
--- a/youtube_channel.py
+++ b/youtube_channel.py
@@ -64,7 +64,17 @@ def process_channel(channelid: str):
channellist.add(playlist["gridPlaylistRenderer"]["shortBylineText"]["runs"][0]["navigationEndpoint"]["browseEndpoint"]["browseId"])
for item in shelfres:
- shelfiteminitdata = getinitialdata(mysession.get("https://www.youtube.com/"+str(item)).text)
+ while True:
+ shelfintp = mysession.get("https://www.youtube.com/"+str(item))
+ if not """
Sorry for the interruption. We have been receiving a large volume of requests from your network.
+
+
To continue with your YouTube experience, please fill out the form below.
""" in shelfintp.text and not shelfintp.status_code == 200:
+ break
+ else:
+ print("Non-200 status code, waiting 30 seconds before retrying...")
+ sleep(30)
+
+ shelfiteminitdata = getinitialdata(shelfintp.text)
playlistsint = fullyexpand(shelfiteminitdata["contents"]["twoColumnBrowseResultsRenderer"]["tabs"][PLAYLISTS_ID]["tabRenderer"]["content"]["sectionListRenderer"]["contents"][0]["itemSectionRenderer"]["contents"][0]["gridRenderer"], mysession, continuationheaders)["items"]
for playlist in playlistsint:
@@ -85,7 +95,7 @@ def process_channel(channelid: str):
else:
print("Non-200 API status code, waiting 30 seconds before retrying...")
sleep(30)
-
+
shelflist = initdata["contents"]["twoColumnBrowseResultsRenderer"]["tabs"][CHANNELS_ID]["tabRenderer"]["content"]["sectionListRenderer"]["contents"]
for item in shelflist:
@@ -99,7 +109,17 @@ def process_channel(channelid: str):
channellist.add(channel["gridChannelRenderer"]["channelId"])
for item in cshelfres:
- shelfiteminitdata = getinitialdata(mysession.get("https://www.youtube.com/"+str(item)).text)
+ while True:
+ shelfintc = mysession.get("https://www.youtube.com/"+str(item))
+ if not """
Sorry for the interruption. We have been receiving a large volume of requests from your network.
+
+
To continue with your YouTube experience, please fill out the form below.
""" in shelfintc.text and not shelfintc.status_code == 200:
+ break
+ else:
+ print("Non-200 status code, waiting 30 seconds before retrying...")
+ sleep(30)
+
+ shelfiteminitdata = getinitialdata(shelfintc.text)
chanlistint = fullyexpand(shelfiteminitdata["contents"]["twoColumnBrowseResultsRenderer"]["tabs"][CHANNELS_ID]["tabRenderer"]["content"]["sectionListRenderer"]["contents"][0]["itemSectionRenderer"]["contents"][0]["gridRenderer"], mysession, continuationheaders)["items"]
for channel in chanlistint: