]> jfr.im git - yt-dlp.git/blame - yt_dlp/extractor/ntvde.py
[ie/youtube] Suppress "Unavailable videos are hidden" warning (#10159)
[yt-dlp.git] / yt_dlp / extractor / ntvde.py
CommitLineData
b8223203
YCH
1import re
2
8f4b58d7
PH
3from .common import InfoExtractor
4from ..utils import (
5 int_or_none,
6 js_to_json,
8afd9468 7 url_or_none,
8f4b58d7 8)
8afd9468 9from ..utils.traversal import traverse_obj
8f4b58d7
PH
10
11
12class NTVDeIE(InfoExtractor):
13 IE_NAME = 'n-tv.de'
8afd9468 14 _VALID_URL = r'https?://(?:www\.)?n-tv\.de/mediathek/(?:videos|magazine)/[^/?#]+/[^/?#]+-article(?P<id>[^/?#]+)\.html'
8f4b58d7
PH
15
16 _TESTS = [{
17 'url': 'http://www.n-tv.de/mediathek/videos/panorama/Schnee-und-Glaette-fuehren-zu-zahlreichen-Unfaellen-und-Staus-article14438086.html',
8afd9468 18 'md5': '6bcf2a6638cb83f45d5561659a1cb498',
8f4b58d7
PH
19 'info_dict': {
20 'id': '14438086',
21 'ext': 'mp4',
ec85ded8 22 'thumbnail': r're:^https?://.*\.jpg$',
8f4b58d7
PH
23 'title': 'Schnee und Glätte führen zu zahlreichen Unfällen und Staus',
24 'alt_title': 'Winterchaos auf deutschen Straßen',
25 'description': 'Schnee und Glätte sorgen deutschlandweit für einen chaotischen Start in die Woche: Auf den Straßen kommt es zu kilometerlangen Staus und Dutzenden Glätteunfällen. In Düsseldorf und München wirbelt der Schnee zudem den Flugplan durcheinander. Dutzende Flüge landen zu spät, einige fallen ganz aus.',
8afd9468 26 'duration': 67,
8f4b58d7
PH
27 'timestamp': 1422892797,
28 'upload_date': '20150202',
29 },
8afd9468
FA
30 }, {
31 'url': 'https://www.n-tv.de/mediathek/magazine/auslandsreport/Juedische-Siedler-wollten-Rache-die-wollten-nur-toeten-article24523089.html',
32 'md5': 'c5c6014c014ccc3359470e1d34472bfd',
33 'info_dict': {
34 'id': '24523089',
35 'ext': 'mp4',
36 'thumbnail': r're:^https?://.*\.jpg$',
37 'title': 'Jüdische Siedler "wollten Rache, die wollten nur töten"',
38 'alt_title': 'Israelische Gewalt fern von Gaza',
39 'description': 'Vier Tage nach dem Massaker der Hamas greifen jüdische Siedler das Haus einer palästinensischen Familie im Westjordanland an. Die Überlebenden berichten, sie waren unbewaffnet, die Angreifer seien nur auf "Rache und Töten" aus gewesen. Als die Toten beerdigt werden sollen, eröffnen die Siedler erneut das Feuer.',
40 'duration': 326,
41 'timestamp': 1699688294,
42 'upload_date': '20231111',
43 },
8f4b58d7
PH
44 }]
45
46 def _real_extract(self, url):
47 video_id = self._match_id(url)
48 webpage = self._download_webpage(url, video_id)
49
8afd9468
FA
50 info = self._search_json(
51 r'article:', webpage, 'info', video_id, transform_source=js_to_json)
52
53 vdata = self._search_json(
54 r'\$\(\s*"#playerwrapper"\s*\)\s*\.data\(\s*"player",',
55 webpage, 'player data', video_id,
56 transform_source=lambda s: js_to_json(re.sub(r'ivw:[^},]+', '', s)))['setup']['source']
163e8369
S
57
58 formats = []
8afd9468 59 if vdata.get('progressive'):
163e8369 60 formats.append({
8afd9468
FA
61 'format_id': 'http',
62 'url': vdata['progressive'],
163e8369 63 })
8afd9468 64 if vdata.get('hls'):
163e8369 65 formats.extend(self._extract_m3u8_formats(
8afd9468
FA
66 vdata['hls'], video_id, 'mp4', m3u8_id='hls', fatal=False))
67 if vdata.get('dash'):
68 formats.extend(self._extract_mpd_formats(vdata['dash'], video_id, fatal=False, mpd_id='dash'))
8f4b58d7
PH
69
70 return {
71 'id': video_id,
8afd9468
FA
72 **traverse_obj(info, {
73 'title': 'headline',
74 'description': 'intro',
75 'alt_title': 'kicker',
76 'timestamp': ('publishedDateAsUnixTimeStamp', {int_or_none}),
77 }),
78 **traverse_obj(vdata, {
79 'thumbnail': ('poster', {url_or_none}),
80 'duration': ('length', {int_or_none}),
81 }),
8f4b58d7
PH
82 'formats': formats,
83 }