]> jfr.im git - yt-dlp.git/blame - youtube_dl/extractor/faz.py
[Makefile] iQiyi login test requires network
[yt-dlp.git] / youtube_dl / extractor / faz.py
CommitLineData
63da13e8 1# encoding: utf-8
526b276f 2from __future__ import unicode_literals
63da13e8
JMF
3
4from .common import InfoExtractor
ecbccea7 5from ..utils import (
6 xpath_element,
7 xpath_text,
8 int_or_none,
9)
63da13e8
JMF
10
11
12class FazIE(InfoExtractor):
526b276f 13 IE_NAME = 'faz.net'
255f5694 14 _VALID_URL = r'https?://(?:www\.)?faz\.net/(?:[^/]+/)*.*?-(?P<id>\d+)\.html'
63da13e8 15
255f5694 16 _TESTS = [{
526b276f
PH
17 'url': 'http://www.faz.net/multimedia/videos/stockholm-chemie-nobelpreis-fuer-drei-amerikanische-forscher-12610585.html',
18 'info_dict': {
19 'id': '12610585',
20 'ext': 'mp4',
21 'title': 'Stockholm: Chemie-Nobelpreis für drei amerikanische Forscher',
22 'description': 'md5:1453fbf9a0d041d985a47306192ea253',
63da13e8 23 },
255f5694
S
24 }, {
25 'url': 'http://www.faz.net/aktuell/politik/berlin-gabriel-besteht-zerreissprobe-ueber-datenspeicherung-13659345.html',
26 'only_matching': True,
27 }, {
28 'url': 'http://www.faz.net/berlin-gabriel-besteht-zerreissprobe-ueber-datenspeicherung-13659345.html',
29 'only_matching': True,
30 }, {
31 'url': 'http://www.faz.net/-13659345.html',
32 'only_matching': True,
33 }, {
34 'url': 'http://www.faz.net/aktuell/politik/-13659345.html',
35 'only_matching': True,
36 }, {
37 'url': 'http://www.faz.net/foobarblafasel-13659345.html',
38 'only_matching': True,
39 }]
63da13e8
JMF
40
41 def _real_extract(self, url):
526b276f
PH
42 video_id = self._match_id(url)
43
63da13e8 44 webpage = self._download_webpage(url, video_id)
ecbccea7 45 description = self._og_search_description(webpage)
526b276f 46 config_xml_url = self._search_regex(
ecbccea7 47 r'videoXMLURL\s*=\s*"([^"]+)', webpage, 'config xml url')
526b276f
PH
48 config = self._download_xml(
49 config_xml_url, video_id, 'Downloading config xml')
63da13e8 50
ecbccea7 51 encodings = xpath_element(config, 'ENCODINGS', 'encodings', True)
63da13e8 52 formats = []
526b276f 53 for pref, code in enumerate(['LOW', 'HIGH', 'HQ']):
ecbccea7 54 encoding = xpath_element(encodings, code)
55 if encoding:
56 encoding_url = xpath_text(encoding, 'FILENAME')
57 if encoding_url:
58 formats.append({
59 'url': encoding_url,
60 'format_id': code.lower(),
61 'quality': pref,
62 'tbr': int_or_none(xpath_text(encoding, 'AVERAGEBITRATE')),
63 })
526b276f 64 self._sort_formats(formats)
63da13e8 65
fb7abb31 66 return {
63da13e8
JMF
67 'id': video_id,
68 'title': self._og_search_title(webpage),
69 'formats': formats,
ecbccea7 70 'description': description.strip() if description else None,
71 'thumbnail': xpath_text(config, 'STILL/STILL_BIG'),
72 'duration': int_or_none(xpath_text(config, 'DURATION')),
63da13e8 73 }