]> jfr.im git - yt-dlp.git/blame - youtube_dl/extractor/bild.py
[bild] extract info from json request
[yt-dlp.git] / youtube_dl / extractor / bild.py
CommitLineData
5f6a1245 1# coding: utf-8
b5a14350
PH
2from __future__ import unicode_literals
3
4from .common import InfoExtractor
c09593c0 5from ..utils import (
bc08873c 6 int_or_none,
70cb4d51 7 unescapeHTML,
c09593c0 8)
b5a14350
PH
9
10
11class 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',
70cb4d51 20 'title': 'Das können die neuen iPads ',
f22834a3 21 'thumbnail': 're:^https?://.*\.jpg$',
b5a14350
PH
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
70cb4d51 30 video_data = self._download_json(url.split(".bild.html")[0] + ",view=json.bild.html", video_id)
b5a14350
PH
31
32 return {
33 'id': video_id,
70cb4d51 34 'title': unescapeHTML(video_data['title']),
35 'description': unescapeHTML(video_data.get('description')),
36 'url': video_data['clipList'][0]['srces'][0]['src'],
37 'thumbnail': video_data.get('poster'),
38 'duration': int_or_none(video_data.get('durationSec')),
b5a14350 39 }