]> Raphaël G. Git Repositories - youtubedl/blob - youtube_dl/extractor/faz.py
Prepare for release.
[youtubedl] / youtube_dl / extractor / faz.py
1 # encoding: utf-8
2 from __future__ import unicode_literals
3
4 from .common import InfoExtractor
5
6
7 class FazIE(InfoExtractor):
8 IE_NAME = 'faz.net'
9 _VALID_URL = r'https?://www\.faz\.net/multimedia/videos/.*?-(?P<id>\d+)\.html'
10
11 _TEST = {
12 'url': 'http://www.faz.net/multimedia/videos/stockholm-chemie-nobelpreis-fuer-drei-amerikanische-forscher-12610585.html',
13 'info_dict': {
14 'id': '12610585',
15 'ext': 'mp4',
16 'title': 'Stockholm: Chemie-Nobelpreis für drei amerikanische Forscher',
17 'description': 'md5:1453fbf9a0d041d985a47306192ea253',
18 },
19 }
20
21 def _real_extract(self, url):
22 video_id = self._match_id(url)
23
24 webpage = self._download_webpage(url, video_id)
25 config_xml_url = self._search_regex(
26 r'writeFLV\(\'(.+?)\',', webpage, 'config xml url')
27 config = self._download_xml(
28 config_xml_url, video_id, 'Downloading config xml')
29
30 encodings = config.find('ENCODINGS')
31 formats = []
32 for pref, code in enumerate(['LOW', 'HIGH', 'HQ']):
33 encoding = encodings.find(code)
34 if encoding is None:
35 continue
36 encoding_url = encoding.find('FILENAME').text
37 formats.append({
38 'url': encoding_url,
39 'format_id': code.lower(),
40 'quality': pref,
41 })
42 self._sort_formats(formats)
43
44 descr = self._html_search_regex(
45 r'<p class="Content Copy">(.*?)</p>', webpage, 'description', fatal=False)
46 return {
47 'id': video_id,
48 'title': self._og_search_title(webpage),
49 'formats': formats,
50 'description': descr,
51 'thumbnail': config.find('STILL/STILL_BIG').text,
52 }