channel: Don't completely fail if can't retrieve # of vids
This commit is contained in:
parent
0cb61ef4b6
commit
7f9e91da7a
@ -107,7 +107,16 @@ def get_number_of_videos(channel_id):
|
|||||||
playlist_id = 'UU' + channel_id[2:]
|
playlist_id = 'UU' + channel_id[2:]
|
||||||
url = 'https://m.youtube.com/playlist?list=' + playlist_id + '&pbj=1'
|
url = 'https://m.youtube.com/playlist?list=' + playlist_id + '&pbj=1'
|
||||||
print("Getting number of videos")
|
print("Getting number of videos")
|
||||||
|
|
||||||
|
# Sometimes retrieving playlist info fails with 403 for no discernable reason
|
||||||
|
try:
|
||||||
response = common.fetch_url(url, common.mobile_ua + headers_pbj)
|
response = common.fetch_url(url, common.mobile_ua + headers_pbj)
|
||||||
|
except urllib.error.HTTPError as e:
|
||||||
|
if e.code != 403:
|
||||||
|
raise
|
||||||
|
print("Couldn't retrieve number of videos")
|
||||||
|
return 1000
|
||||||
|
|
||||||
'''with open('debug/playlist_debug_metadata', 'wb') as f:
|
'''with open('debug/playlist_debug_metadata', 'wb') as f:
|
||||||
f.write(response)'''
|
f.write(response)'''
|
||||||
response = response.decode('utf-8')
|
response = response.decode('utf-8')
|
||||||
|
Loading…
x
Reference in New Issue
Block a user