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