added kickstarter IE
[youtube-dl] / youtube_dl / extractor / kickstarter.py
1 import re
2
3 from .common import InfoExtractor
4
5
6 class KickStarterIE(InfoExtractor):
7     _VALID_URL = r'https?://www\.kickstarter\.com/projects/(?P<id>.*)/.*\?'
8     _TEST = {
9         "url": "https://www.kickstarter.com/projects/1404461844/intersection-the-story-of-josh-grant?ref=home_location",
10         "file": "1404461844.mp4",
11         "md5": "c81addca81327ffa66c642b5d8b08cab",
12         "info_dict": {
13             "title": u"Intersection: The Story of Josh Grant by Kyle Cowling \u2014 Kickstarter"
14         }
15     }
16
17
18     def _real_extract(self, url):
19         m = re.match(self._VALID_URL, url)
20         video_id = m.group('id')
21
22         webpage_src = self._download_webpage(url, video_id)
23
24         video_url = self._search_regex(r'data-video="(.*?)">',
25             webpage_src, u'video URL')
26
27         if 'mp4' in video_url:
28             ext = 'mp4'
29         else:
30             ext = 'flv'
31
32         video_title = self._html_search_regex(r"<title>(.*)</title>?",
33             webpage_src, u'title')
34
35
36         results = [{
37                     'id': video_id,
38                     'url' : video_url,
39                     'title' : video_title,
40                     'ext' : ext,
41                     }]
42
43         return results