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.

58 lines
2.0 KiB

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