mirror of
https://github.com/ytdl-org/youtube-dl.git
synced 2024-11-15 03:27:46 +01:00
[dvtv] Improve and fix playlists support (closes #13063)
This commit is contained in:
parent
765522345f
commit
4d9fc40100
@ -5,9 +5,12 @@ import re
|
|||||||
|
|
||||||
from .common import InfoExtractor
|
from .common import InfoExtractor
|
||||||
from ..utils import (
|
from ..utils import (
|
||||||
js_to_json,
|
determine_ext,
|
||||||
unescapeHTML,
|
|
||||||
ExtractorError,
|
ExtractorError,
|
||||||
|
int_or_none,
|
||||||
|
js_to_json,
|
||||||
|
mimetype2ext,
|
||||||
|
unescapeHTML,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@ -24,14 +27,7 @@ class DVTVIE(InfoExtractor):
|
|||||||
'id': 'dc0768de855511e49e4b0025900fea04',
|
'id': 'dc0768de855511e49e4b0025900fea04',
|
||||||
'ext': 'mp4',
|
'ext': 'mp4',
|
||||||
'title': 'Vondra o Českém století: Při pohledu na Havla mi bylo trapně',
|
'title': 'Vondra o Českém století: Při pohledu na Havla mi bylo trapně',
|
||||||
}
|
'duration': 1484,
|
||||||
}, {
|
|
||||||
'url': 'http://video.aktualne.cz/dvtv/stropnicky-policie-vrbetice-preventivne-nekontrolovala/r~82ed4322849211e4a10c0025900fea04/',
|
|
||||||
'md5': '6388f1941b48537dbd28791f712af8bf',
|
|
||||||
'info_dict': {
|
|
||||||
'id': '72c02230849211e49f60002590604f2e',
|
|
||||||
'ext': 'mp4',
|
|
||||||
'title': 'Stropnický: Policie Vrbětice preventivně nekontrolovala',
|
|
||||||
}
|
}
|
||||||
}, {
|
}, {
|
||||||
'url': 'http://video.aktualne.cz/dvtv/dvtv-16-12-2014-utok-talibanu-boj-o-kliniku-uprchlici/r~973eb3bc854e11e498be002590604f2e/',
|
'url': 'http://video.aktualne.cz/dvtv/dvtv-16-12-2014-utok-talibanu-boj-o-kliniku-uprchlici/r~973eb3bc854e11e498be002590604f2e/',
|
||||||
@ -44,72 +40,100 @@ class DVTVIE(InfoExtractor):
|
|||||||
'info_dict': {
|
'info_dict': {
|
||||||
'id': 'b0b40906854d11e4bdad0025900fea04',
|
'id': 'b0b40906854d11e4bdad0025900fea04',
|
||||||
'ext': 'mp4',
|
'ext': 'mp4',
|
||||||
'title': 'Drtinová Veselovský TV 16. 12. 2014: Témata dne'
|
'title': 'Drtinová Veselovský TV 16. 12. 2014: Témata dne',
|
||||||
|
'description': 'md5:0916925dea8e30fe84222582280b47a0',
|
||||||
|
'timestamp': 1418760010,
|
||||||
|
'upload_date': '20141216',
|
||||||
}
|
}
|
||||||
}, {
|
}, {
|
||||||
'md5': '5f7652a08b05009c1292317b449ffea2',
|
'md5': '5f7652a08b05009c1292317b449ffea2',
|
||||||
'info_dict': {
|
'info_dict': {
|
||||||
'id': '420ad9ec854a11e4bdad0025900fea04',
|
'id': '420ad9ec854a11e4bdad0025900fea04',
|
||||||
'ext': 'mp4',
|
'ext': 'mp4',
|
||||||
'title': 'Školní masakr možná změní boj s Talibanem, říká novinářka'
|
'title': 'Školní masakr možná změní boj s Talibanem, říká novinářka',
|
||||||
|
'description': 'md5:ff2f9f6de73c73d7cef4f756c1c1af42',
|
||||||
|
'timestamp': 1418760010,
|
||||||
|
'upload_date': '20141216',
|
||||||
}
|
}
|
||||||
}, {
|
}, {
|
||||||
'md5': '498eb9dfa97169f409126c617e2a3d64',
|
'md5': '498eb9dfa97169f409126c617e2a3d64',
|
||||||
'info_dict': {
|
'info_dict': {
|
||||||
'id': '95d35580846a11e4b6d20025900fea04',
|
'id': '95d35580846a11e4b6d20025900fea04',
|
||||||
'ext': 'mp4',
|
'ext': 'mp4',
|
||||||
'title': 'Boj o kliniku: Veřejný zájem, nebo právo na majetek?'
|
'title': 'Boj o kliniku: Veřejný zájem, nebo právo na majetek?',
|
||||||
|
'description': 'md5:889fe610a70fee5511dc3326a089188e',
|
||||||
|
'timestamp': 1418760010,
|
||||||
|
'upload_date': '20141216',
|
||||||
}
|
}
|
||||||
}, {
|
}, {
|
||||||
'md5': 'b8dc6b744844032dab6ba3781a7274b9',
|
'md5': 'b8dc6b744844032dab6ba3781a7274b9',
|
||||||
'info_dict': {
|
'info_dict': {
|
||||||
'id': '6fe14d66853511e4833a0025900fea04',
|
'id': '6fe14d66853511e4833a0025900fea04',
|
||||||
'ext': 'mp4',
|
'ext': 'mp4',
|
||||||
'title': 'Pánek: Odmítání syrských uprchlíků je ostudou české vlády'
|
'title': 'Pánek: Odmítání syrských uprchlíků je ostudou české vlády',
|
||||||
|
'description': 'md5:544f86de6d20c4815bea11bf2ac3004f',
|
||||||
|
'timestamp': 1418760010,
|
||||||
|
'upload_date': '20141216',
|
||||||
}
|
}
|
||||||
}],
|
}],
|
||||||
}, {
|
|
||||||
'url': 'http://video.aktualne.cz/v-cechach-poprve-zazni-zelenkova-zrestaurovana-mse/r~45b4b00483ec11e4883b002590604f2e/',
|
|
||||||
'only_matching': True,
|
|
||||||
}, {
|
}, {
|
||||||
'url': 'https://video.aktualne.cz/dvtv/zeman-si-jen-leci-mindraky-sobotku-nenavidi-a-babis-se-mu-te/r~960cdb3a365a11e7a83b0025900fea04/',
|
'url': 'https://video.aktualne.cz/dvtv/zeman-si-jen-leci-mindraky-sobotku-nenavidi-a-babis-se-mu-te/r~960cdb3a365a11e7a83b0025900fea04/',
|
||||||
'md5': 'f8efe9656017da948369aa099788c8ea',
|
'md5': 'f8efe9656017da948369aa099788c8ea',
|
||||||
'info_dict': {
|
'info_dict': {
|
||||||
'id': '3c496fec365911e7a6500025900fea04',
|
'id': '3c496fec365911e7a6500025900fea04',
|
||||||
'ext': 'm3u8',
|
'ext': 'mp4',
|
||||||
'title': 'Zeman si jen léčí mindráky, Sobotku nenávidí a Babiš se mu teď hodí, tvrdí Kmenta',
|
'title': 'Zeman si jen léčí mindráky, Sobotku nenávidí a Babiš se mu teď hodí, tvrdí Kmenta',
|
||||||
}
|
'duration': 1103,
|
||||||
|
},
|
||||||
|
'params': {
|
||||||
|
'skip_download': True,
|
||||||
|
},
|
||||||
|
}, {
|
||||||
|
'url': 'http://video.aktualne.cz/v-cechach-poprve-zazni-zelenkova-zrestaurovana-mse/r~45b4b00483ec11e4883b002590604f2e/',
|
||||||
|
'only_matching': True,
|
||||||
}]
|
}]
|
||||||
|
|
||||||
def _parse_video_metadata(self, js, video_id):
|
def _parse_video_metadata(self, js, video_id):
|
||||||
metadata = self._parse_json(js, video_id, transform_source=js_to_json)
|
data = self._parse_json(js, video_id, transform_source=js_to_json)
|
||||||
|
|
||||||
|
title = unescapeHTML(data['title'])
|
||||||
|
|
||||||
formats = []
|
formats = []
|
||||||
for video in metadata['sources']:
|
for video in data['sources']:
|
||||||
ext = video['type'][6:]
|
video_url = video.get('file')
|
||||||
if video['label'] != 'adaptive':
|
if not video_url:
|
||||||
|
continue
|
||||||
|
video_type = video.get('type')
|
||||||
|
ext = determine_ext(video_url, mimetype2ext(video_type))
|
||||||
|
if video_type == 'application/vnd.apple.mpegurl' or ext == 'm3u8':
|
||||||
|
formats.extend(self._extract_m3u8_formats(
|
||||||
|
video_url, video_id, 'mp4', entry_protocol='m3u8_native',
|
||||||
|
m3u8_id='hls', fatal=False))
|
||||||
|
elif video_type == 'application/dash+xml' or ext == 'mpd':
|
||||||
|
formats.extend(self._extract_mpd_formats(
|
||||||
|
video_url, video_id, mpd_id='dash', fatal=False))
|
||||||
|
else:
|
||||||
|
label = video.get('label')
|
||||||
|
height = self._search_regex(
|
||||||
|
r'^(\d+)[pP]', label or '', 'height', default=None)
|
||||||
|
format_id = ['http']
|
||||||
|
for f in (ext, label):
|
||||||
|
if f:
|
||||||
|
format_id.append(f)
|
||||||
formats.append({
|
formats.append({
|
||||||
'url': video['file'],
|
'url': video_url,
|
||||||
'ext': ext,
|
'format_id': '-'.join(format_id),
|
||||||
'format_id': '%s-%s' % (ext, video['label']),
|
'height': int_or_none(height),
|
||||||
'height': int(video['label'].rstrip('p')),
|
|
||||||
'fps': 25,
|
|
||||||
})
|
})
|
||||||
elif video['type'] == 'application/dash+xml':
|
|
||||||
formats.extend(self._extract_mpd_formats(video['file'],
|
|
||||||
video_id,
|
|
||||||
fatal=False))
|
|
||||||
elif video['type'] == 'application/vnd.apple.mpegurl':
|
|
||||||
formats.extend(self._extract_m3u8_formats(video['file'],
|
|
||||||
video_id,
|
|
||||||
fatal=False))
|
|
||||||
|
|
||||||
self._sort_formats(formats)
|
self._sort_formats(formats)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
'id': metadata['mediaid'],
|
'id': data.get('mediaid') or video_id,
|
||||||
'title': unescapeHTML(metadata['title']),
|
'title': title,
|
||||||
'thumbnail': self._proto_relative_url(metadata['image'], 'http:'),
|
'description': data.get('description'),
|
||||||
|
'thumbnail': data.get('image'),
|
||||||
|
'duration': int_or_none(data.get('duration')),
|
||||||
|
'timestamp': int_or_none(data.get('pubtime')),
|
||||||
'formats': formats
|
'formats': formats
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -120,7 +144,7 @@ class DVTVIE(InfoExtractor):
|
|||||||
|
|
||||||
# single video
|
# single video
|
||||||
item = self._search_regex(
|
item = self._search_regex(
|
||||||
r"(?s)embedData[0-9a-f]{32}\['asset'\]\s*=\s*(\{.+?\});",
|
r'(?s)embedData[0-9a-f]{32}\[["\']asset["\']\]\s*=\s*(\{.+?\});',
|
||||||
webpage, 'video', default=None, fatal=False)
|
webpage, 'video', default=None, fatal=False)
|
||||||
|
|
||||||
if item:
|
if item:
|
||||||
@ -130,6 +154,8 @@ class DVTVIE(InfoExtractor):
|
|||||||
items = re.findall(
|
items = re.findall(
|
||||||
r"(?s)BBX\.context\.assets\['[0-9a-f]{32}'\]\.push\(({.+?})\);",
|
r"(?s)BBX\.context\.assets\['[0-9a-f]{32}'\]\.push\(({.+?})\);",
|
||||||
webpage)
|
webpage)
|
||||||
|
if not items:
|
||||||
|
items = re.findall(r'(?s)var\s+asset\s*=\s*({.+?});\n', webpage)
|
||||||
|
|
||||||
if items:
|
if items:
|
||||||
return {
|
return {
|
||||||
|
Loading…
Reference in New Issue
Block a user