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.

46 lines
1.6 KiB

  1. import re
  2. from .common import InfoExtractor
  3. from ..utils import (
  4. ExtractorError,
  5. )
  6. class TeamcocoIE(InfoExtractor):
  7. _VALID_URL = r'http://teamcoco\.com/video/(?P<url_title>.*)'
  8. _TEST = {
  9. u'url': u'http://teamcoco.com/video/louis-ck-interview-george-w-bush',
  10. u'file': u'19705.mp4',
  11. u'md5': u'27b6f7527da5acf534b15f21b032656e',
  12. u'info_dict': {
  13. u"description": u"Louis C.K. got starstruck by George W. Bush, so what? Part one.",
  14. u"title": u"Louis C.K. Interview Pt. 1 11/3/11"
  15. }
  16. }
  17. def _real_extract(self, url):
  18. mobj = re.match(self._VALID_URL, url)
  19. if mobj is None:
  20. raise ExtractorError(u'Invalid URL: %s' % url)
  21. url_title = mobj.group('url_title')
  22. webpage = self._download_webpage(url, url_title)
  23. video_id = self._html_search_regex(r'<article class="video" data-id="(\d+?)"',
  24. webpage, u'video id')
  25. self.report_extraction(video_id)
  26. data_url = 'http://teamcoco.com/cvp/2.0/%s.xml' % video_id
  27. data = self._download_webpage(data_url, video_id, 'Downloading data webpage')
  28. video_url = self._html_search_regex(r'<file [^>]*type="high".*?>(.*?)</file>',
  29. data, u'video URL')
  30. return [{
  31. 'id': video_id,
  32. 'url': video_url,
  33. 'ext': 'mp4',
  34. 'title': self._og_search_title(webpage),
  35. 'thumbnail': self._og_search_thumbnail(webpage),
  36. 'description': self._og_search_description(webpage),
  37. }]