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.

41 lines
1.4 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'https?://(?:.+?\.)?vice\.com/.*?/(?P<name>.+)'
  8. _TESTS = [
  9. {
  10. 'url': 'http://www.vice.com/Fringes/cowboy-capitalists-part-1',
  11. 'info_dict': {
  12. 'id': '43cW1mYzpia9IlestBjVpd23Yu3afAfp',
  13. 'ext': 'mp4',
  14. 'title': 'VICE_COWBOYCAPITALISTS_PART01_v1_VICE_WM_1080p.mov',
  15. },
  16. 'params': {
  17. # Requires ffmpeg (m3u8 manifest)
  18. 'skip_download': True,
  19. },
  20. }, {
  21. 'url': 'https://news.vice.com/video/experimenting-on-animals-inside-the-monkey-lab',
  22. 'only_matching': True,
  23. }
  24. ]
  25. def _real_extract(self, url):
  26. mobj = re.match(self._VALID_URL, url)
  27. name = mobj.group('name')
  28. webpage = self._download_webpage(url, name)
  29. try:
  30. embed_code = self._search_regex(
  31. r'embedCode=([^&\'"]+)', webpage,
  32. 'ooyala embed code')
  33. ooyala_url = OoyalaIE._url_for_embed_code(embed_code)
  34. except ExtractorError:
  35. raise ExtractorError('The page doesn\'t contain a video', expected=True)
  36. return self.url_result(ooyala_url, ie='Ooyala')