]> Raphaël G. Git Repositories - youtubedl/blob - youtube_dl/extractor/faz.py
Add note about mplayer2 and backporters.
[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/(?:[^/]+/)*.*?-(?P<id>\d+)\.html'
10
11 _TESTS = [{
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 'url': 'http://www.faz.net/aktuell/politik/berlin-gabriel-besteht-zerreissprobe-ueber-datenspeicherung-13659345.html',
21 'only_matching': True,
22 }, {
23 'url': 'http://www.faz.net/berlin-gabriel-besteht-zerreissprobe-ueber-datenspeicherung-13659345.html',
24 'only_matching': True,
25 }, {
26 'url': 'http://www.faz.net/-13659345.html',
27 'only_matching': True,
28 }, {
29 'url': 'http://www.faz.net/aktuell/politik/-13659345.html',
30 'only_matching': True,
31 }, {
32 'url': 'http://www.faz.net/foobarblafasel-13659345.html',
33 'only_matching': True,
34 }]
35
36 def _real_extract(self, url):
37 video_id = self._match_id(url)
38
39 webpage = self._download_webpage(url, video_id)
40 config_xml_url = self._search_regex(
41 r'writeFLV\(\'(.+?)\',', webpage, 'config xml url')
42 config = self._download_xml(
43 config_xml_url, video_id, 'Downloading config xml')
44
45 encodings = config.find('ENCODINGS')
46 formats = []
47 for pref, code in enumerate(['LOW', 'HIGH', 'HQ']):
48 encoding = encodings.find(code)
49 if encoding is None:
50 continue
51 encoding_url = encoding.find('FILENAME').text
52 formats.append({
53 'url': encoding_url,
54 'format_id': code.lower(),
55 'quality': pref,
56 })
57 self._sort_formats(formats)
58
59 descr = self._html_search_regex(
60 r'<p class="Content Copy">(.*?)</p>', webpage, 'description', fatal=False)
61 return {
62 'id': video_id,
63 'title': self._og_search_title(webpage),
64 'formats': formats,
65 'description': descr,
66 'thumbnail': config.find('STILL/STILL_BIG').text,
67 }