kickstarter.py 2.6 KB

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