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.

439 lines
17 KiB

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
10 years ago
10 years ago
  1. from __future__ import unicode_literals
  2. import re
  3. from .common import InfoExtractor
  4. from ..compat import (
  5. compat_str,
  6. compat_xpath,
  7. )
  8. from ..utils import (
  9. ExtractorError,
  10. find_xpath_attr,
  11. fix_xml_ampersands,
  12. float_or_none,
  13. HEADRequest,
  14. RegexNotFoundError,
  15. sanitized_Request,
  16. strip_or_none,
  17. timeconvert,
  18. try_get,
  19. unescapeHTML,
  20. update_url_query,
  21. url_basename,
  22. xpath_text,
  23. )
  24. def _media_xml_tag(tag):
  25. return '{http://search.yahoo.com/mrss/}%s' % tag
  26. class MTVServicesInfoExtractor(InfoExtractor):
  27. _MOBILE_TEMPLATE = None
  28. _LANG = None
  29. @staticmethod
  30. def _id_from_uri(uri):
  31. return uri.split(':')[-1]
  32. @staticmethod
  33. def _remove_template_parameter(url):
  34. # Remove the templates, like &device={device}
  35. return re.sub(r'&[^=]*?={.*?}(?=(&|$))', '', url)
  36. def _get_feed_url(self, uri):
  37. return self._FEED_URL
  38. def _get_thumbnail_url(self, uri, itemdoc):
  39. search_path = '%s/%s' % (_media_xml_tag('group'), _media_xml_tag('thumbnail'))
  40. thumb_node = itemdoc.find(search_path)
  41. if thumb_node is None:
  42. return None
  43. else:
  44. return thumb_node.attrib['url']
  45. def _extract_mobile_video_formats(self, mtvn_id):
  46. webpage_url = self._MOBILE_TEMPLATE % mtvn_id
  47. req = sanitized_Request(webpage_url)
  48. # Otherwise we get a webpage that would execute some javascript
  49. req.add_header('User-Agent', 'curl/7')
  50. webpage = self._download_webpage(req, mtvn_id,
  51. 'Downloading mobile page')
  52. metrics_url = unescapeHTML(self._search_regex(r'<a href="(http://metrics.+?)"', webpage, 'url'))
  53. req = HEADRequest(metrics_url)
  54. response = self._request_webpage(req, mtvn_id, 'Resolving url')
  55. url = response.geturl()
  56. # Transform the url to get the best quality:
  57. url = re.sub(r'.+pxE=mp4', 'http://mtvnmobile.vo.llnwd.net/kip0/_pxn=0+_pxK=18639+_pxE=mp4', url, 1)
  58. return [{'url': url, 'ext': 'mp4'}]
  59. def _extract_video_formats(self, mdoc, mtvn_id, video_id):
  60. if re.match(r'.*/(error_country_block\.swf|geoblock\.mp4|copyright_error\.flv(?:\?geo\b.+?)?)$', mdoc.find('.//src').text) is not None:
  61. if mtvn_id is not None and self._MOBILE_TEMPLATE is not None:
  62. self.to_screen('The normal version is not available from your '
  63. 'country, trying with the mobile version')
  64. return self._extract_mobile_video_formats(mtvn_id)
  65. raise ExtractorError('This video is not available from your country.',
  66. expected=True)
  67. formats = []
  68. for rendition in mdoc.findall('.//rendition'):
  69. if rendition.get('method') == 'hls':
  70. hls_url = rendition.find('./src').text
  71. formats.extend(self._extract_m3u8_formats(
  72. hls_url, video_id, ext='mp4', entry_protocol='m3u8_native',
  73. m3u8_id='hls'))
  74. else:
  75. # fms
  76. try:
  77. _, _, ext = rendition.attrib['type'].partition('/')
  78. rtmp_video_url = rendition.find('./src').text
  79. if 'error_not_available.swf' in rtmp_video_url:
  80. raise ExtractorError(
  81. '%s said: video is not available' % self.IE_NAME,
  82. expected=True)
  83. if rtmp_video_url.endswith('siteunavail.png'):
  84. continue
  85. formats.extend([{
  86. 'ext': 'flv' if rtmp_video_url.startswith('rtmp') else ext,
  87. 'url': rtmp_video_url,
  88. 'format_id': '-'.join(filter(None, [
  89. 'rtmp' if rtmp_video_url.startswith('rtmp') else None,
  90. rendition.get('bitrate')])),
  91. 'width': int(rendition.get('width')),
  92. 'height': int(rendition.get('height')),
  93. }])
  94. except (KeyError, TypeError):
  95. raise ExtractorError('Invalid rendition field.')
  96. self._sort_formats(formats)
  97. return formats
  98. def _extract_subtitles(self, mdoc, mtvn_id):
  99. subtitles = {}
  100. for transcript in mdoc.findall('.//transcript'):
  101. if transcript.get('kind') != 'captions':
  102. continue
  103. lang = transcript.get('srclang')
  104. subtitles[lang] = [{
  105. 'url': compat_str(typographic.get('src')),
  106. 'ext': typographic.get('format')
  107. } for typographic in transcript.findall('./typographic')]
  108. return subtitles
  109. def _get_video_info(self, itemdoc, use_hls=True):
  110. uri = itemdoc.find('guid').text
  111. video_id = self._id_from_uri(uri)
  112. self.report_extraction(video_id)
  113. content_el = itemdoc.find('%s/%s' % (_media_xml_tag('group'), _media_xml_tag('content')))
  114. mediagen_url = self._remove_template_parameter(content_el.attrib['url'])
  115. mediagen_url = mediagen_url.replace('device={device}', '')
  116. if 'acceptMethods' not in mediagen_url:
  117. mediagen_url += '&' if '?' in mediagen_url else '?'
  118. mediagen_url += 'acceptMethods='
  119. mediagen_url += 'hls' if use_hls else 'fms'
  120. mediagen_doc = self._download_xml(mediagen_url, video_id,
  121. 'Downloading video urls')
  122. item = mediagen_doc.find('./video/item')
  123. if item is not None and item.get('type') == 'text':
  124. message = '%s returned error: ' % self.IE_NAME
  125. if item.get('code') is not None:
  126. message += '%s - ' % item.get('code')
  127. message += item.text
  128. raise ExtractorError(message, expected=True)
  129. description = strip_or_none(xpath_text(itemdoc, 'description'))
  130. timestamp = timeconvert(xpath_text(itemdoc, 'pubDate'))
  131. title_el = None
  132. if title_el is None:
  133. title_el = find_xpath_attr(
  134. itemdoc, './/{http://search.yahoo.com/mrss/}category',
  135. 'scheme', 'urn:mtvn:video_title')
  136. if title_el is None:
  137. title_el = itemdoc.find(compat_xpath('.//{http://search.yahoo.com/mrss/}title'))
  138. if title_el is None:
  139. title_el = itemdoc.find(compat_xpath('.//title'))
  140. if title_el.text is None:
  141. title_el = None
  142. title = title_el.text
  143. if title is None:
  144. raise ExtractorError('Could not find video title')
  145. title = title.strip()
  146. # This a short id that's used in the webpage urls
  147. mtvn_id = None
  148. mtvn_id_node = find_xpath_attr(itemdoc, './/{http://search.yahoo.com/mrss/}category',
  149. 'scheme', 'urn:mtvn:id')
  150. if mtvn_id_node is not None:
  151. mtvn_id = mtvn_id_node.text
  152. formats = self._extract_video_formats(mediagen_doc, mtvn_id, video_id)
  153. return {
  154. 'title': title,
  155. 'formats': formats,
  156. 'subtitles': self._extract_subtitles(mediagen_doc, mtvn_id),
  157. 'id': video_id,
  158. 'thumbnail': self._get_thumbnail_url(uri, itemdoc),
  159. 'description': description,
  160. 'duration': float_or_none(content_el.attrib.get('duration')),
  161. 'timestamp': timestamp,
  162. }
  163. def _get_feed_query(self, uri):
  164. data = {'uri': uri}
  165. if self._LANG:
  166. data['lang'] = self._LANG
  167. return data
  168. def _get_videos_info(self, uri, use_hls=True):
  169. video_id = self._id_from_uri(uri)
  170. feed_url = self._get_feed_url(uri)
  171. info_url = update_url_query(feed_url, self._get_feed_query(uri))
  172. return self._get_videos_info_from_url(info_url, video_id, use_hls)
  173. def _get_videos_info_from_url(self, url, video_id, use_hls=True):
  174. idoc = self._download_xml(
  175. url, video_id,
  176. 'Downloading info', transform_source=fix_xml_ampersands)
  177. title = xpath_text(idoc, './channel/title')
  178. description = xpath_text(idoc, './channel/description')
  179. return self.playlist_result(
  180. [self._get_video_info(item, use_hls) for item in idoc.findall('.//item')],
  181. playlist_title=title, playlist_description=description)
  182. def _extract_triforce_mgid(self, webpage, data_zone=None, video_id=None):
  183. triforce_feed = self._parse_json(self._search_regex(
  184. r'triforceManifestFeed\s*=\s*({.+?})\s*;\s*\n', webpage,
  185. 'triforce feed', default='{}'), video_id, fatal=False)
  186. data_zone = self._search_regex(
  187. r'data-zone=(["\'])(?P<zone>.+?_lc_promo.*?)\1', webpage,
  188. 'data zone', default=data_zone, group='zone')
  189. feed_url = try_get(
  190. triforce_feed, lambda x: x['manifest']['zones'][data_zone]['feed'],
  191. compat_str)
  192. if not feed_url:
  193. return
  194. feed = self._download_json(feed_url, video_id, fatal=False)
  195. if not feed:
  196. return
  197. return try_get(feed, lambda x: x['result']['data']['id'], compat_str)
  198. def _extract_mgid(self, webpage):
  199. try:
  200. # the url can be http://media.mtvnservices.com/fb/{mgid}.swf
  201. # or http://media.mtvnservices.com/{mgid}
  202. og_url = self._og_search_video_url(webpage)
  203. mgid = url_basename(og_url)
  204. if mgid.endswith('.swf'):
  205. mgid = mgid[:-4]
  206. except RegexNotFoundError:
  207. mgid = None
  208. if mgid is None or ':' not in mgid:
  209. mgid = self._search_regex(
  210. [r'data-mgid="(.*?)"', r'swfobject.embedSWF\(".*?(mgid:.*?)"'],
  211. webpage, 'mgid', default=None)
  212. if not mgid:
  213. sm4_embed = self._html_search_meta(
  214. 'sm4:video:embed', webpage, 'sm4 embed', default='')
  215. mgid = self._search_regex(
  216. r'embed/(mgid:.+?)["\'&?/]', sm4_embed, 'mgid', default=None)
  217. if not mgid:
  218. mgid = self._extract_triforce_mgid(webpage)
  219. return mgid
  220. def _real_extract(self, url):
  221. title = url_basename(url)
  222. webpage = self._download_webpage(url, title)
  223. mgid = self._extract_mgid(webpage)
  224. videos_info = self._get_videos_info(mgid)
  225. return videos_info
  226. class MTVServicesEmbeddedIE(MTVServicesInfoExtractor):
  227. IE_NAME = 'mtvservices:embedded'
  228. _VALID_URL = r'https?://media\.mtvnservices\.com/embed/(?P<mgid>.+?)(\?|/|$)'
  229. _TEST = {
  230. # From http://www.thewrap.com/peter-dinklage-sums-up-game-of-thrones-in-45-seconds-video/
  231. 'url': 'http://media.mtvnservices.com/embed/mgid:uma:video:mtv.com:1043906/cp~vid%3D1043906%26uri%3Dmgid%3Auma%3Avideo%3Amtv.com%3A1043906',
  232. 'md5': 'cb349b21a7897164cede95bd7bf3fbb9',
  233. 'info_dict': {
  234. 'id': '1043906',
  235. 'ext': 'mp4',
  236. 'title': 'Peter Dinklage Sums Up \'Game Of Thrones\' In 45 Seconds',
  237. 'description': '"Sexy sexy sexy, stabby stabby stabby, beautiful language," says Peter Dinklage as he tries summarizing "Game of Thrones" in under a minute.',
  238. 'timestamp': 1400126400,
  239. 'upload_date': '20140515',
  240. },
  241. }
  242. @staticmethod
  243. def _extract_url(webpage):
  244. mobj = re.search(
  245. r'<iframe[^>]+?src=(["\'])(?P<url>(?:https?:)?//media.mtvnservices.com/embed/.+?)\1', webpage)
  246. if mobj:
  247. return mobj.group('url')
  248. def _get_feed_url(self, uri):
  249. video_id = self._id_from_uri(uri)
  250. config = self._download_json(
  251. 'http://media.mtvnservices.com/pmt/e1/access/index.html?uri=%s&configtype=edge' % uri, video_id)
  252. return self._remove_template_parameter(config['feedWithQueryParams'])
  253. def _real_extract(self, url):
  254. mobj = re.match(self._VALID_URL, url)
  255. mgid = mobj.group('mgid')
  256. return self._get_videos_info(mgid)
  257. class MTVIE(MTVServicesInfoExtractor):
  258. IE_NAME = 'mtv'
  259. _VALID_URL = r'https?://(?:www\.)?mtv\.com/(?:video-clips|(?:full-)?episodes)/(?P<id>[^/?#.]+)'
  260. _FEED_URL = 'http://www.mtv.com/feeds/mrss/'
  261. _TESTS = [{
  262. 'url': 'http://www.mtv.com/video-clips/vl8qof/unlocking-the-truth-trailer',
  263. 'md5': '1edbcdf1e7628e414a8c5dcebca3d32b',
  264. 'info_dict': {
  265. 'id': '5e14040d-18a4-47c4-a582-43ff602de88e',
  266. 'ext': 'mp4',
  267. 'title': 'Unlocking The Truth|July 18, 2016|1|101|Trailer',
  268. 'description': '"Unlocking the Truth" premieres August 17th at 11/10c.',
  269. 'timestamp': 1468846800,
  270. 'upload_date': '20160718',
  271. },
  272. }, {
  273. 'url': 'http://www.mtv.com/full-episodes/94tujl/unlocking-the-truth-gates-of-hell-season-1-ep-101',
  274. 'only_matching': True,
  275. }, {
  276. 'url': 'http://www.mtv.com/episodes/g8xu7q/teen-mom-2-breaking-the-wall-season-7-ep-713',
  277. 'only_matching': True,
  278. }]
  279. class MTVVideoIE(MTVServicesInfoExtractor):
  280. IE_NAME = 'mtv:video'
  281. _VALID_URL = r'''(?x)^https?://
  282. (?:(?:www\.)?mtv\.com/videos/.+?/(?P<videoid>[0-9]+)/[^/]+$|
  283. m\.mtv\.com/videos/video\.rbml\?.*?id=(?P<mgid>[^&]+))'''
  284. _FEED_URL = 'http://www.mtv.com/player/embed/AS3/rss/'
  285. _TESTS = [
  286. {
  287. 'url': 'http://www.mtv.com/videos/misc/853555/ours-vh1-storytellers.jhtml',
  288. 'md5': '850f3f143316b1e71fa56a4edfd6e0f8',
  289. 'info_dict': {
  290. 'id': '853555',
  291. 'ext': 'mp4',
  292. 'title': 'Taylor Swift - "Ours (VH1 Storytellers)"',
  293. 'description': 'Album: Taylor Swift performs "Ours" for VH1 Storytellers at Harvey Mudd College.',
  294. 'timestamp': 1352610000,
  295. 'upload_date': '20121111',
  296. },
  297. },
  298. ]
  299. def _get_thumbnail_url(self, uri, itemdoc):
  300. return 'http://mtv.mtvnimages.com/uri/' + uri
  301. def _real_extract(self, url):
  302. mobj = re.match(self._VALID_URL, url)
  303. video_id = mobj.group('videoid')
  304. uri = mobj.groupdict().get('mgid')
  305. if uri is None:
  306. webpage = self._download_webpage(url, video_id)
  307. # Some videos come from Vevo.com
  308. m_vevo = re.search(
  309. r'(?s)isVevoVideo = true;.*?vevoVideoId = "(.*?)";', webpage)
  310. if m_vevo:
  311. vevo_id = m_vevo.group(1)
  312. self.to_screen('Vevo video detected: %s' % vevo_id)
  313. return self.url_result('vevo:%s' % vevo_id, ie='Vevo')
  314. uri = self._html_search_regex(r'/uri/(.*?)\?', webpage, 'uri')
  315. return self._get_videos_info(uri)
  316. class MTVDEIE(MTVServicesInfoExtractor):
  317. IE_NAME = 'mtv.de'
  318. _VALID_URL = r'https?://(?:www\.)?mtv\.de/(?:artists|shows|news)/(?:[^/]+/)*(?P<id>\d+)-[^/#?]+/*(?:[#?].*)?$'
  319. _TESTS = [{
  320. 'url': 'http://www.mtv.de/artists/10571-cro/videos/61131-traum',
  321. 'info_dict': {
  322. 'id': 'music_video-a50bc5f0b3aa4b3190aa',
  323. 'ext': 'flv',
  324. 'title': 'MusicVideo_cro-traum',
  325. 'description': 'Cro - Traum',
  326. },
  327. 'params': {
  328. # rtmp download
  329. 'skip_download': True,
  330. },
  331. 'skip': 'Blocked at Travis CI',
  332. }, {
  333. # mediagen URL without query (e.g. http://videos.mtvnn.com/mediagen/e865da714c166d18d6f80893195fcb97)
  334. 'url': 'http://www.mtv.de/shows/933-teen-mom-2/staffeln/5353/folgen/63565-enthullungen',
  335. 'info_dict': {
  336. 'id': 'local_playlist-f5ae778b9832cc837189',
  337. 'ext': 'flv',
  338. 'title': 'Episode_teen-mom-2_shows_season-5_episode-1_full-episode_part1',
  339. },
  340. 'params': {
  341. # rtmp download
  342. 'skip_download': True,
  343. },
  344. 'skip': 'Blocked at Travis CI',
  345. }, {
  346. 'url': 'http://www.mtv.de/news/77491-mtv-movies-spotlight-pixels-teil-3',
  347. 'info_dict': {
  348. 'id': 'local_playlist-4e760566473c4c8c5344',
  349. 'ext': 'mp4',
  350. 'title': 'Article_mtv-movies-spotlight-pixels-teil-3_short-clips_part1',
  351. 'description': 'MTV Movies Supercut',
  352. },
  353. 'params': {
  354. # rtmp download
  355. 'skip_download': True,
  356. },
  357. 'skip': 'Das Video kann zur Zeit nicht abgespielt werden.',
  358. }]
  359. def _real_extract(self, url):
  360. video_id = self._match_id(url)
  361. webpage = self._download_webpage(url, video_id)
  362. playlist = self._parse_json(
  363. self._search_regex(
  364. r'window\.pagePlaylist\s*=\s*(\[.+?\]);\n', webpage, 'page playlist'),
  365. video_id)
  366. def _mrss_url(item):
  367. return item['mrss'] + item.get('mrssvars', '')
  368. # news pages contain single video in playlist with different id
  369. if len(playlist) == 1:
  370. return self._get_videos_info_from_url(_mrss_url(playlist[0]), video_id)
  371. for item in playlist:
  372. item_id = item.get('id')
  373. if item_id and compat_str(item_id) == video_id:
  374. return self._get_videos_info_from_url(_mrss_url(item), video_id)