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.

55 lines
1.6 KiB

10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
  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. 'thumbnail': 're:^https?://.*\.jpg$',
  20. },
  21. }
  22. def _real_extract(self, url):
  23. episode = self._match_id(url)
  24. webpage = self._download_webpage(
  25. 'http://fernsehkritik.tv/folge-%s/play' % episode, episode)
  26. title = clean_html(self._html_search_regex(
  27. '<h3>([^<]+)</h3>', webpage, 'title'))
  28. matches = re.search(
  29. r'(?s)<video(?:(?!poster)[^>])+(?:poster="([^"]+)")?[^>]*>(.*)</video>',
  30. webpage)
  31. if matches is None:
  32. raise ExtractorError('Unable to extract the video')
  33. poster, sources = matches.groups()
  34. if poster is None:
  35. self.report_warning('unable to extract thumbnail')
  36. urls = re.findall(r'<source[^>]+src="([^"]+)"', sources)
  37. formats = [{
  38. 'url': furl,
  39. 'format_id': determine_ext(furl),
  40. } for furl in urls]
  41. return {
  42. 'id': episode,
  43. 'title': title,
  44. 'formats': formats,
  45. 'thumbnail': poster,
  46. }