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: