]> Raphaël G. Git Repositories - youtubedl/blob - youtube_dl/extractor/bild.py
debian/changelog: Initiate a new release.
[youtubedl] / youtube_dl / extractor / bild.py
1 # coding: utf-8
2 from __future__ import unicode_literals
3
4 from .common import InfoExtractor
5 from ..utils import (
6 int_or_none,
7 fix_xml_ampersands,
8 )
9
10
11 class BildIE(InfoExtractor):
12 _VALID_URL = r'https?://(?:www\.)?bild\.de/(?:[^/]+/)+(?P<display_id>[^/]+)-(?P<id>\d+)(?:,auto=true)?\.bild\.html'
13 IE_DESC = 'Bild.de'
14 _TEST = {
15 'url': 'http://www.bild.de/video/clip/apple-ipad-air/das-koennen-die-neuen-ipads-38184146.bild.html',
16 'md5': 'dd495cbd99f2413502a1713a1156ac8a',
17 'info_dict': {
18 'id': '38184146',
19 'ext': 'mp4',
20 'title': 'BILD hat sie getestet',
21 'thumbnail': 're:^https?://.*\.jpg$',
22 'duration': 196,
23 'description': 'Mit dem iPad Air 2 und dem iPad Mini 3 hat Apple zwei neue Tablet-Modelle präsentiert. BILD-Reporter Sven Stein durfte die Geräte bereits testen. ',
24 }
25 }
26
27 def _real_extract(self, url):
28 video_id = self._match_id(url)
29
30 xml_url = url.split(".bild.html")[0] + ",view=xml.bild.xml"
31 doc = self._download_xml(xml_url, video_id, transform_source=fix_xml_ampersands)
32
33 duration = int_or_none(doc.attrib.get('duration'), scale=1000)
34
35 return {
36 'id': video_id,
37 'title': doc.attrib['ueberschrift'],
38 'description': doc.attrib.get('text'),
39 'url': doc.attrib['src'],
40 'thumbnail': doc.attrib.get('img'),
41 'duration': duration,
42 }