mirror of
https://codeberg.org/polarisfm/youtube-dl
synced 2024-11-22 16:44:32 +01:00
[ntvde] Fix extraction (closes #21204)
This commit is contained in:
parent
c97f5e934f
commit
cba1a5e1ae
@ -4,11 +4,9 @@ from __future__ import unicode_literals
|
|||||||
import re
|
import re
|
||||||
|
|
||||||
from .common import InfoExtractor
|
from .common import InfoExtractor
|
||||||
from ..compat import compat_urlparse
|
|
||||||
from ..utils import (
|
from ..utils import (
|
||||||
int_or_none,
|
int_or_none,
|
||||||
js_to_json,
|
js_to_json,
|
||||||
parse_duration,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@ -18,7 +16,7 @@ class NTVDeIE(InfoExtractor):
|
|||||||
|
|
||||||
_TESTS = [{
|
_TESTS = [{
|
||||||
'url': 'http://www.n-tv.de/mediathek/videos/panorama/Schnee-und-Glaette-fuehren-zu-zahlreichen-Unfaellen-und-Staus-article14438086.html',
|
'url': 'http://www.n-tv.de/mediathek/videos/panorama/Schnee-und-Glaette-fuehren-zu-zahlreichen-Unfaellen-und-Staus-article14438086.html',
|
||||||
'md5': '6ef2514d4b1e8e03ca24b49e2f167153',
|
'md5': 'ec439b7980c2a600c357dbe431555c5d',
|
||||||
'info_dict': {
|
'info_dict': {
|
||||||
'id': '14438086',
|
'id': '14438086',
|
||||||
'ext': 'mp4',
|
'ext': 'mp4',
|
||||||
@ -26,7 +24,7 @@ class NTVDeIE(InfoExtractor):
|
|||||||
'title': 'Schnee und Glätte führen zu zahlreichen Unfällen und Staus',
|
'title': 'Schnee und Glätte führen zu zahlreichen Unfällen und Staus',
|
||||||
'alt_title': 'Winterchaos auf deutschen Straßen',
|
'alt_title': 'Winterchaos auf deutschen Straßen',
|
||||||
'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.',
|
'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.',
|
||||||
'duration': 4020,
|
'duration': 67,
|
||||||
'timestamp': 1422892797,
|
'timestamp': 1422892797,
|
||||||
'upload_date': '20150202',
|
'upload_date': '20150202',
|
||||||
},
|
},
|
||||||
@ -37,31 +35,26 @@ class NTVDeIE(InfoExtractor):
|
|||||||
webpage = self._download_webpage(url, video_id)
|
webpage = self._download_webpage(url, video_id)
|
||||||
|
|
||||||
info = self._parse_json(self._search_regex(
|
info = self._parse_json(self._search_regex(
|
||||||
r'(?s)ntv\.pageInfo\.article\s*=\s*(\{.*?\});', webpage, 'info'),
|
r'(?s)article:\s*(\{.*?\})', webpage, 'info'),
|
||||||
video_id, transform_source=js_to_json)
|
video_id, transform_source=js_to_json)
|
||||||
timestamp = int_or_none(info.get('publishedDateAsUnixTimeStamp'))
|
timestamp = int_or_none(info.get('publishedDateAsUnixTimeStamp'))
|
||||||
vdata = self._parse_json(self._search_regex(
|
pdata = self._parse_json(self._search_regex(
|
||||||
r'(?s)\$\(\s*"\#player"\s*\)\s*\.data\(\s*"player",\s*(\{.*?\})\);',
|
r'(?s)\$\(\s*"\#playerwrapper"\s*\)\s*\.data\(\s*"player",\s*(\{.*?\})\);',
|
||||||
webpage, 'player data'), video_id,
|
webpage, 'player data'), video_id,
|
||||||
transform_source=lambda s: js_to_json(re.sub(r'advertising:\s*{[^}]+},', '', s)))
|
transform_source=lambda s: js_to_json(re.sub(r',\s*ivw:\s*[^}]*}', '}', s))) # ignore from composed IVW key/value on
|
||||||
duration = parse_duration(vdata.get('duration'))
|
vdata = pdata['setup']['source']
|
||||||
|
duration = vdata.get('length')
|
||||||
|
|
||||||
formats = []
|
formats = []
|
||||||
if vdata.get('video'):
|
if vdata.get('progressive'):
|
||||||
formats.append({
|
formats.append({
|
||||||
'format_id': 'flash',
|
'format_id': 'progressive',
|
||||||
'url': 'rtmp://fms.n-tv.de/%s' % vdata['video'],
|
'url': vdata['progressive'],
|
||||||
|
'preference': 1, # prefer, as seems to have the same properties as the highest HLS quality, plus proper fps
|
||||||
})
|
})
|
||||||
if vdata.get('videoMp4'):
|
if vdata.get('hls'):
|
||||||
formats.append({
|
|
||||||
'format_id': 'mobile',
|
|
||||||
'url': compat_urlparse.urljoin('http://video.n-tv.de', vdata['videoMp4']),
|
|
||||||
'tbr': 400, # estimation
|
|
||||||
})
|
|
||||||
if vdata.get('videoM3u8'):
|
|
||||||
m3u8_url = compat_urlparse.urljoin('http://video.n-tv.de', vdata['videoM3u8'])
|
|
||||||
formats.extend(self._extract_m3u8_formats(
|
formats.extend(self._extract_m3u8_formats(
|
||||||
m3u8_url, video_id, ext='mp4', entry_protocol='m3u8_native',
|
vdata['hls'], video_id, ext='mp4', entry_protocol='m3u8_native',
|
||||||
preference=0, m3u8_id='hls', fatal=False))
|
preference=0, m3u8_id='hls', fatal=False))
|
||||||
self._sort_formats(formats)
|
self._sort_formats(formats)
|
||||||
|
|
||||||
@ -71,7 +64,7 @@ class NTVDeIE(InfoExtractor):
|
|||||||
'description': info.get('intro'),
|
'description': info.get('intro'),
|
||||||
'alt_title': info.get('kicker'),
|
'alt_title': info.get('kicker'),
|
||||||
'timestamp': timestamp,
|
'timestamp': timestamp,
|
||||||
'thumbnail': vdata.get('html5VideoPoster'),
|
'thumbnail': vdata.get('poster'),
|
||||||
'duration': duration,
|
'duration': duration,
|
||||||
'formats': formats,
|
'formats': formats,
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user