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.

37 lines
1.2 KiB

  1. import re
  2. from .common import InfoExtractor
  3. class KickStarterIE(InfoExtractor):
  4. _VALID_URL = r'https?://www\.kickstarter\.com/projects/(?P<id>\d*)/.*'
  5. _TEST = {
  6. u"url": u"https://www.kickstarter.com/projects/1404461844/intersection-the-story-of-josh-grant?ref=home_location",
  7. u"file": u"1404461844.mp4",
  8. u"md5": u"c81addca81327ffa66c642b5d8b08cab",
  9. u"info_dict": {
  10. u"title": u"Intersection: The Story of Josh Grant by Kyle Cowling",
  11. },
  12. }
  13. def _real_extract(self, url):
  14. m = re.match(self._VALID_URL, url)
  15. video_id = m.group('id')
  16. webpage_src = self._download_webpage(url, video_id)
  17. video_url = self._search_regex(r'data-video="(.*?)">',
  18. webpage_src, u'video URL')
  19. if 'mp4' in video_url:
  20. ext = 'mp4'
  21. else:
  22. ext = 'flv'
  23. video_title = self._html_search_regex(r"<title>(.*?)</title>",
  24. webpage_src, u'title').rpartition(u'\u2014 Kickstarter')[0].strip()
  25. results = [{
  26. 'id': video_id,
  27. 'url': video_url,
  28. 'title': video_title,
  29. 'ext': ext,
  30. }]
  31. return results