mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-11-10 11:20:41 +00:00
[dvtv] PEP8 and correct format sorting (#4502)
This commit is contained in:
parent
edf41477f0
commit
b9465395cb
@ -2,11 +2,8 @@
|
|||||||
|
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
import re
|
|
||||||
import json
|
|
||||||
from .common import InfoExtractor
|
from .common import InfoExtractor
|
||||||
from ..utils import (
|
from ..utils import (
|
||||||
ExtractorError,
|
|
||||||
js_to_json,
|
js_to_json,
|
||||||
unescapeHTML
|
unescapeHTML
|
||||||
)
|
)
|
||||||
@ -28,10 +25,10 @@ class DVTVIE(InfoExtractor):
|
|||||||
}
|
}
|
||||||
}, {
|
}, {
|
||||||
'url': 'http://video.aktualne.cz/dvtv/stropnicky-policie-vrbetice-preventivne-nekontrolovala/r~82ed4322849211e4a10c0025900fea04/',
|
'url': 'http://video.aktualne.cz/dvtv/stropnicky-policie-vrbetice-preventivne-nekontrolovala/r~82ed4322849211e4a10c0025900fea04/',
|
||||||
'md5': 'd50455195a67a94c57f931360cc68a1b',
|
'md5': '6388f1941b48537dbd28791f712af8bf',
|
||||||
'info_dict': {
|
'info_dict': {
|
||||||
'id': '82ed4322849211e4a10c0025900fea04',
|
'id': '82ed4322849211e4a10c0025900fea04',
|
||||||
'ext': 'webm',
|
'ext': 'mp4',
|
||||||
'title': 'Stropnický: Policie Vrbětice preventivně nekontrolovala'
|
'title': 'Stropnický: Policie Vrbětice preventivně nekontrolovala'
|
||||||
}
|
}
|
||||||
}]
|
}]
|
||||||
@ -40,19 +37,22 @@ class DVTVIE(InfoExtractor):
|
|||||||
video_id = self._match_id(url)
|
video_id = self._match_id(url)
|
||||||
webpage = self._download_webpage(url, video_id)
|
webpage = self._download_webpage(url, video_id)
|
||||||
|
|
||||||
code = self._search_regex(r'embedData[0-9a-f]{32}\[\'asset\'\] = (\{.+?\});', webpage, 'video JSON', flags=re.DOTALL)
|
code = self._search_regex(
|
||||||
|
r'(?s)embedData[0-9a-f]{32}\[\'asset\'\] = (\{.+?\});',
|
||||||
|
webpage, 'video JSON')
|
||||||
payload = self._parse_json(code, video_id, transform_source=js_to_json)
|
payload = self._parse_json(code, video_id, transform_source=js_to_json)
|
||||||
formats = []
|
formats = []
|
||||||
for source in payload['sources']:
|
for source in payload['sources']:
|
||||||
|
ext = source['type'][6:]
|
||||||
formats.append({
|
formats.append({
|
||||||
'url': source['file'],
|
'url': source['file'],
|
||||||
'ext': source['type'][6:],
|
'ext': ext,
|
||||||
'format': '%s %s' % (source['type'][6:], source['label']),
|
'format': '%s %s' % (ext, source['label']),
|
||||||
'format_id': '%s-%s' % (source['type'][6:], source['label']),
|
'format_id': '%s-%s' % (ext, source['label']),
|
||||||
'resolution': source['label'],
|
'height': int(source['label'].rstrip('p')),
|
||||||
'fps': 25,
|
'fps': 25,
|
||||||
'preference': -1 if source['type'][6:] == 'mp4' and source['label'] == '720p' else -2
|
|
||||||
})
|
})
|
||||||
|
self._sort_formats(formats)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
'id': video_id[-32:],
|
'id': video_id[-32:],
|
||||||
|
Loading…
Reference in New Issue
Block a user