fix get_number_of_videos_channel

This commit is contained in:
zrose584 2020-10-09 19:41:31 +02:00
parent 9123d9a6cf
commit a0c33c621e

View File

@ -150,7 +150,8 @@ def get_number_of_videos_channel(channel_id):
response = response.decode('utf-8') response = response.decode('utf-8')
match = re.search(r'"numVideosText":\s*{\s*"runs":\s*\[{"text":\s*"([\d,]*) videos"', response) # match = re.search(r'"numVideosText":\s*{\s*"runs":\s*\[{"text":\s*"([\d,]*) videos"', response)
match = re.search(r'"numVideosText".*?([,\d]+)', response)
if match: if match:
return int(match.group(1).replace(',','')) return int(match.group(1).replace(',',''))
else: else:
@ -209,7 +210,7 @@ def get_channel_page_general_url(base_url, tab, request, channel_id=None):
if tab == 'videos' and channel_id: if tab == 'videos' and channel_id:
tasks = ( tasks = (
gevent.spawn(get_number_of_videos_channel, channel_id), gevent.spawn(get_number_of_videos_channel, channel_id),
gevent.spawn(get_channel_tab, channel_id, page_number, sort, 'videos', view) gevent.spawn(get_channel_tab, channel_id, page_number, sort, 'videos', view)
) )
gevent.joinall(tasks) gevent.joinall(tasks)
@ -217,7 +218,7 @@ def get_channel_page_general_url(base_url, tab, request, channel_id=None):
number_of_videos, polymer_json = tasks[0].value, tasks[1].value number_of_videos, polymer_json = tasks[0].value, tasks[1].value
elif tab == 'videos': elif tab == 'videos':
tasks = ( tasks = (
gevent.spawn(get_number_of_videos_general, base_url), gevent.spawn(get_number_of_videos_general, base_url),
gevent.spawn(util.fetch_url, base_url + '/videos?pbj=1&view=0', headers_desktop, debug_name='gen_channel_videos') gevent.spawn(util.fetch_url, base_url + '/videos?pbj=1&view=0', headers_desktop, debug_name='gen_channel_videos')
) )
gevent.joinall(tasks) gevent.joinall(tasks)