You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

73 lines
2.7 KiB

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