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
2.0 KiB

  1. # encoding: utf-8
  2. from __future__ import unicode_literals
  3. from .common import InfoExtractor
  4. class KickStarterIE(InfoExtractor):
  5. _VALID_URL = r'https?://www\.kickstarter\.com/projects/(?P<id>[^/]*)/.*'
  6. _TESTS = [{
  7. 'url': 'https://www.kickstarter.com/projects/1404461844/intersection-the-story-of-josh-grant?ref=home_location',
  8. 'md5': 'c81addca81327ffa66c642b5d8b08cab',
  9. 'info_dict': {
  10. 'id': '1404461844',
  11. 'ext': 'mp4',
  12. 'title': 'Intersection: The Story of Josh Grant by Kyle Cowling',
  13. 'description': 'A unique motocross documentary that examines the '
  14. 'life and mind of one of sports most elite athletes: Josh Grant.',
  15. },
  16. }, {
  17. 'note': 'Embedded video (not using the native kickstarter video service)',
  18. 'url': 'https://www.kickstarter.com/projects/597507018/pebble-e-paper-watch-for-iphone-and-android/posts/659178',
  19. 'info_dict': {
  20. 'id': '78704821',
  21. 'ext': 'mp4',
  22. 'uploader_id': 'pebble',
  23. 'uploader': 'Pebble Technology',
  24. 'title': 'Pebble iOS Notifications',
  25. }
  26. }]
  27. def _real_extract(self, url):
  28. video_id = self._match_id(url)
  29. webpage = self._download_webpage(url, video_id)
  30. title = self._html_search_regex(
  31. r'<title>\s*(.*?)(?:\s*&mdash; Kickstarter)?\s*</title>',
  32. webpage, 'title')
  33. video_url = self._search_regex(
  34. r'data-video-url="(.*?)"',
  35. webpage, 'video URL', default=None)
  36. if video_url is None: # No native kickstarter, look for embedded videos
  37. return {
  38. '_type': 'url_transparent',
  39. 'ie_key': 'Generic',
  40. 'url': url,
  41. 'title': title,
  42. }
  43. return {
  44. 'id': video_id,
  45. 'url': video_url,
  46. 'title': title,
  47. 'description': self._og_search_description(webpage),
  48. 'thumbnail': self._og_search_thumbnail(webpage),
  49. }