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.

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