]>
Commit | Line | Data |
---|---|---|
0155549d M |
1 | # coding: utf-8 |
2 | from __future__ import unicode_literals | |
3 | ||
0155549d M |
4 | from .common import InfoExtractor |
5 | from ..utils import ( | |
711ede6e | 6 | determine_ext, |
ecfe6234 | 7 | int_or_none, |
0155549d | 8 | parse_iso8601, |
bad4ccdb | 9 | xpath_text, |
0155549d M |
10 | ) |
11 | ||
12 | ||
13 | class HeiseIE(InfoExtractor): | |
bad4ccdb S |
14 | _VALID_URL = r'https?://(?:www\.)?heise\.de/(?:[^/]+/)+[^/]+-(?P<id>[0-9]+)\.html' |
15 | _TESTS = [{ | |
16 | 'url': 'http://www.heise.de/video/artikel/Podcast-c-t-uplink-3-3-Owncloud-Tastaturen-Peilsender-Smartphone-2404147.html', | |
17 | 'md5': 'ffed432483e922e88545ad9f2f15d30e', | |
18 | 'info_dict': { | |
19 | 'id': '2404147', | |
20 | 'ext': 'mp4', | |
21 | 'title': "Podcast: c't uplink 3.3 – Owncloud / Tastaturen / Peilsender Smartphone", | |
22 | 'format_id': 'mp4_720p', | |
23 | 'timestamp': 1411812600, | |
24 | 'upload_date': '20140927', | |
25 | 'description': 'md5:c934cbfb326c669c2bcabcbe3d3fcd20', | |
26 | 'thumbnail': r're:^https?://.*/gallery/$', | |
27 | } | |
28 | }, { | |
29 | 'url': 'http://www.heise.de/ct/artikel/c-t-uplink-3-3-Owncloud-Tastaturen-Peilsender-Smartphone-2403911.html', | |
30 | 'only_matching': True, | |
31 | }, { | |
32 | 'url': 'http://www.heise.de/newsticker/meldung/c-t-uplink-Owncloud-Tastaturen-Peilsender-Smartphone-2404251.html?wt_mc=rss.ho.beitrag.atom', | |
33 | 'only_matching': True, | |
34 | }, { | |
35 | 'url': 'http://www.heise.de/ct/ausgabe/2016-12-Spiele-3214137.html', | |
36 | 'only_matching': True, | |
37 | }] | |
0155549d | 38 | |
0155549d | 39 | def _real_extract(self, url): |
5a8b7755 | 40 | video_id = self._match_id(url) |
5a8b7755 | 41 | webpage = self._download_webpage(url, video_id) |
ecfe6234 PH |
42 | |
43 | container_id = self._search_regex( | |
bad4ccdb | 44 | r'<div class="videoplayerjw"[^>]+data-container="([0-9]+)"', |
ecfe6234 PH |
45 | webpage, 'container ID') |
46 | sequenz_id = self._search_regex( | |
bad4ccdb | 47 | r'<div class="videoplayerjw"[^>]+data-sequenz="([0-9]+)"', |
ecfe6234 | 48 | webpage, 'sequenz ID') |
0155549d | 49 | |
db76c30c TG |
50 | title = self._html_search_meta('fulltitle', webpage, default=None) |
51 | if not title or title == "c't": | |
52 | title = self._search_regex( | |
bad4ccdb S |
53 | r'<div[^>]+class="videoplayerjw"[^>]+data-title="([^"]+)"', |
54 | webpage, 'title') | |
db76c30c | 55 | |
bad4ccdb S |
56 | doc = self._download_xml( |
57 | 'http://www.heise.de/videout/feed', video_id, query={ | |
58 | 'container': container_id, | |
59 | 'sequenz': sequenz_id, | |
60 | }) | |
0155549d M |
61 | |
62 | formats = [] | |
ecfe6234 PH |
63 | for source_node in doc.findall('.//{http://rss.jwpcdn.com/}source'): |
64 | label = source_node.attrib['label'] | |
65 | height = int_or_none(self._search_regex( | |
66 | r'^(.*?_)?([0-9]+)p$', label, 'height', default=None)) | |
711ede6e PH |
67 | video_url = source_node.attrib['file'] |
68 | ext = determine_ext(video_url, '') | |
ecfe6234 | 69 | formats.append({ |
711ede6e | 70 | 'url': video_url, |
ecfe6234 | 71 | 'format_note': label, |
711ede6e | 72 | 'format_id': '%s_%s' % (ext, label), |
ecfe6234 PH |
73 | 'height': height, |
74 | }) | |
0155549d | 75 | self._sort_formats(formats) |
0155549d | 76 | |
bad4ccdb S |
77 | description = self._og_search_description( |
78 | webpage, default=None) or self._html_search_meta( | |
79 | 'description', webpage) | |
80 | ||
81 | return { | |
82 | 'id': video_id, | |
83 | 'title': title, | |
84 | 'description': description, | |
85 | 'thumbnail': (xpath_text(doc, './/{http://rss.jwpcdn.com/}image') or | |
86 | self._og_search_thumbnail(webpage)), | |
87 | 'timestamp': parse_iso8601( | |
88 | self._html_search_meta('date', webpage)), | |
89 | 'formats': formats, | |
90 | } |