[dailymotion] Extract view count (#1895)
This commit is contained in:
parent
336c3a69bd
commit
f53c966a73
3 changed files with 14 additions and 0 deletions
|
@ -11,6 +11,7 @@ from ..utils import (
|
|||
get_element_by_attribute,
|
||||
get_element_by_id,
|
||||
orderedSet,
|
||||
str_to_int,
|
||||
|
||||
ExtractorError,
|
||||
)
|
||||
|
@ -146,6 +147,9 @@ class DailymotionIE(DailymotionBaseInfoExtractor, SubtitlesInfoExtractor):
|
|||
self._list_available_subtitles(video_id, webpage)
|
||||
return
|
||||
|
||||
view_count = str_to_int(self._search_regex(
|
||||
r'video_views_value[^>]+>([\d\.]+)<', webpage, u'view count'))
|
||||
|
||||
return {
|
||||
'id': video_id,
|
||||
'formats': formats,
|
||||
|
@ -155,6 +159,7 @@ class DailymotionIE(DailymotionBaseInfoExtractor, SubtitlesInfoExtractor):
|
|||
'subtitles': video_subtitles,
|
||||
'thumbnail': info['thumbnail_url'],
|
||||
'age_limit': age_limit,
|
||||
'view_count': view_count,
|
||||
}
|
||||
|
||||
def _get_available_subtitles(self, video_id, webpage):
|
||||
|
|
|
@ -1020,3 +1020,7 @@ def format_bytes(bytes):
|
|||
suffix = [u'B', u'KiB', u'MiB', u'GiB', u'TiB', u'PiB', u'EiB', u'ZiB', u'YiB'][exponent]
|
||||
converted = float(bytes) / float(1024 ** exponent)
|
||||
return u'%.2f%s' % (converted, suffix)
|
||||
|
||||
def str_to_int(int_str):
|
||||
int_str = re.sub(r'[,\.]', u'', int_str)
|
||||
return int(int_str)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue