1
0
mirror of https://codeberg.org/polarisfm/youtube-dl synced 2024-11-26 10:24:33 +01:00

[youtube] Fix likes/dislike extraction

This commit is contained in:
Sergey M․ 2015-06-29 00:48:06 +06:00
parent 507683780e
commit c93d53f5e3

View File

@ -29,6 +29,7 @@ from ..utils import (
get_element_by_id,
int_or_none,
orderedSet,
str_to_int,
unescapeHTML,
unified_strdate,
uppercase_escape,
@ -1005,12 +1006,11 @@ class YoutubeIE(YoutubeBaseInfoExtractor):
video_description = ''
def _extract_count(count_name):
count = self._search_regex(
r'id="watch-%s"[^>]*>.*?([\d,]+)\s*</span>' % re.escape(count_name),
video_webpage, count_name, default=None)
if count is not None:
return int(count.replace(',', ''))
return None
return str_to_int(self._search_regex(
r'-%s-button[^>]+><span[^>]+class="yt-uix-button-content"[^>]*>([\d,]+)</span>'
% re.escape(count_name),
video_webpage, count_name, default=None))
like_count = _extract_count('like')
dislike_count = _extract_count('dislike')