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.

62 lines
2.2 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. _TESTS = [{
  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. '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. 'playlist': [
  21. {
  22. 'info_dict': {
  23. 'id': '78704821',
  24. 'ext': 'mp4',
  25. 'uploader_id': 'pebble',
  26. 'uploader': 'Pebble Technology',
  27. 'title': 'Pebble iOS Notifications',
  28. }
  29. }
  30. ],
  31. }]
  32. def _real_extract(self, url):
  33. m = re.match(self._VALID_URL, url)
  34. video_id = m.group('id')
  35. webpage = self._download_webpage(url, video_id)
  36. title = self._html_search_regex(
  37. r'<title>\s*(.*?)(?:\s*&mdash; Kickstarter)?\s*</title>',
  38. webpage, 'title')
  39. video_url = self._search_regex(
  40. r'data-video-url="(.*?)"',
  41. webpage, 'video URL', default=None)
  42. if video_url is None: # No native kickstarter, look for embedded videos
  43. return {
  44. '_type': 'url_transparent',
  45. 'ie_key': 'Generic',
  46. 'url': url,
  47. 'title': title,
  48. }
  49. return {
  50. 'id': video_id,
  51. 'url': video_url,
  52. 'title': title,
  53. 'description': self._og_search_description(webpage),
  54. 'thumbnail': self._og_search_thumbnail(webpage),
  55. }