]> jfr.im git - yt-dlp.git/blob - yt_dlp/extractor/crooksandliars.py
[ie/youtube] Suppress "Unavailable videos are hidden" warning (#10159)
[yt-dlp.git] / yt_dlp / extractor / crooksandliars.py
1 from .common import InfoExtractor
2 from ..utils import (
3 int_or_none,
4 qualities,
5 )
6
7
8 class CrooksAndLiarsIE(InfoExtractor):
9 _VALID_URL = r'https?://embed\.crooksandliars\.com/(?:embed|v)/(?P<id>[A-Za-z0-9]+)'
10 _EMBED_REGEX = [r'<(?:iframe[^>]+src|param[^>]+value)=(["\'])(?P<url>(?:https?:)?//embed\.crooksandliars\.com/(?:embed|v)/.+?)\1']
11
12 _TESTS = [{
13 'url': 'https://embed.crooksandliars.com/embed/8RUoRhRi',
14 'info_dict': {
15 'id': '8RUoRhRi',
16 'ext': 'mp4',
17 'title': 'Fox & Friends Says Protecting Atheists From Discrimination Is Anti-Christian!',
18 'description': 'md5:e1a46ad1650e3a5ec7196d432799127f',
19 'thumbnail': r're:^https?://.*\.jpg',
20 'timestamp': 1428207000,
21 'upload_date': '20150405',
22 'uploader': 'Heather',
23 'duration': 236,
24 },
25 }, {
26 'url': 'http://embed.crooksandliars.com/v/MTE3MjUtMzQ2MzA',
27 'only_matching': True,
28 }]
29
30 def _real_extract(self, url):
31 video_id = self._match_id(url)
32
33 webpage = self._download_webpage(
34 f'http://embed.crooksandliars.com/embed/{video_id}', video_id)
35
36 manifest = self._search_json(r'var\s+manifest\s*=', webpage, 'manifest JSON', video_id)
37
38 quality = qualities(('webm_low', 'mp4_low', 'webm_high', 'mp4_high'))
39
40 formats = [{
41 'url': item['url'],
42 'format_id': item['type'],
43 'quality': quality(item['type']),
44 } for item in manifest['flavors'] if item['mime'].startswith('video/')]
45
46 return {
47 'url': url,
48 'id': video_id,
49 'title': manifest['title'],
50 'description': manifest.get('description'),
51 'thumbnail': self._proto_relative_url(manifest.get('poster')),
52 'timestamp': int_or_none(manifest.get('created')),
53 'uploader': manifest.get('author'),
54 'duration': int_or_none(manifest.get('duration')),
55 'formats': formats,
56 }