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.

39 lines
1.4 KiB

  1. # encoding: utf-8
  2. from __future__ import unicode_literals
  3. import re
  4. from .common import InfoExtractor
  5. class KickStarterIE(InfoExtractor):
  6. _VALID_URL = r'https?://www\.kickstarter\.com/projects/(?P<id>[^/]*)/.*'
  7. _TEST = {
  8. 'url': 'https://www.kickstarter.com/projects/1404461844/intersection-the-story-of-josh-grant?ref=home_location',
  9. 'md5': 'c81addca81327ffa66c642b5d8b08cab',
  10. 'info_dict': {
  11. 'id': '1404461844',
  12. 'ext': 'mp4',
  13. 'title': 'Intersection: The Story of Josh Grant by Kyle Cowling',
  14. 'description': 'A unique motocross documentary that examines the '
  15. 'life and mind of one of sports most elite athletes: Josh Grant.',
  16. },
  17. }
  18. def _real_extract(self, url):
  19. m = re.match(self._VALID_URL, url)
  20. video_id = m.group('id')
  21. webpage = self._download_webpage(url, video_id)
  22. video_url = self._search_regex(r'data-video-url="(.*?)"',
  23. webpage, 'video URL')
  24. video_title = self._html_search_regex(r'<title>(.*?)</title>',
  25. webpage, 'title').rpartition('— Kickstarter')[0].strip()
  26. return {
  27. 'id': video_id,
  28. 'url': video_url,
  29. 'title': video_title,
  30. 'description': self._og_search_description(webpage),
  31. 'thumbnail': self._og_search_thumbnail(webpage),
  32. }