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.3 KiB

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