Browse Source

youtube-util: validation for shelf items

pull/11/head
tech234a 3 years ago
parent
commit
7a70bc25b5
1 changed files with 23 additions and 3 deletions
  1. +23
    -3
      youtube_channel.py

+ 23
- 3
youtube_channel.py View File

@@ -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 """</div><div id="content" class=" content-alignment" role="main"><p class='largeText'>Sorry for the interruption. We have been receiving a large volume of requests from your network.</p>

<p>To continue with your YouTube experience, please fill out the form below.</p>""" 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 """</div><div id="content" class=" content-alignment" role="main"><p class='largeText'>Sorry for the interruption. We have been receiving a large volume of requests from your network.</p>

<p>To continue with your YouTube experience, please fill out the form below.</p>""" 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:


Loading…
Cancel
Save