[heise] Fix extraction
Now they use an XML format instead of JSON.
This commit is contained in:
parent
4a6c94288a
commit
ecfe623422
1 changed files with 21 additions and 27 deletions
|
@ -4,6 +4,7 @@ from __future__ import unicode_literals
|
||||||
from .common import InfoExtractor
|
from .common import InfoExtractor
|
||||||
from ..utils import (
|
from ..utils import (
|
||||||
get_meta_content,
|
get_meta_content,
|
||||||
|
int_or_none,
|
||||||
parse_iso8601,
|
parse_iso8601,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -28,20 +29,26 @@ class HeiseIE(InfoExtractor):
|
||||||
'timestamp': 1411812600,
|
'timestamp': 1411812600,
|
||||||
'upload_date': '20140927',
|
'upload_date': '20140927',
|
||||||
'description': 'In uplink-Episode 3.3 geht es darum, wie man sich von Cloud-Anbietern emanzipieren kann, worauf man beim Kauf einer Tastatur achten sollte und was Smartphones über uns verraten.',
|
'description': 'In uplink-Episode 3.3 geht es darum, wie man sich von Cloud-Anbietern emanzipieren kann, worauf man beim Kauf einer Tastatur achten sollte und was Smartphones über uns verraten.',
|
||||||
|
'thumbnail': 're:https?://.*\.jpg$',
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
def _real_extract(self, url):
|
def _real_extract(self, url):
|
||||||
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)
|
||||||
json_url = self._search_regex(
|
|
||||||
r'json_url:\s*"([^"]+)"', webpage, 'json URL')
|
container_id = self._search_regex(
|
||||||
config = self._download_json(json_url, video_id)
|
r'<div class="videoplayerjw".*?data-container="([0-9]+)"',
|
||||||
|
webpage, 'container ID')
|
||||||
|
sequenz_id = self._search_regex(
|
||||||
|
r'<div class="videoplayerjw".*?data-sequenz="([0-9]+)"',
|
||||||
|
webpage, 'sequenz ID')
|
||||||
|
data_url = 'http://www.heise.de/videout/feed?container=%s&sequenz=%s' % (container_id, sequenz_id)
|
||||||
|
doc = self._download_xml(data_url, video_id)
|
||||||
|
|
||||||
info = {
|
info = {
|
||||||
'id': video_id,
|
'id': video_id,
|
||||||
'thumbnail': config.get('poster'),
|
'thumbnail': self._og_search_thumbnail(webpage),
|
||||||
'timestamp': parse_iso8601(get_meta_content('date', webpage)),
|
'timestamp': parse_iso8601(get_meta_content('date', webpage)),
|
||||||
'description': self._og_search_description(webpage),
|
'description': self._og_search_description(webpage),
|
||||||
}
|
}
|
||||||
|
@ -49,32 +56,19 @@ class HeiseIE(InfoExtractor):
|
||||||
title = get_meta_content('fulltitle', webpage)
|
title = get_meta_content('fulltitle', webpage)
|
||||||
if title:
|
if title:
|
||||||
info['title'] = title
|
info['title'] = title
|
||||||
elif config.get('title'):
|
|
||||||
info['title'] = config['title']
|
|
||||||
else:
|
else:
|
||||||
info['title'] = self._og_search_title(webpage)
|
info['title'] = self._og_search_title(webpage)
|
||||||
|
|
||||||
formats = []
|
formats = []
|
||||||
for t, rs in config['formats'].items():
|
for source_node in doc.findall('.//{http://rss.jwpcdn.com/}source'):
|
||||||
if not rs or not hasattr(rs, 'items'):
|
label = source_node.attrib['label']
|
||||||
self._downloader.report_warning(
|
height = int_or_none(self._search_regex(
|
||||||
'formats: {0}: no resolutions'.format(t))
|
r'^(.*?_)?([0-9]+)p$', label, 'height', default=None))
|
||||||
continue
|
|
||||||
|
|
||||||
for height_str, obj in rs.items():
|
|
||||||
format_id = '{0}_{1}'.format(t, height_str)
|
|
||||||
|
|
||||||
if not obj or not obj.get('url'):
|
|
||||||
self._downloader.report_warning(
|
|
||||||
'formats: {0}: no url'.format(format_id))
|
|
||||||
continue
|
|
||||||
|
|
||||||
formats.append({
|
formats.append({
|
||||||
'url': obj['url'],
|
'url': source_node.attrib['file'],
|
||||||
'format_id': format_id,
|
'format_note': label,
|
||||||
'height': self._int(height_str, 'height'),
|
'height': height,
|
||||||
})
|
})
|
||||||
|
|
||||||
self._sort_formats(formats)
|
self._sort_formats(formats)
|
||||||
info['formats'] = formats
|
info['formats'] = formats
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue