fktv.py 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. from __future__ import unicode_literals
  2. import re
  3. from .common import InfoExtractor
  4. from ..utils import (
  5. clean_html,
  6. determine_ext,
  7. ExtractorError,
  8. )
  9. class FKTVIE(InfoExtractor):
  10. IE_NAME = 'fernsehkritik.tv'
  11. _VALID_URL = r'http://(?:www\.)?fernsehkritik\.tv/folge-(?P<id>[0-9]+)(?:/.*)?'
  12. _TEST = {
  13. 'url': 'http://fernsehkritik.tv/folge-1',
  14. 'md5': '21f0b0c99bce7d5b524eb1b17b1c6d79',
  15. 'info_dict': {
  16. 'id': '1',
  17. 'ext': 'mp4',
  18. 'title': 'Folge 1 vom 10. April 2007',
  19. },
  20. }
  21. def _real_extract(self, url):
  22. episode = self._match_id(url)
  23. webpage = self._download_webpage('http://fernsehkritik.tv/folge-%s/play' % episode, episode)
  24. title = clean_html(self._html_search_regex('<h3>([^<]+)</h3>', webpage, 'title'))
  25. matches = re.search(r'(?s)<video[^>]+poster="([^"]+)"[^>]*>(.*)</video>', webpage)
  26. if matches is None:
  27. raise ExtractorError('Unable to extract the video')
  28. poster, sources = matches.groups()
  29. urls = re.findall(r'<source[^>]+src="([^"]+)"', sources)
  30. formats = [{'url': url, 'format_id': determine_ext(url)} for url in urls]
  31. return {
  32. 'id': episode,
  33. 'title': title,
  34. 'formats': formats,
  35. 'thumbnail': poster,
  36. }