[ie/wistia] Support password-protected videos (#11100)
[yt-dlp3.git] / yt_dlp / extractor / kickstarter.py
blobc0d851d9615a69d04ed9f4d375975c1849c14da9
1 from .common import InfoExtractor
2 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.'
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',
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',
39 def _real_extract(self, url):
40 video_id = self._match_id(url)
41 webpage = self._download_webpage(url, video_id)
43 title = self._html_search_regex(
44 r'<title>\s*(.*?)(?:\s*&mdash;\s*Kickstarter)?\s*</title>',
45 webpage, 'title')
46 video_url = self._search_regex(
47 r'data-video-url="(.*?)"',
48 webpage, 'video URL', default=None)
49 if video_url is None: # No native kickstarter, look for embedded videos
50 return {
51 '_type': 'url_transparent',
52 'ie_key': 'Generic',
53 'url': smuggle_url(url, {'to_generic': True}),
54 'title': title,
57 thumbnail = self._og_search_thumbnail(webpage, default=None)
58 if thumbnail is None:
59 thumbnail = self._html_search_regex(
60 r'<img[^>]+class="[^"]+\s*poster\s*[^"]+"[^>]+src="([^"]+)"',
61 webpage, 'thumbnail image', fatal=False)
62 return {
63 'id': video_id,
64 'url': video_url,
65 'title': title,
66 'description': self._og_search_description(webpage, default=None),
67 'thumbnail': thumbnail,