Fix comment count extraction due to 'K/M' postfixes
YouTube now displays 2K comments instead of 2359, for instance
This commit is contained in:
parent
ca4a735692
commit
51a1693789
@ -54,7 +54,10 @@ def commatize(num):
|
|||||||
if num is None:
|
if num is None:
|
||||||
return ''
|
return ''
|
||||||
if isinstance(num, str):
|
if isinstance(num, str):
|
||||||
num = int(num)
|
try:
|
||||||
|
num = int(num)
|
||||||
|
except ValueError:
|
||||||
|
return num
|
||||||
return '{:,}'.format(num)
|
return '{:,}'.format(num)
|
||||||
|
|
||||||
|
|
||||||
|
@ -233,7 +233,7 @@
|
|||||||
<div class="comments-area-outer comments-disabled">Comments disabled</div>
|
<div class="comments-area-outer comments-disabled">Comments disabled</div>
|
||||||
{% else %}
|
{% else %}
|
||||||
<details class="comments-area-outer" {{'open' if settings.comments_mode == 1 else ''}}>
|
<details class="comments-area-outer" {{'open' if settings.comments_mode == 1 else ''}}>
|
||||||
<summary>{{ comment_count|commatize }} comment{{'s' if comment_count != 1 else ''}}</summary>
|
<summary>{{ comment_count|commatize }} comment{{'s' if comment_count != '1' else ''}}</summary>
|
||||||
<div class="comments-area-inner comments-area">
|
<div class="comments-area-inner comments-area">
|
||||||
{% if comments_info %}
|
{% if comments_info %}
|
||||||
{{ comments.video_comments(comments_info) }}
|
{{ comments.video_comments(comments_info) }}
|
||||||
|
@ -363,12 +363,12 @@ def _extract_watch_info_mobile(top_level):
|
|||||||
comment_count_text = extract_str(deep_get(comment_info,
|
comment_count_text = extract_str(deep_get(comment_info,
|
||||||
'header', 'commentSectionHeaderRenderer', 'countText'))
|
'header', 'commentSectionHeaderRenderer', 'countText'))
|
||||||
if comment_count_text == 'Comments': # just this with no number, means 0 comments
|
if comment_count_text == 'Comments': # just this with no number, means 0 comments
|
||||||
info['comment_count'] = 0
|
info['comment_count'] = '0'
|
||||||
else:
|
else:
|
||||||
info['comment_count'] = extract_int(comment_count_text)
|
info['comment_count'] = extract_approx_int(comment_count_text)
|
||||||
info['comments_disabled'] = False
|
info['comments_disabled'] = False
|
||||||
else: # no comment section present means comments are disabled
|
else: # no comment section present means comments are disabled
|
||||||
info['comment_count'] = 0
|
info['comment_count'] = '0'
|
||||||
info['comments_disabled'] = True
|
info['comments_disabled'] = True
|
||||||
|
|
||||||
# check for limited state
|
# check for limited state
|
||||||
|
Loading…
x
Reference in New Issue
Block a user