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.

53 lines
1.8 KiB

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