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.

38 lines
1.2 KiB

  1. from __future__ import unicode_literals
  2. import re
  3. from .common import InfoExtractor
  4. from .ooyala import OoyalaIE
  5. from ..utils import ExtractorError
  6. class ViceIE(InfoExtractor):
  7. _VALID_URL = r'http://www\.vice\.com/.*?/(?P<name>.+)'
  8. _TEST = {
  9. 'url': 'http://www.vice.com/Fringes/cowboy-capitalists-part-1',
  10. 'info_dict': {
  11. 'id': '43cW1mYzpia9IlestBjVpd23Yu3afAfp',
  12. 'ext': 'mp4',
  13. 'title': 'VICE_COWBOYCAPITALISTS_PART01_v1_VICE_WM_1080p.mov',
  14. },
  15. 'params': {
  16. # Requires ffmpeg (m3u8 manifest)
  17. 'skip_download': True,
  18. },
  19. }
  20. def _real_extract(self, url):
  21. mobj = re.match(self._VALID_URL, url)
  22. name = mobj.group('name')
  23. webpage = self._download_webpage(url, name)
  24. try:
  25. embed_code = self._search_regex(
  26. r'embedCode=([^&\'"]+)', webpage,
  27. 'ooyala embed code')
  28. ooyala_url = OoyalaIE._url_for_embed_code(embed_code)
  29. print(ooyala_url)
  30. except ExtractorError:
  31. raise ExtractorError('The page doesn\'t contain a video', expected=True)
  32. return self.url_result(ooyala_url, ie='Ooyala')