]> jfr.im git - yt-dlp.git/blame - youtube_dl/extractor/kickstarter.py
[openload] Add support for oload.win and oload.download
[yt-dlp.git] / youtube_dl / extractor / kickstarter.py
CommitLineData
dcdb292f 1# coding: utf-8
79bfd010
JMF
2from __future__ import unicode_literals
3
f1d20fa3 4from .common import InfoExtractor
abe694ca 5from ..utils import smuggle_url
f1d20fa3
JMS
6
7
8class KickStarterIE(InfoExtractor):
92519402 9 _VALID_URL = r'https?://(?:www\.)?kickstarter\.com/projects/(?P<id>[^/]*)/.*'
e00fc35d 10 _TESTS = [{
f021acee 11 'url': 'https://www.kickstarter.com/projects/1404461844/intersection-the-story-of-josh-grant/description',
79bfd010
JMF
12 'md5': 'c81addca81327ffa66c642b5d8b08cab',
13 'info_dict': {
14 'id': '1404461844',
15 'ext': 'mp4',
16 'title': 'Intersection: The Story of Josh Grant by Kyle Cowling',
9e1a5b84
JW
17 'description': (
18 'A unique motocross documentary that examines the '
19 'life and mind of one of sports most elite athletes: Josh Grant.'
20 ),
94518f20 21 },
e00fc35d
PH
22 }, {
23 'note': 'Embedded video (not using the native kickstarter video service)',
24 'url': 'https://www.kickstarter.com/projects/597507018/pebble-e-paper-watch-for-iphone-and-android/posts/659178',
4a6c9428
PH
25 'info_dict': {
26 'id': '78704821',
27 'ext': 'mp4',
28 'uploader_id': 'pebble',
29 'uploader': 'Pebble Technology',
30 'title': 'Pebble iOS Notifications',
abe694ca
YCH
31 },
32 'add_ie': ['Vimeo'],
627b9648
YCH
33 }, {
34 'url': 'https://www.kickstarter.com/projects/1420158244/power-drive-2000/widget/video.html',
35 'info_dict': {
36 'id': '1420158244',
37 'ext': 'mp4',
38 'title': 'Power Drive 2000',
39 },
e00fc35d 40 }]
f1d20fa3 41
f1d20fa3 42 def _real_extract(self, url):
4a6c9428 43 video_id = self._match_id(url)
79bfd010 44 webpage = self._download_webpage(url, video_id)
f1d20fa3 45
e00fc35d 46 title = self._html_search_regex(
f021acee 47 r'<title>\s*(.*?)(?:\s*&mdash;\s*Kickstarter)?\s*</title>',
e00fc35d
PH
48 webpage, 'title')
49 video_url = self._search_regex(
50 r'data-video-url="(.*?)"',
51 webpage, 'video URL', default=None)
52 if video_url is None: # No native kickstarter, look for embedded videos
53 return {
54 '_type': 'url_transparent',
55 'ie_key': 'Generic',
abe694ca 56 'url': smuggle_url(url, {'to_generic': True}),
e00fc35d
PH
57 'title': title,
58 }
f1d20fa3 59
627b9648
YCH
60 thumbnail = self._og_search_thumbnail(webpage, default=None)
61 if thumbnail is None:
62 thumbnail = self._html_search_regex(
63 r'<img[^>]+class="[^"]+\s*poster\s*[^"]+"[^>]+src="([^"]+)"',
64 webpage, 'thumbnail image', fatal=False)
79bfd010
JMF
65 return {
66 'id': video_id,
67 'url': video_url,
e00fc35d 68 'title': title,
08773689 69 'description': self._og_search_description(webpage, default=None),
627b9648 70 'thumbnail': thumbnail,
79bfd010 71 }