]> Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/kickstarter.py
Prepare for upload.
[youtubedl] / youtube_dl / extractor / kickstarter.py
1 # encoding: utf-8
2 from __future__ import unicode_literals
3
4 from .common import InfoExtractor
5
6
7 class KickStarterIE(InfoExtractor):
8 _VALID_URL = r'https?://www\.kickstarter\.com/projects/(?P<id>[^/]*)/.*'
9 _TESTS = [{
10 'url': 'https://www.kickstarter.com/projects/1404461844/intersection-the-story-of-josh-grant?ref=home_location',
11 'md5': 'c81addca81327ffa66c642b5d8b08cab',
12 'info_dict': {
13 'id': '1404461844',
14 'ext': 'mp4',
15 'title': 'Intersection: The Story of Josh Grant by Kyle Cowling',
16 'description': 'A unique motocross documentary that examines the '
17 'life and mind of one of sports most elite athletes: Josh Grant.',
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 }]
30
31 def _real_extract(self, url):
32 video_id = self._match_id(url)
33 webpage = self._download_webpage(url, video_id)
34
35 title = self._html_search_regex(
36 r'<title>\s*(.*?)(?:\s*&mdash; Kickstarter)?\s*</title>',
37 webpage, 'title')
38 video_url = self._search_regex(
39 r'data-video-url="(.*?)"',
40 webpage, 'video URL', default=None)
41 if video_url is None: # No native kickstarter, look for embedded videos
42 return {
43 '_type': 'url_transparent',
44 'ie_key': 'Generic',
45 'url': url,
46 'title': title,
47 }
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 }