logo

youtube-dl

[mirror] Download/Watch videos from video hostersgit clone https://hacktivis.me/git/mirror/youtube-dl.git

kickstarter.py (2708B)


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