faz.py 2.4 KB

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