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