You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

418 lines
16 KiB

10 years ago
Switch codebase to use sanitized_Request instead of compat_urllib_request.Request [downloader/dash] Use sanitized_Request [downloader/http] Use sanitized_Request [atresplayer] Use sanitized_Request [bambuser] Use sanitized_Request [bliptv] Use sanitized_Request [brightcove] Use sanitized_Request [cbs] Use sanitized_Request [ceskatelevize] Use sanitized_Request [collegerama] Use sanitized_Request [extractor/common] Use sanitized_Request [crunchyroll] Use sanitized_Request [dailymotion] Use sanitized_Request [dcn] Use sanitized_Request [dramafever] Use sanitized_Request [dumpert] Use sanitized_Request [eitb] Use sanitized_Request [escapist] Use sanitized_Request [everyonesmixtape] Use sanitized_Request [extremetube] Use sanitized_Request [facebook] Use sanitized_Request [fc2] Use sanitized_Request [flickr] Use sanitized_Request [4tube] Use sanitized_Request [gdcvault] Use sanitized_Request [extractor/generic] Use sanitized_Request [hearthisat] Use sanitized_Request [hotnewhiphop] Use sanitized_Request [hypem] Use sanitized_Request [iprima] Use sanitized_Request [ivi] Use sanitized_Request [keezmovies] Use sanitized_Request [letv] Use sanitized_Request [lynda] Use sanitized_Request [metacafe] Use sanitized_Request [minhateca] Use sanitized_Request [miomio] Use sanitized_Request [meovideo] Use sanitized_Request [mofosex] Use sanitized_Request [moniker] Use sanitized_Request [mooshare] Use sanitized_Request [movieclips] Use sanitized_Request [mtv] Use sanitized_Request [myvideo] Use sanitized_Request [neteasemusic] Use sanitized_Request [nfb] Use sanitized_Request [niconico] Use sanitized_Request [noco] Use sanitized_Request [nosvideo] Use sanitized_Request [novamov] Use sanitized_Request [nowness] Use sanitized_Request [nuvid] Use sanitized_Request [played] Use sanitized_Request [pluralsight] Use sanitized_Request [pornhub] Use sanitized_Request [pornotube] Use sanitized_Request [primesharetv] Use sanitized_Request [promptfile] Use sanitized_Request [qqmusic] Use sanitized_Request [rtve] Use sanitized_Request [safari] Use sanitized_Request [sandia] Use sanitized_Request [shared] Use sanitized_Request [sharesix] Use sanitized_Request [sina] Use sanitized_Request [smotri] Use sanitized_Request [sohu] Use sanitized_Request [spankwire] Use sanitized_Request [sportdeutschland] Use sanitized_Request [streamcloud] Use sanitized_Request [streamcz] Use sanitized_Request [tapely] Use sanitized_Request [tube8] Use sanitized_Request [tubitv] Use sanitized_Request [twitch] Use sanitized_Request [twitter] Use sanitized_Request [udemy] Use sanitized_Request [vbox7] Use sanitized_Request [veoh] Use sanitized_Request [vessel] Use sanitized_Request [vevo] Use sanitized_Request [viddler] Use sanitized_Request [videomega] Use sanitized_Request [viewvster] Use sanitized_Request [viki] Use sanitized_Request [vk] Use sanitized_Request [vodlocker] Use sanitized_Request [voicerepublic] Use sanitized_Request [wistia] Use sanitized_Request [xfileshare] Use sanitized_Request [xtube] Use sanitized_Request [xvideos] Use sanitized_Request [yandexmusic] Use sanitized_Request [youku] Use sanitized_Request [youporn] Use sanitized_Request [youtube] Use sanitized_Request [patreon] Use sanitized_Request [extractor/common] Remove unused import [nfb] PEP 8
9 years ago
Switch codebase to use sanitized_Request instead of compat_urllib_request.Request [downloader/dash] Use sanitized_Request [downloader/http] Use sanitized_Request [atresplayer] Use sanitized_Request [bambuser] Use sanitized_Request [bliptv] Use sanitized_Request [brightcove] Use sanitized_Request [cbs] Use sanitized_Request [ceskatelevize] Use sanitized_Request [collegerama] Use sanitized_Request [extractor/common] Use sanitized_Request [crunchyroll] Use sanitized_Request [dailymotion] Use sanitized_Request [dcn] Use sanitized_Request [dramafever] Use sanitized_Request [dumpert] Use sanitized_Request [eitb] Use sanitized_Request [escapist] Use sanitized_Request [everyonesmixtape] Use sanitized_Request [extremetube] Use sanitized_Request [facebook] Use sanitized_Request [fc2] Use sanitized_Request [flickr] Use sanitized_Request [4tube] Use sanitized_Request [gdcvault] Use sanitized_Request [extractor/generic] Use sanitized_Request [hearthisat] Use sanitized_Request [hotnewhiphop] Use sanitized_Request [hypem] Use sanitized_Request [iprima] Use sanitized_Request [ivi] Use sanitized_Request [keezmovies] Use sanitized_Request [letv] Use sanitized_Request [lynda] Use sanitized_Request [metacafe] Use sanitized_Request [minhateca] Use sanitized_Request [miomio] Use sanitized_Request [meovideo] Use sanitized_Request [mofosex] Use sanitized_Request [moniker] Use sanitized_Request [mooshare] Use sanitized_Request [movieclips] Use sanitized_Request [mtv] Use sanitized_Request [myvideo] Use sanitized_Request [neteasemusic] Use sanitized_Request [nfb] Use sanitized_Request [niconico] Use sanitized_Request [noco] Use sanitized_Request [nosvideo] Use sanitized_Request [novamov] Use sanitized_Request [nowness] Use sanitized_Request [nuvid] Use sanitized_Request [played] Use sanitized_Request [pluralsight] Use sanitized_Request [pornhub] Use sanitized_Request [pornotube] Use sanitized_Request [primesharetv] Use sanitized_Request [promptfile] Use sanitized_Request [qqmusic] Use sanitized_Request [rtve] Use sanitized_Request [safari] Use sanitized_Request [sandia] Use sanitized_Request [shared] Use sanitized_Request [sharesix] Use sanitized_Request [sina] Use sanitized_Request [smotri] Use sanitized_Request [sohu] Use sanitized_Request [spankwire] Use sanitized_Request [sportdeutschland] Use sanitized_Request [streamcloud] Use sanitized_Request [streamcz] Use sanitized_Request [tapely] Use sanitized_Request [tube8] Use sanitized_Request [tubitv] Use sanitized_Request [twitch] Use sanitized_Request [twitter] Use sanitized_Request [udemy] Use sanitized_Request [vbox7] Use sanitized_Request [veoh] Use sanitized_Request [vessel] Use sanitized_Request [vevo] Use sanitized_Request [viddler] Use sanitized_Request [videomega] Use sanitized_Request [viewvster] Use sanitized_Request [viki] Use sanitized_Request [vk] Use sanitized_Request [vodlocker] Use sanitized_Request [voicerepublic] Use sanitized_Request [wistia] Use sanitized_Request [xfileshare] Use sanitized_Request [xtube] Use sanitized_Request [xvideos] Use sanitized_Request [yandexmusic] Use sanitized_Request [youku] Use sanitized_Request [youporn] Use sanitized_Request [youtube] Use sanitized_Request [patreon] Use sanitized_Request [extractor/common] Remove unused import [nfb] PEP 8
9 years ago
10 years ago
Switch codebase to use sanitized_Request instead of compat_urllib_request.Request [downloader/dash] Use sanitized_Request [downloader/http] Use sanitized_Request [atresplayer] Use sanitized_Request [bambuser] Use sanitized_Request [bliptv] Use sanitized_Request [brightcove] Use sanitized_Request [cbs] Use sanitized_Request [ceskatelevize] Use sanitized_Request [collegerama] Use sanitized_Request [extractor/common] Use sanitized_Request [crunchyroll] Use sanitized_Request [dailymotion] Use sanitized_Request [dcn] Use sanitized_Request [dramafever] Use sanitized_Request [dumpert] Use sanitized_Request [eitb] Use sanitized_Request [escapist] Use sanitized_Request [everyonesmixtape] Use sanitized_Request [extremetube] Use sanitized_Request [facebook] Use sanitized_Request [fc2] Use sanitized_Request [flickr] Use sanitized_Request [4tube] Use sanitized_Request [gdcvault] Use sanitized_Request [extractor/generic] Use sanitized_Request [hearthisat] Use sanitized_Request [hotnewhiphop] Use sanitized_Request [hypem] Use sanitized_Request [iprima] Use sanitized_Request [ivi] Use sanitized_Request [keezmovies] Use sanitized_Request [letv] Use sanitized_Request [lynda] Use sanitized_Request [metacafe] Use sanitized_Request [minhateca] Use sanitized_Request [miomio] Use sanitized_Request [meovideo] Use sanitized_Request [mofosex] Use sanitized_Request [moniker] Use sanitized_Request [mooshare] Use sanitized_Request [movieclips] Use sanitized_Request [mtv] Use sanitized_Request [myvideo] Use sanitized_Request [neteasemusic] Use sanitized_Request [nfb] Use sanitized_Request [niconico] Use sanitized_Request [noco] Use sanitized_Request [nosvideo] Use sanitized_Request [novamov] Use sanitized_Request [nowness] Use sanitized_Request [nuvid] Use sanitized_Request [played] Use sanitized_Request [pluralsight] Use sanitized_Request [pornhub] Use sanitized_Request [pornotube] Use sanitized_Request [primesharetv] Use sanitized_Request [promptfile] Use sanitized_Request [qqmusic] Use sanitized_Request [rtve] Use sanitized_Request [safari] Use sanitized_Request [sandia] Use sanitized_Request [shared] Use sanitized_Request [sharesix] Use sanitized_Request [sina] Use sanitized_Request [smotri] Use sanitized_Request [sohu] Use sanitized_Request [spankwire] Use sanitized_Request [sportdeutschland] Use sanitized_Request [streamcloud] Use sanitized_Request [streamcz] Use sanitized_Request [tapely] Use sanitized_Request [tube8] Use sanitized_Request [tubitv] Use sanitized_Request [twitch] Use sanitized_Request [twitter] Use sanitized_Request [udemy] Use sanitized_Request [vbox7] Use sanitized_Request [veoh] Use sanitized_Request [vessel] Use sanitized_Request [vevo] Use sanitized_Request [viddler] Use sanitized_Request [videomega] Use sanitized_Request [viewvster] Use sanitized_Request [viki] Use sanitized_Request [vk] Use sanitized_Request [vodlocker] Use sanitized_Request [voicerepublic] Use sanitized_Request [wistia] Use sanitized_Request [xfileshare] Use sanitized_Request [xtube] Use sanitized_Request [xvideos] Use sanitized_Request [yandexmusic] Use sanitized_Request [youku] Use sanitized_Request [youporn] Use sanitized_Request [youtube] Use sanitized_Request [patreon] Use sanitized_Request [extractor/common] Remove unused import [nfb] PEP 8
9 years ago
10 years ago
  1. # coding: utf-8
  2. from __future__ import unicode_literals
  3. import re
  4. import json
  5. import itertools
  6. from .common import InfoExtractor
  7. from ..compat import compat_str
  8. from ..utils import (
  9. ExtractorError,
  10. determine_ext,
  11. int_or_none,
  12. parse_iso8601,
  13. sanitized_Request,
  14. str_to_int,
  15. unescapeHTML,
  16. )
  17. class DailymotionBaseInfoExtractor(InfoExtractor):
  18. @staticmethod
  19. def _build_request(url):
  20. """Build a request with the family filter disabled"""
  21. request = sanitized_Request(url)
  22. request.add_header('Cookie', 'family_filter=off; ff=off')
  23. return request
  24. def _download_webpage_handle_no_ff(self, url, *args, **kwargs):
  25. request = self._build_request(url)
  26. return self._download_webpage_handle(request, *args, **kwargs)
  27. def _download_webpage_no_ff(self, url, *args, **kwargs):
  28. request = self._build_request(url)
  29. return self._download_webpage(request, *args, **kwargs)
  30. class DailymotionIE(DailymotionBaseInfoExtractor):
  31. _VALID_URL = r'(?i)(?:https?://)?(?:(www|touch)\.)?dailymotion\.[a-z]{2,3}/(?:(embed|#)/)?video/(?P<id>[^/?_]+)'
  32. IE_NAME = 'dailymotion'
  33. _FORMATS = [
  34. ('stream_h264_ld_url', 'ld'),
  35. ('stream_h264_url', 'standard'),
  36. ('stream_h264_hq_url', 'hq'),
  37. ('stream_h264_hd_url', 'hd'),
  38. ('stream_h264_hd1080_url', 'hd180'),
  39. ]
  40. _TESTS = [
  41. {
  42. 'url': 'https://www.dailymotion.com/video/x2iuewm_steam-machine-models-pricing-listed-on-steam-store-ign-news_videogames',
  43. 'md5': '2137c41a8e78554bb09225b8eb322406',
  44. 'info_dict': {
  45. 'id': 'x2iuewm',
  46. 'ext': 'mp4',
  47. 'title': 'Steam Machine Models, Pricing Listed on Steam Store - IGN News',
  48. 'description': 'Several come bundled with the Steam Controller.',
  49. 'thumbnail': 're:^https?:.*\.(?:jpg|png)$',
  50. 'duration': 74,
  51. 'timestamp': 1425657362,
  52. 'upload_date': '20150306',
  53. 'uploader': 'IGN',
  54. 'uploader_id': 'xijv66',
  55. 'age_limit': 0,
  56. 'view_count': int,
  57. 'comment_count': int,
  58. }
  59. },
  60. # Vevo video
  61. {
  62. 'url': 'http://www.dailymotion.com/video/x149uew_katy-perry-roar-official_musi',
  63. 'info_dict': {
  64. 'title': 'Roar (Official)',
  65. 'id': 'USUV71301934',
  66. 'ext': 'mp4',
  67. 'uploader': 'Katy Perry',
  68. 'upload_date': '20130905',
  69. },
  70. 'params': {
  71. 'skip_download': True,
  72. },
  73. 'skip': 'VEVO is only available in some countries',
  74. },
  75. # age-restricted video
  76. {
  77. 'url': 'http://www.dailymotion.com/video/xyh2zz_leanna-decker-cyber-girl-of-the-year-desires-nude-playboy-plus_redband',
  78. 'md5': '0d667a7b9cebecc3c89ee93099c4159d',
  79. 'info_dict': {
  80. 'id': 'xyh2zz',
  81. 'ext': 'mp4',
  82. 'title': 'Leanna Decker - Cyber Girl Of The Year Desires Nude [Playboy Plus]',
  83. 'uploader': 'HotWaves1012',
  84. 'age_limit': 18,
  85. }
  86. },
  87. # geo-restricted, player v5
  88. {
  89. 'url': 'http://www.dailymotion.com/video/xhza0o',
  90. 'only_matching': True,
  91. }
  92. ]
  93. def _real_extract(self, url):
  94. video_id = self._match_id(url)
  95. webpage = self._download_webpage_no_ff(
  96. 'https://www.dailymotion.com/video/%s' % video_id, video_id)
  97. age_limit = self._rta_search(webpage)
  98. description = self._og_search_description(webpage) or self._html_search_meta(
  99. 'description', webpage, 'description')
  100. view_count = str_to_int(self._search_regex(
  101. [r'<meta[^>]+itemprop="interactionCount"[^>]+content="UserPlays:(\d+)"',
  102. r'video_views_count[^>]+>\s+([\d\.,]+)'],
  103. webpage, 'view count', fatal=False))
  104. comment_count = int_or_none(self._search_regex(
  105. r'<meta[^>]+itemprop="interactionCount"[^>]+content="UserComments:(\d+)"',
  106. webpage, 'comment count', fatal=False))
  107. player_v5 = self._search_regex(
  108. [r'buildPlayer\(({.+?})\);', r'playerV5\s*=\s*dmp\.create\([^,]+?,\s*({.+?})\);'],
  109. webpage, 'player v5', default=None)
  110. if player_v5:
  111. player = self._parse_json(player_v5, video_id)
  112. metadata = player['metadata']
  113. self._check_error(metadata)
  114. formats = []
  115. for quality, media_list in metadata['qualities'].items():
  116. for media in media_list:
  117. media_url = media.get('url')
  118. if not media_url:
  119. continue
  120. type_ = media.get('type')
  121. if type_ == 'application/vnd.lumberjack.manifest':
  122. continue
  123. ext = determine_ext(media_url)
  124. if type_ == 'application/x-mpegURL' or ext == 'm3u8':
  125. m3u8_formats = self._extract_m3u8_formats(
  126. media_url, video_id, 'mp4', m3u8_id='hls', fatal=False)
  127. if m3u8_formats:
  128. formats.extend(m3u8_formats)
  129. elif type_ == 'application/f4m' or ext == 'f4m':
  130. f4m_formats = self._extract_f4m_formats(
  131. media_url, video_id, preference=-1, f4m_id='hds', fatal=False)
  132. if f4m_formats:
  133. formats.extend(f4m_formats)
  134. else:
  135. f = {
  136. 'url': media_url,
  137. 'format_id': quality,
  138. }
  139. m = re.search(r'H264-(?P<width>\d+)x(?P<height>\d+)', media_url)
  140. if m:
  141. f.update({
  142. 'width': int(m.group('width')),
  143. 'height': int(m.group('height')),
  144. })
  145. formats.append(f)
  146. self._sort_formats(formats)
  147. title = metadata['title']
  148. duration = int_or_none(metadata.get('duration'))
  149. timestamp = int_or_none(metadata.get('created_time'))
  150. thumbnail = metadata.get('poster_url')
  151. uploader = metadata.get('owner', {}).get('screenname')
  152. uploader_id = metadata.get('owner', {}).get('id')
  153. subtitles = {}
  154. for subtitle_lang, subtitle in metadata.get('subtitles', {}).get('data', {}).items():
  155. subtitles[subtitle_lang] = [{
  156. 'ext': determine_ext(subtitle_url),
  157. 'url': subtitle_url,
  158. } for subtitle_url in subtitle.get('urls', [])]
  159. return {
  160. 'id': video_id,
  161. 'title': title,
  162. 'description': description,
  163. 'thumbnail': thumbnail,
  164. 'duration': duration,
  165. 'timestamp': timestamp,
  166. 'uploader': uploader,
  167. 'uploader_id': uploader_id,
  168. 'age_limit': age_limit,
  169. 'view_count': view_count,
  170. 'comment_count': comment_count,
  171. 'formats': formats,
  172. 'subtitles': subtitles,
  173. }
  174. # vevo embed
  175. vevo_id = self._search_regex(
  176. r'<link rel="video_src" href="[^"]*?vevo.com[^"]*?video=(?P<id>[\w]*)',
  177. webpage, 'vevo embed', default=None)
  178. if vevo_id:
  179. return self.url_result('vevo:%s' % vevo_id, 'Vevo')
  180. # fallback old player
  181. embed_page = self._download_webpage_no_ff(
  182. 'https://www.dailymotion.com/embed/video/%s' % video_id,
  183. video_id, 'Downloading embed page')
  184. timestamp = parse_iso8601(self._html_search_meta(
  185. 'video:release_date', webpage, 'upload date'))
  186. info = self._parse_json(
  187. self._search_regex(
  188. r'var info = ({.*?}),$', embed_page,
  189. 'video info', flags=re.MULTILINE),
  190. video_id)
  191. self._check_error(info)
  192. formats = []
  193. for (key, format_id) in self._FORMATS:
  194. video_url = info.get(key)
  195. if video_url is not None:
  196. m_size = re.search(r'H264-(\d+)x(\d+)', video_url)
  197. if m_size is not None:
  198. width, height = map(int_or_none, (m_size.group(1), m_size.group(2)))
  199. else:
  200. width, height = None, None
  201. formats.append({
  202. 'url': video_url,
  203. 'ext': 'mp4',
  204. 'format_id': format_id,
  205. 'width': width,
  206. 'height': height,
  207. })
  208. self._sort_formats(formats)
  209. # subtitles
  210. video_subtitles = self.extract_subtitles(video_id, webpage)
  211. title = self._og_search_title(webpage, default=None)
  212. if title is None:
  213. title = self._html_search_regex(
  214. r'(?s)<span\s+id="video_title"[^>]*>(.*?)</span>', webpage,
  215. 'title')
  216. return {
  217. 'id': video_id,
  218. 'formats': formats,
  219. 'uploader': info['owner.screenname'],
  220. 'timestamp': timestamp,
  221. 'title': title,
  222. 'description': description,
  223. 'subtitles': video_subtitles,
  224. 'thumbnail': info['thumbnail_url'],
  225. 'age_limit': age_limit,
  226. 'view_count': view_count,
  227. 'duration': info['duration']
  228. }
  229. def _check_error(self, info):
  230. if info.get('error') is not None:
  231. raise ExtractorError(
  232. '%s said: %s' % (self.IE_NAME, info['error']['title']), expected=True)
  233. def _get_subtitles(self, video_id, webpage):
  234. try:
  235. sub_list = self._download_webpage(
  236. 'https://api.dailymotion.com/video/%s/subtitles?fields=id,language,url' % video_id,
  237. video_id, note=False)
  238. except ExtractorError as err:
  239. self._downloader.report_warning('unable to download video subtitles: %s' % compat_str(err))
  240. return {}
  241. info = json.loads(sub_list)
  242. if (info['total'] > 0):
  243. sub_lang_list = dict((l['language'], [{'url': l['url'], 'ext': 'srt'}]) for l in info['list'])
  244. return sub_lang_list
  245. self._downloader.report_warning('video doesn\'t have subtitles')
  246. return {}
  247. class DailymotionPlaylistIE(DailymotionBaseInfoExtractor):
  248. IE_NAME = 'dailymotion:playlist'
  249. _VALID_URL = r'(?:https?://)?(?:www\.)?dailymotion\.[a-z]{2,3}/playlist/(?P<id>.+?)/'
  250. _MORE_PAGES_INDICATOR = r'(?s)<div class="pages[^"]*">.*?<a\s+class="[^"]*?icon-arrow_right[^"]*?"'
  251. _PAGE_TEMPLATE = 'https://www.dailymotion.com/playlist/%s/%s'
  252. _TESTS = [{
  253. 'url': 'http://www.dailymotion.com/playlist/xv4bw_nqtv_sport/1#video=xl8v3q',
  254. 'info_dict': {
  255. 'title': 'SPORT',
  256. 'id': 'xv4bw_nqtv_sport',
  257. },
  258. 'playlist_mincount': 20,
  259. }]
  260. def _extract_entries(self, id):
  261. video_ids = set()
  262. processed_urls = set()
  263. for pagenum in itertools.count(1):
  264. page_url = self._PAGE_TEMPLATE % (id, pagenum)
  265. webpage, urlh = self._download_webpage_handle_no_ff(
  266. page_url, id, 'Downloading page %s' % pagenum)
  267. if urlh.geturl() in processed_urls:
  268. self.report_warning('Stopped at duplicated page %s, which is the same as %s' % (
  269. page_url, urlh.geturl()), id)
  270. break
  271. processed_urls.add(urlh.geturl())
  272. for video_id in re.findall(r'data-xid="(.+?)"', webpage):
  273. if video_id not in video_ids:
  274. yield self.url_result('http://www.dailymotion.com/video/%s' % video_id, 'Dailymotion')
  275. video_ids.add(video_id)
  276. if re.search(self._MORE_PAGES_INDICATOR, webpage) is None:
  277. break
  278. def _real_extract(self, url):
  279. mobj = re.match(self._VALID_URL, url)
  280. playlist_id = mobj.group('id')
  281. webpage = self._download_webpage(url, playlist_id)
  282. return {
  283. '_type': 'playlist',
  284. 'id': playlist_id,
  285. 'title': self._og_search_title(webpage),
  286. 'entries': self._extract_entries(playlist_id),
  287. }
  288. class DailymotionUserIE(DailymotionPlaylistIE):
  289. IE_NAME = 'dailymotion:user'
  290. _VALID_URL = r'https?://(?:www\.)?dailymotion\.[a-z]{2,3}/(?!(?:embed|#|video|playlist)/)(?:(?:old/)?user/)?(?P<user>[^/]+)'
  291. _PAGE_TEMPLATE = 'http://www.dailymotion.com/user/%s/%s'
  292. _TESTS = [{
  293. 'url': 'https://www.dailymotion.com/user/nqtv',
  294. 'info_dict': {
  295. 'id': 'nqtv',
  296. 'title': 'Rémi Gaillard',
  297. },
  298. 'playlist_mincount': 100,
  299. }, {
  300. 'url': 'http://www.dailymotion.com/user/UnderProject',
  301. 'info_dict': {
  302. 'id': 'UnderProject',
  303. 'title': 'UnderProject',
  304. },
  305. 'playlist_mincount': 1800,
  306. 'expected_warnings': [
  307. 'Stopped at duplicated page',
  308. ],
  309. 'skip': 'Takes too long time',
  310. }]
  311. def _real_extract(self, url):
  312. mobj = re.match(self._VALID_URL, url)
  313. user = mobj.group('user')
  314. webpage = self._download_webpage(
  315. 'https://www.dailymotion.com/user/%s' % user, user)
  316. full_user = unescapeHTML(self._html_search_regex(
  317. r'<a class="nav-image" title="([^"]+)" href="/%s">' % re.escape(user),
  318. webpage, 'user'))
  319. return {
  320. '_type': 'playlist',
  321. 'id': user,
  322. 'title': full_user,
  323. 'entries': self._extract_entries(user),
  324. }
  325. class DailymotionCloudIE(DailymotionBaseInfoExtractor):
  326. _VALID_URL_PREFIX = r'http://api\.dmcloud\.net/(?:player/)?embed/'
  327. _VALID_URL = r'%s[^/]+/(?P<id>[^/?]+)' % _VALID_URL_PREFIX
  328. _VALID_EMBED_URL = r'%s[^/]+/[^\'"]+' % _VALID_URL_PREFIX
  329. _TESTS = [{
  330. # From http://www.francetvinfo.fr/economie/entreprises/les-entreprises-familiales-le-secret-de-la-reussite_933271.html
  331. # Tested at FranceTvInfo_2
  332. 'url': 'http://api.dmcloud.net/embed/4e7343f894a6f677b10006b4/556e03339473995ee145930c?auth=1464865870-0-jyhsm84b-ead4c701fb750cf9367bf4447167a3db&autoplay=1',
  333. 'only_matching': True,
  334. }, {
  335. # http://www.francetvinfo.fr/societe/larguez-les-amarres-le-cobaturage-se-developpe_980101.html
  336. 'url': 'http://api.dmcloud.net/player/embed/4e7343f894a6f677b10006b4/559545469473996d31429f06?auth=1467430263-0-90tglw2l-a3a4b64ed41efe48d7fccad85b8b8fda&autoplay=1',
  337. 'only_matching': True,
  338. }]
  339. @classmethod
  340. def _extract_dmcloud_url(self, webpage):
  341. mobj = re.search(r'<iframe[^>]+src=[\'"](%s)[\'"]' % self._VALID_EMBED_URL, webpage)
  342. if mobj:
  343. return mobj.group(1)
  344. mobj = re.search(
  345. r'<input[^>]+id=[\'"]dmcloudUrlEmissionSelect[\'"][^>]+value=[\'"](%s)[\'"]' % self._VALID_EMBED_URL,
  346. webpage)
  347. if mobj:
  348. return mobj.group(1)
  349. def _real_extract(self, url):
  350. video_id = self._match_id(url)
  351. webpage = self._download_webpage_no_ff(url, video_id)
  352. title = self._html_search_regex(r'<title>([^>]+)</title>', webpage, 'title')
  353. video_info = self._parse_json(self._search_regex(
  354. r'var\s+info\s*=\s*([^;]+);', webpage, 'video info'), video_id)
  355. # TODO: parse ios_url, which is in fact a manifest
  356. video_url = video_info['mp4_url']
  357. return {
  358. 'id': video_id,
  359. 'url': video_url,
  360. 'title': title,
  361. 'thumbnail': video_info.get('thumbnail_url'),
  362. }