Fix parsing shorts
Add check for extracting duration for shorts Make short duration extraction stricter Fix handling shorts with no views
This commit is contained in:
parent
f322035d4a
commit
e6fd9b40f4
@ -323,8 +323,7 @@ def extract_item_info(item, additional_info={}):
|
|||||||
|
|
||||||
# handle case where it is "No views"
|
# handle case where it is "No views"
|
||||||
if not info['approx_view_count']:
|
if not info['approx_view_count']:
|
||||||
if ('No views' in item.get('shortViewCountText', '')
|
if ('No views' in extract_str(item.get('viewCountText', ''))):
|
||||||
or 'no views' in accessibility_label.lower()):
|
|
||||||
info['view_count'] = 0
|
info['view_count'] = 0
|
||||||
info['approx_view_count'] = '0'
|
info['approx_view_count'] = '0'
|
||||||
|
|
||||||
@ -365,12 +364,13 @@ def extract_item_info(item, additional_info={}):
|
|||||||
['accessibility', 'accessibilityData', 'label'],
|
['accessibility', 'accessibilityData', 'label'],
|
||||||
default='')
|
default='')
|
||||||
|
|
||||||
duration = re.search(r'(\d+) (second|seconds|minute) - play video',
|
duration = re.search(r'(\d+) (second|seconds|minute) - play video$',
|
||||||
accessibility_label)
|
accessibility_label)
|
||||||
if duration.group(2) == 'minute':
|
if duration:
|
||||||
info['duration'] = "1:00"
|
if duration.group(2) == 'minute':
|
||||||
else:
|
info['duration'] = '1:00'
|
||||||
info['duration'] = "0:" + duration.group(1).zfill(2)
|
else:
|
||||||
|
info['duration'] = '0:' + duration.group(1).zfill(2)
|
||||||
|
|
||||||
# if it's an item in a playlist, get its index
|
# if it's an item in a playlist, get its index
|
||||||
if 'index' in item: # url has wrong index on playlist page
|
if 'index' in item: # url has wrong index on playlist page
|
||||||
|
Loading…
x
Reference in New Issue
Block a user