|
@@ -4,17 +4,30 @@ from __future__ import unicode_literals
|
|
import re
|
|
import re
|
|
|
|
|
|
from .common import InfoExtractor
|
|
from .common import InfoExtractor
|
|
-from ..compat import compat_urllib_parse_urlparse
|
|
|
|
-from ..utils import (
|
|
|
|
- ExtractorError,
|
|
|
|
- qualities,
|
|
|
|
- unified_strdate,
|
|
|
|
- clean_html,
|
|
|
|
-)
|
|
|
|
|
|
+from ..utils import int_or_none
|
|
|
|
|
|
|
|
|
|
class UltimediaIE(InfoExtractor):
|
|
class UltimediaIE(InfoExtractor):
|
|
- _VALID_URL = r'https?://(?:www\.)?ultimedia\.com/default/index/video[^/]+/id/(?P<id>[\d+a-z]+)'
|
|
|
|
|
|
+ _VALID_URL = r'''(?x)
|
|
|
|
+ https?://(?:www\.)?ultimedia\.com/
|
|
|
|
+ (?:
|
|
|
|
+ deliver/
|
|
|
|
+ (?P<embed_type>
|
|
|
|
+ generic|
|
|
|
|
+ musique
|
|
|
|
+ )
|
|
|
|
+ (?:/[^/]+)*/
|
|
|
|
+ (?:
|
|
|
|
+ src|
|
|
|
|
+ article
|
|
|
|
+ )|
|
|
|
|
+ default/index/video
|
|
|
|
+ (?P<site_type>
|
|
|
|
+ generic|
|
|
|
|
+ music
|
|
|
|
+ )
|
|
|
|
+ /id
|
|
|
|
+ )/(?P<id>[\d+a-z]+)'''
|
|
_TESTS = [{
|
|
_TESTS = [{
|
|
# news
|
|
# news
|
|
'url': 'https://www.ultimedia.com/default/index/videogeneric/id/s8uk0r',
|
|
'url': 'https://www.ultimedia.com/default/index/videogeneric/id/s8uk0r',
|
|
@@ -23,9 +36,11 @@ class UltimediaIE(InfoExtractor):
|
|
'id': 's8uk0r',
|
|
'id': 's8uk0r',
|
|
'ext': 'mp4',
|
|
'ext': 'mp4',
|
|
'title': 'Loi sur la fin de vie: le texte prévoit un renforcement des directives anticipées',
|
|
'title': 'Loi sur la fin de vie: le texte prévoit un renforcement des directives anticipées',
|
|
- 'description': 'md5:3e5c8fd65791487333dda5db8aed32af',
|
|
|
|
'thumbnail': 're:^https?://.*\.jpg',
|
|
'thumbnail': 're:^https?://.*\.jpg',
|
|
|
|
+ 'duration': 74,
|
|
'upload_date': '20150317',
|
|
'upload_date': '20150317',
|
|
|
|
+ 'timestamp': 1426604939,
|
|
|
|
+ 'uploader_id': '3fszv',
|
|
},
|
|
},
|
|
}, {
|
|
}, {
|
|
# music
|
|
# music
|
|
@@ -34,72 +49,61 @@ class UltimediaIE(InfoExtractor):
|
|
'info_dict': {
|
|
'info_dict': {
|
|
'id': 'xvpfp8',
|
|
'id': 'xvpfp8',
|
|
'ext': 'mp4',
|
|
'ext': 'mp4',
|
|
- 'title': "Two - C'est la vie (Clip)",
|
|
|
|
- 'description': 'Two',
|
|
|
|
|
|
+ 'title': 'Two - C\'est La Vie (clip)',
|
|
'thumbnail': 're:^https?://.*\.jpg',
|
|
'thumbnail': 're:^https?://.*\.jpg',
|
|
|
|
+ 'duration': 233,
|
|
'upload_date': '20150224',
|
|
'upload_date': '20150224',
|
|
|
|
+ 'timestamp': 1424760500,
|
|
|
|
+ 'uploader_id': '3rfzk',
|
|
},
|
|
},
|
|
}]
|
|
}]
|
|
|
|
|
|
- def _real_extract(self, url):
|
|
|
|
- video_id = self._match_id(url)
|
|
|
|
- webpage = self._download_webpage(url, video_id)
|
|
|
|
|
|
+ @staticmethod
|
|
|
|
+ def _extract_url(webpage):
|
|
|
|
+ mobj = re.search(
|
|
|
|
+ r'<(?:iframe|script)[^>]+src=["\'](?P<url>(?:https?:)?//(?:www\.)?ultimedia\.com/deliver/(?:generic|musique)(?:/[^/]+)*/(?:src|article)/[\d+a-z]+)',
|
|
|
|
+ webpage)
|
|
|
|
+ if mobj:
|
|
|
|
+ return mobj.group('url')
|
|
|
|
|
|
- deliver_url = self._proto_relative_url(self._search_regex(
|
|
|
|
- r'<iframe[^>]+src="((?:https?:)?//(?:www\.)?ultimedia\.com/deliver/[^"]+)"',
|
|
|
|
- webpage, 'deliver URL'), compat_urllib_parse_urlparse(url).scheme + ':')
|
|
|
|
|
|
+ def _real_extract(self, url):
|
|
|
|
+ mobj = re.match(self._VALID_URL, url)
|
|
|
|
+ video_id = mobj.group('id')
|
|
|
|
+ video_type = mobj.group('embed_type') or mobj.group('site_type')
|
|
|
|
+ if video_type == 'music':
|
|
|
|
+ video_type = 'musique'
|
|
|
|
|
|
- deliver_page = self._download_webpage(
|
|
|
|
- deliver_url, video_id, 'Downloading iframe page')
|
|
|
|
|
|
+ deliver_info = self._download_json(
|
|
|
|
+ 'http://www.ultimedia.com/deliver/video?video=%s&topic=%s' % (video_id, video_type),
|
|
|
|
+ video_id)
|
|
|
|
|
|
- if '>This video is currently not available' in deliver_page:
|
|
|
|
- raise ExtractorError(
|
|
|
|
- 'Video %s is currently not available' % video_id, expected=True)
|
|
|
|
|
|
+ yt_id = deliver_info.get('yt_id')
|
|
|
|
+ if yt_id:
|
|
|
|
+ return self.url_result(yt_id, 'Youtube')
|
|
|
|
|
|
- player = self._parse_json(
|
|
|
|
- self._search_regex(
|
|
|
|
- r"jwplayer\('player(?:_temp)?'\)\.setup\(({.+?})\)\.on",
|
|
|
|
- deliver_page, 'player'),
|
|
|
|
- video_id)
|
|
|
|
|
|
+ jwconf = deliver_info['jwconf']
|
|
|
|
|
|
- quality = qualities(['flash', 'html5'])
|
|
|
|
formats = []
|
|
formats = []
|
|
- for mode in player['modes']:
|
|
|
|
- video_url = mode.get('config', {}).get('file')
|
|
|
|
- if not video_url:
|
|
|
|
- continue
|
|
|
|
- if re.match(r'https?://www\.youtube\.com/.+?', video_url):
|
|
|
|
- return self.url_result(video_url, 'Youtube')
|
|
|
|
|
|
+ for source in jwconf['playlist'][0]['sources']:
|
|
formats.append({
|
|
formats.append({
|
|
- 'url': video_url,
|
|
|
|
- 'format_id': mode.get('type'),
|
|
|
|
- 'quality': quality(mode.get('type')),
|
|
|
|
|
|
+ 'url': source['file'],
|
|
|
|
+ 'format_id': source.get('label'),
|
|
})
|
|
})
|
|
- self._sort_formats(formats)
|
|
|
|
-
|
|
|
|
- thumbnail = player.get('image')
|
|
|
|
|
|
|
|
- title = clean_html((
|
|
|
|
- self._html_search_regex(
|
|
|
|
- r'(?s)<div\s+id="catArticle">.+?</div>(.+?)</h1>',
|
|
|
|
- webpage, 'title', default=None) or
|
|
|
|
- self._search_regex(
|
|
|
|
- r"var\s+nameVideo\s*=\s*'([^']+)'",
|
|
|
|
- deliver_page, 'title')))
|
|
|
|
-
|
|
|
|
- description = clean_html(self._html_search_regex(
|
|
|
|
- r'(?s)<span>Description</span>(.+?)</p>', webpage,
|
|
|
|
- 'description', fatal=False))
|
|
|
|
|
|
+ self._sort_formats(formats)
|
|
|
|
|
|
- upload_date = unified_strdate(self._search_regex(
|
|
|
|
- r'Ajouté le\s*<span>([^<]+)', webpage,
|
|
|
|
- 'upload date', fatal=False))
|
|
|
|
|
|
+ title = deliver_info['title']
|
|
|
|
+ thumbnail = jwconf.get('image')
|
|
|
|
+ duration = int_or_none(deliver_info.get('duration'))
|
|
|
|
+ timestamp = int_or_none(deliver_info.get('release_time'))
|
|
|
|
+ uploader_id = deliver_info.get('owner_id')
|
|
|
|
|
|
return {
|
|
return {
|
|
'id': video_id,
|
|
'id': video_id,
|
|
'title': title,
|
|
'title': title,
|
|
- 'description': description,
|
|
|
|
'thumbnail': thumbnail,
|
|
'thumbnail': thumbnail,
|
|
- 'upload_date': upload_date,
|
|
|
|
|
|
+ 'duration': duration,
|
|
|
|
+ 'timestamp': timestamp,
|
|
|
|
+ 'uploader_id': uploader_id,
|
|
'formats': formats,
|
|
'formats': formats,
|
|
}
|
|
}
|