1
0
Fork 0
mirror of https://github.com/blackjack4494/yt-dlc.git synced 2024-12-22 15:57:23 +00:00

[dvtv] PEP8 and correct format sorting (#4502)

This commit is contained in:
Philipp Hagemeister 2014-12-17 23:18:06 +01:00
parent edf41477f0
commit b9465395cb

View file

@ -2,11 +2,8 @@
from __future__ import unicode_literals
import re
import json
from .common import InfoExtractor
from ..utils import (
ExtractorError,
js_to_json,
unescapeHTML
)
@ -28,10 +25,10 @@ class DVTVIE(InfoExtractor):
}
}, {
'url': 'http://video.aktualne.cz/dvtv/stropnicky-policie-vrbetice-preventivne-nekontrolovala/r~82ed4322849211e4a10c0025900fea04/',
'md5': 'd50455195a67a94c57f931360cc68a1b',
'md5': '6388f1941b48537dbd28791f712af8bf',
'info_dict': {
'id': '82ed4322849211e4a10c0025900fea04',
'ext': 'webm',
'ext': 'mp4',
'title': 'Stropnický: Policie Vrbětice preventivně nekontrolovala'
}
}]
@ -40,19 +37,22 @@ class DVTVIE(InfoExtractor):
video_id = self._match_id(url)
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)
formats = []
for source in payload['sources']:
ext = source['type'][6:]
formats.append({
'url': source['file'],
'ext': source['type'][6:],
'format': '%s %s' % (source['type'][6:], source['label']),
'format_id': '%s-%s' % (source['type'][6:], source['label']),
'resolution': source['label'],
'ext': ext,
'format': '%s %s' % (ext, source['label']),
'format_id': '%s-%s' % (ext, source['label']),
'height': int(source['label'].rstrip('p')),
'fps': 25,
'preference': -1 if source['type'][6:] == 'mp4' and source['label'] == '720p' else -2
})
self._sort_formats(formats)
return {
'id': video_id[-32:],