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.5 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. def _real_extract(self, url):
  9. mobj = re.match(self._VALID_URL, url)
  10. if mobj is None:
  11. raise ExtractorError(u'Invalid URL: %s' % url)
  12. url_title = mobj.group('url_title')
  13. webpage = self._download_webpage(url, url_title)
  14. video_id = self._html_search_regex(r'<article class="video" data-id="(\d+?)"',
  15. webpage, u'video id')
  16. self.report_extraction(video_id)
  17. video_title = self._html_search_regex(r'<meta property="og:title" content="(.+?)"',
  18. webpage, u'title')
  19. thumbnail = self._html_search_regex(r'<meta property="og:image" content="(.+?)"',
  20. webpage, u'thumbnail', fatal=False)
  21. video_description = self._html_search_regex(r'<meta property="og:description" content="(.*?)"',
  22. webpage, u'description', fatal=False)
  23. data_url = 'http://teamcoco.com/cvp/2.0/%s.xml' % video_id
  24. data = self._download_webpage(data_url, video_id, 'Downloading data webpage')
  25. video_url = self._html_search_regex(r'<file type="high".*?>(.*?)</file>',
  26. data, u'video URL')
  27. return [{
  28. 'id': video_id,
  29. 'url': video_url,
  30. 'ext': 'mp4',
  31. 'title': video_title,
  32. 'thumbnail': thumbnail,
  33. 'description': video_description,
  34. }]