[ie/wistia] Support password-protected videos (#11100)
[yt-dlp3.git] / yt_dlp / extractor / harpodeon.py
blobaa3b2ca34a2ac81fb968634db809a3ecbfbaf523
1 from .common import InfoExtractor
2 from ..utils import int_or_none
5 class HarpodeonIE(InfoExtractor):
6 _VALID_URL = r'https?://(?:www\.)?harpodeon\.com/(?:video|preview)/\w+/(?P<id>\d+)'
7 _TESTS = [{
8 'url': 'https://www.harpodeon.com/video/The_Smoking_Out_of_Bella_Butts/268068288',
9 'md5': '727371564a6a9ebccef2073535b5b6bd',
10 'skip': 'Free video could become unavailable',
11 'info_dict': {
12 'id': '268068288',
13 'ext': 'mp4',
14 'title': 'The Smoking Out of Bella Butts',
15 'description': 'md5:47e16bdb41fc8a79c83ab83af11c8b77',
16 'creator': 'Vitagraph Company of America',
17 'release_year': 1915,
19 }, {
20 'url': 'https://www.harpodeon.com/preview/The_Smoking_Out_of_Bella_Butts/268068288',
21 'md5': '6dfea5412845f690c7331be703f884db',
22 'info_dict': {
23 'id': '268068288',
24 'ext': 'mp4',
25 'title': 'The Smoking Out of Bella Butts',
26 'description': 'md5:47e16bdb41fc8a79c83ab83af11c8b77',
27 'creator': 'Vitagraph Company of America',
28 'release_year': 1915,
30 }, {
31 'url': 'https://www.harpodeon.com/preview/Behind_the_Screen/421838710',
32 'md5': '7979df9ca04637282cb7d172ab3a9c3b',
33 'info_dict': {
34 'id': '421838710',
35 'ext': 'mp4',
36 'title': 'Behind the Screen',
37 'description': 'md5:008972a3dc51fba3965ee517d2ba9155',
38 'creator': 'Lone Star Corporation',
39 'release_year': 1916,
43 def _real_extract(self, url):
44 video_id = self._match_id(url)
45 webpage = self._download_webpage(url, video_id)
47 title, creator, release_year = self._search_regex(
48 r'''(?x)
49 <div[^>]+videoInfo[^<]*<h2[^>]*>(?P<title>[^>]+)</h2>
50 (?:\s*<p[^>]*>\((?P<creator>.+),\s*)?(?P<release_year>\d{4})?''',
51 webpage, 'title', group=('title', 'creator', 'release_year'),
52 fatal=False) or (None, None, None)
54 hp_base = self._html_search_regex(r'hpBase\(\s*["\']([^"\']+)', webpage, 'hp_base')
56 hp_inject_video, hp_resolution = self._search_regex(
57 r'''(?x)
58 hpInjectVideo\([\'\"](?P<hp_inject_video>\w+)[\'\"],
59 [\'\"](?P<hp_resolution>\d+)[\'\"]''',
60 webpage, 'hp_inject_video', group=['hp_inject_video', 'hp_resolution'])
62 return {
63 'id': video_id,
64 'title': title,
65 'url': f'{hp_base}{hp_inject_video}_{hp_resolution}.mp4',
66 'http_headers': {'Referer': url},
67 'description': self._html_search_meta('description', webpage, fatal=False),
68 'creator': creator,
69 'release_year': int_or_none(release_year),