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.

57 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': (
  14. 'A unique motocross documentary that examines the '
  15. 'life and mind of one of sports most elite athletes: Josh Grant.'
  16. ),
  17. },
  18. }, {
  19. 'note': 'Embedded video (not using the native kickstarter video service)',
  20. 'url': 'https://www.kickstarter.com/projects/597507018/pebble-e-paper-watch-for-iphone-and-android/posts/659178',
  21. 'info_dict': {
  22. 'id': '78704821',
  23. 'ext': 'mp4',
  24. 'uploader_id': 'pebble',
  25. 'uploader': 'Pebble Technology',
  26. 'title': 'Pebble iOS Notifications',
  27. }
  28. }]
  29. def _real_extract(self, url):
  30. video_id = self._match_id(url)
  31. webpage = self._download_webpage(url, video_id)
  32. title = self._html_search_regex(
  33. r'<title>\s*(.*?)(?:\s*&mdash; Kickstarter)?\s*</title>',
  34. webpage, 'title')
  35. video_url = self._search_regex(
  36. r'data-video-url="(.*?)"',
  37. webpage, 'video URL', default=None)
  38. if video_url is None: # No native kickstarter, look for embedded videos
  39. return {
  40. '_type': 'url_transparent',
  41. 'ie_key': 'Generic',
  42. 'url': url,
  43. 'title': title,
  44. }
  45. return {
  46. 'id': video_id,
  47. 'url': video_url,
  48. 'title': title,
  49. 'description': self._og_search_description(webpage),
  50. 'thumbnail': self._og_search_thumbnail(webpage),
  51. }