kickstarter.py 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. import re
  2. from .common import InfoExtractor
  3. class KickStarterIE(InfoExtractor):
  4. _VALID_URL = r'https?://www\.kickstarter\.com/projects/(?P<id>.*)/.*\?'
  5. _TEST = {
  6. "url": "https://www.kickstarter.com/projects/1404461844/intersection-the-story-of-josh-grant?ref=home_location",
  7. "file": "1404461844.mp4",
  8. "md5": "c81addca81327ffa66c642b5d8b08cab",
  9. "info_dict": {
  10. "title": u"Intersection: The Story of Josh Grant by Kyle Cowling \u2014 Kickstarter"
  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')
  25. results = [{
  26. 'id': video_id,
  27. 'url' : video_url,
  28. 'title' : video_title,
  29. 'ext' : ext,
  30. }]
  31. return results