]> jfr.im git - yt-dlp.git/blob - yt_dlp/extractor/crtvg.py
[ie/youtube] Suppress "Unavailable videos are hidden" warning (#10159)
[yt-dlp.git] / yt_dlp / extractor / crtvg.py
1 import re
2
3 from .common import InfoExtractor
4 from ..utils import make_archive_id, remove_end
5
6
7 class CrtvgIE(InfoExtractor):
8 _VALID_URL = r'https?://(?:www\.)?crtvg\.es/tvg/a-carta/(?P<id>[^/#?]+)'
9 _TESTS = [{
10 'url': 'https://www.crtvg.es/tvg/a-carta/os-caimans-do-tea-5839623',
11 'md5': 'c0958d9ff90e4503a75544358758921d',
12 'info_dict': {
13 'id': 'os-caimans-do-tea-5839623',
14 'title': 'Os caimáns do Tea',
15 'ext': 'mp4',
16 'description': 'md5:f71cfba21ae564f0a6f415b31de1f842',
17 'thumbnail': r're:^https?://.*\.(?:jpg|png)',
18 '_old_archive_ids': ['crtvg 5839623'],
19 },
20 'params': {'skip_download': 'm3u8'},
21 }, {
22 'url': 'https://www.crtvg.es/tvg/a-carta/a-parabolica-love-story',
23 'md5': '9a47b95a1749db7b7eb3214904624584',
24 'info_dict': {
25 'id': 'a-parabolica-love-story',
26 'title': 'A parabólica / Trabuco, o can mordedor / Love Story',
27 'ext': 'mp4',
28 'description': 'md5:f71cfba21ae564f0a6f415b31de1f842',
29 'thumbnail': r're:^https?://.*\.(?:jpg|png)',
30 },
31 'params': {'skip_download': 'm3u8'},
32 }]
33
34 def _real_extract(self, url):
35 video_id = self._match_id(url)
36 webpage = self._download_webpage(url, video_id)
37 video_url = self._search_regex(r'var\s+url\s*=\s*["\']([^"\']+)', webpage, 'video url')
38 formats = self._extract_m3u8_formats(video_url + '/playlist.m3u8', video_id, fatal=False)
39 formats.extend(self._extract_mpd_formats(video_url + '/manifest.mpd', video_id, fatal=False))
40
41 old_video_id = None
42 if mobj := re.fullmatch(r'[^/#?]+-(?P<old_id>\d{7})', video_id):
43 old_video_id = [make_archive_id(self, mobj.group('old_id'))]
44
45 return {
46 'id': video_id,
47 '_old_archive_ids': old_video_id,
48 'formats': formats,
49 'title': remove_end(self._html_search_meta(
50 ['og:title', 'twitter:title'], webpage, 'title', default=None), ' | CRTVG'),
51 'description': self._html_search_meta('description', webpage, 'description', default=None),
52 'thumbnail': self._html_search_meta(['og:image', 'twitter:image'], webpage, 'thumbnail', default=None),
53 }