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.

55 lines
1.9 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. video_title = self._html_search_regex(r'<meta property="og:title" content="(.+?)"',
  27. webpage, u'title')
  28. thumbnail = self._html_search_regex(r'<meta property="og:image" content="(.+?)"',
  29. webpage, u'thumbnail', fatal=False)
  30. video_description = self._html_search_regex(r'<meta property="og:description" content="(.*?)"',
  31. webpage, u'description', fatal=False)
  32. data_url = 'http://teamcoco.com/cvp/2.0/%s.xml' % video_id
  33. data = self._download_webpage(data_url, video_id, 'Downloading data webpage')
  34. video_url = self._html_search_regex(r'<file type="high".*?>(.*?)</file>',
  35. data, u'video URL')
  36. return [{
  37. 'id': video_id,
  38. 'url': video_url,
  39. 'ext': 'mp4',
  40. 'title': video_title,
  41. 'thumbnail': thumbnail,
  42. 'description': video_description,
  43. }]