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.

70 lines
2.6 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. '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. 'expected_warnings': ['OpenGraph description'],
  36. }]
  37. def _real_extract(self, url):
  38. video_id = self._match_id(url)
  39. webpage = self._download_webpage(url, video_id)
  40. title = self._html_search_regex(
  41. r'<title>\s*(.*?)(?:\s*&mdash; Kickstarter)?\s*</title>',
  42. webpage, 'title')
  43. video_url = self._search_regex(
  44. r'data-video-url="(.*?)"',
  45. webpage, 'video URL', default=None)
  46. if video_url is None: # No native kickstarter, look for embedded videos
  47. return {
  48. '_type': 'url_transparent',
  49. 'ie_key': 'Generic',
  50. 'url': url,
  51. 'title': title,
  52. }
  53. thumbnail = self._og_search_thumbnail(webpage, default=None)
  54. if thumbnail is None:
  55. thumbnail = self._html_search_regex(
  56. r'<img[^>]+class="[^"]+\s*poster\s*[^"]+"[^>]+src="([^"]+)"',
  57. webpage, 'thumbnail image', fatal=False)
  58. return {
  59. 'id': video_id,
  60. 'url': video_url,
  61. 'title': title,
  62. 'description': self._og_search_description(webpage),
  63. 'thumbnail': thumbnail,
  64. }