]> jfr.im git - yt-dlp.git/blob - yt_dlp/extractor/lcp.py
[misc] Add `hatch`, `ruff`, `pre-commit` and improve dev docs (#7409)
[yt-dlp.git] / yt_dlp / extractor / lcp.py
1 from .arkena import ArkenaIE
2 from .common import InfoExtractor
3
4
5 class LcpPlayIE(ArkenaIE): # XXX: Do not subclass from concrete IE
6 _VALID_URL = r'https?://play\.lcp\.fr/embed/(?P<id>[^/]+)/(?P<account_id>[^/]+)/[^/]+/[^/]+'
7 _TESTS = [{
8 'url': 'http://play.lcp.fr/embed/327336/131064/darkmatter/0',
9 'md5': 'b8bd9298542929c06c1c15788b1f277a',
10 'info_dict': {
11 'id': '327336',
12 'ext': 'mp4',
13 'title': '327336',
14 'timestamp': 1456391602,
15 'upload_date': '20160225',
16 },
17 'params': {
18 'skip_download': True,
19 },
20 }]
21
22
23 class LcpIE(InfoExtractor):
24 _VALID_URL = r'https?://(?:www\.)?lcp\.fr/(?:[^/]+/)*(?P<id>[^/]+)'
25
26 _TESTS = [{
27 # arkena embed
28 'url': 'http://www.lcp.fr/la-politique-en-video/schwartzenberg-prg-preconise-francois-hollande-de-participer-une-primaire',
29 'md5': 'b8bd9298542929c06c1c15788b1f277a',
30 'info_dict': {
31 'id': 'd56d03e9',
32 'ext': 'mp4',
33 'title': 'Schwartzenberg (PRG) préconise à François Hollande de participer à une primaire à gauche',
34 'description': 'md5:96ad55009548da9dea19f4120c6c16a8',
35 'timestamp': 1456488895,
36 'upload_date': '20160226',
37 },
38 'params': {
39 'skip_download': True,
40 },
41 }, {
42 # dailymotion live stream
43 'url': 'http://www.lcp.fr/le-direct',
44 'info_dict': {
45 'id': 'xji3qy',
46 'ext': 'mp4',
47 'title': 'La Chaine Parlementaire (LCP), Live TNT',
48 'description': 'md5:5c69593f2de0f38bd9a949f2c95e870b',
49 'uploader': 'LCP',
50 'uploader_id': 'xbz33d',
51 'timestamp': 1308923058,
52 'upload_date': '20110624',
53 },
54 'params': {
55 # m3u8 live stream
56 'skip_download': True,
57 },
58 }, {
59 'url': 'http://www.lcp.fr/emissions/277792-les-volontaires',
60 'only_matching': True,
61 }]
62
63 def _real_extract(self, url):
64 display_id = self._match_id(url)
65
66 webpage = self._download_webpage(url, display_id)
67
68 play_url = self._search_regex(
69 r'<iframe[^>]+src=(["\'])(?P<url>%s?(?:(?!\1).)*)\1' % LcpPlayIE._VALID_URL,
70 webpage, 'play iframe', default=None, group='url')
71
72 if not play_url:
73 return self.url_result(url, 'Generic')
74
75 title = self._og_search_title(webpage, default=None) or self._html_search_meta(
76 'twitter:title', webpage, fatal=True)
77 description = self._html_search_meta(
78 ('description', 'twitter:description'), webpage)
79
80 return {
81 '_type': 'url_transparent',
82 'ie_key': LcpPlayIE.ie_key(),
83 'url': play_url,
84 'display_id': display_id,
85 'title': title,
86 'description': description,
87 }