projects
/
youtube-dl
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
[GenericIE] Outsource embedded blip.tv player video id extraction to BlipTVIE and...
[youtube-dl]
/
youtube_dl
/
extractor
/
dailymotion.py
diff --git
a/youtube_dl/extractor/dailymotion.py
b/youtube_dl/extractor/dailymotion.py
index 355b4ed0a028540c81a486ac4f389d50cbf48987..6685c94a3d6b283e0b7f2240ebfcf35ce462edc2 100644
(file)
--- a/
youtube_dl/extractor/dailymotion.py
+++ b/
youtube_dl/extractor/dailymotion.py
@@
-11,6
+11,7
@@
from ..utils import (
get_element_by_attribute,
get_element_by_id,
orderedSet,
get_element_by_attribute,
get_element_by_id,
orderedSet,
+ str_to_int,
ExtractorError,
)
ExtractorError,
)
@@
-27,7
+28,7
@@
class DailymotionBaseInfoExtractor(InfoExtractor):
class DailymotionIE(DailymotionBaseInfoExtractor, SubtitlesInfoExtractor):
"""Information Extractor for Dailymotion"""
class DailymotionIE(DailymotionBaseInfoExtractor, SubtitlesInfoExtractor):
"""Information Extractor for Dailymotion"""
- _VALID_URL = r'(?i)(?:https?://)?(?:
www\.)?dailymotion\.[a-z]{2,3}/(?:embed/)?video/([^/
]+)'
+ _VALID_URL = r'(?i)(?:https?://)?(?:
(www|touch)\.)?dailymotion\.[a-z]{2,3}/(?:(embed|#)/)?video/(?P<id>[^/?_
]+)'
IE_NAME = u'dailymotion'
_FORMATS = [
IE_NAME = u'dailymotion'
_FORMATS = [
@@
-80,7
+81,7
@@
class DailymotionIE(DailymotionBaseInfoExtractor, SubtitlesInfoExtractor):
# Extract id and simplified title from URL
mobj = re.match(self._VALID_URL, url)
# Extract id and simplified title from URL
mobj = re.match(self._VALID_URL, url)
- video_id = mobj.group(
1).split('_')[0].split('?')[0]
+ video_id = mobj.group(
'id')
url = 'http://www.dailymotion.com/video/%s' % video_id
url = 'http://www.dailymotion.com/video/%s' % video_id
@@
-100,10
+101,6
@@
class DailymotionIE(DailymotionBaseInfoExtractor, SubtitlesInfoExtractor):
self.to_screen(u'Vevo video detected: %s' % vevo_id)
return self.url_result(u'vevo:%s' % vevo_id, ie='Vevo')
self.to_screen(u'Vevo video detected: %s' % vevo_id)
return self.url_result(u'vevo:%s' % vevo_id, ie='Vevo')
- video_uploader = self._search_regex([r'(?im)<span class="owner[^\"]+?">[^<]+?<a [^>]+?>([^<]+?)</a>',
- # Looking for official user
- r'<(?:span|a) .*?rel="author".*?>([^<]+?)</'],
- webpage, 'video uploader', fatal=False)
age_limit = self._rta_search(webpage)
video_upload_date = None
age_limit = self._rta_search(webpage)
video_upload_date = None
@@
-141,23
+138,29
@@
class DailymotionIE(DailymotionBaseInfoExtractor, SubtitlesInfoExtractor):
raise ExtractorError(u'Unable to extract video URL')
# subtitles
raise ExtractorError(u'Unable to extract video URL')
# subtitles
- video_subtitles = self.extract_subtitles(video_id)
+ video_subtitles = self.extract_subtitles(video_id
, webpage
)
if self._downloader.params.get('listsubtitles', False):
if self._downloader.params.get('listsubtitles', False):
- self._list_available_subtitles(video_id)
+ self._list_available_subtitles(video_id
, webpage
)
return
return
+ view_count = self._search_regex(
+ r'video_views_count[^>]+>\s+([\d\.,]+)', webpage, u'view count', fatal=False)
+ if view_count is not None:
+ view_count = str_to_int(view_count)
+
return {
'id': video_id,
'formats': formats,
return {
'id': video_id,
'formats': formats,
- 'uploader':
video_uploader
,
+ 'uploader':
info['owner_screenname']
,
'upload_date': video_upload_date,
'title': self._og_search_title(webpage),
'subtitles': video_subtitles,
'thumbnail': info['thumbnail_url'],
'age_limit': age_limit,
'upload_date': video_upload_date,
'title': self._og_search_title(webpage),
'subtitles': video_subtitles,
'thumbnail': info['thumbnail_url'],
'age_limit': age_limit,
+ 'view_count': view_count,
}
}
- def _get_available_subtitles(self, video_id):
+ def _get_available_subtitles(self, video_id
, webpage
):
try:
sub_list = self._download_webpage(
'https://api.dailymotion.com/video/%s/subtitles?fields=id,language,url' % video_id,
try:
sub_list = self._download_webpage(
'https://api.dailymotion.com/video/%s/subtitles?fields=id,language,url' % video_id,
@@
-186,7
+189,7
@@
class DailymotionPlaylistIE(DailymotionBaseInfoExtractor):
webpage = self._download_webpage(request,
id, u'Downloading page %s' % pagenum)
webpage = self._download_webpage(request,
id, u'Downloading page %s' % pagenum)
- playlist_el = get_element_by_attribute(u'class', u'video_list', webpage)
+ playlist_el = get_element_by_attribute(u'class', u'
row
video_list', webpage)
video_ids.extend(re.findall(r'data-id="(.+?)"', playlist_el))
if re.search(self._MORE_PAGES_INDICATOR, webpage, re.DOTALL) is None:
video_ids.extend(re.findall(r'data-id="(.+?)"', playlist_el))
if re.search(self._MORE_PAGES_INDICATOR, webpage, re.DOTALL) is None: