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.

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