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.

78 lines
2.7 KiB

  1. import re
  2. import random
  3. import json
  4. from .common import InfoExtractor
  5. from ..utils import (
  6. determine_ext,
  7. get_element_by_id,
  8. clean_html,
  9. )
  10. class FKTVIE(InfoExtractor):
  11. IE_NAME = u'fernsehkritik.tv'
  12. _VALID_URL = r'(?:http://)?(?:www\.)?fernsehkritik\.tv/folge-(?P<ep>[0-9]+)(?:/.*)?'
  13. _TEST = {
  14. u'url': u'http://fernsehkritik.tv/folge-1',
  15. u'file': u'00011.flv',
  16. u'info_dict': {
  17. u'title': u'Folge 1 vom 10. April 2007',
  18. u'description': u'md5:fb4818139c7cfe6907d4b83412a6864f',
  19. },
  20. }
  21. def _real_extract(self, url):
  22. mobj = re.match(self._VALID_URL, url)
  23. episode = int(mobj.group('ep'))
  24. server = random.randint(2, 4)
  25. video_thumbnail = 'http://fernsehkritik.tv/images/magazin/folge%d.jpg' % episode
  26. start_webpage = self._download_webpage('http://fernsehkritik.tv/folge-%d/Start' % episode,
  27. episode)
  28. playlist = self._search_regex(r'playlist = (\[.*?\]);', start_webpage,
  29. u'playlist', flags=re.DOTALL)
  30. files = json.loads(re.sub('{[^{}]*?}', '{}', playlist))
  31. # TODO: return a single multipart video
  32. videos = []
  33. for i, _ in enumerate(files, 1):
  34. video_id = '%04d%d' % (episode, i)
  35. video_url = 'http://dl%d.fernsehkritik.tv/fernsehkritik%d%s.flv' % (server, episode, '' if i == 1 else '-%d' % i)
  36. videos.append({
  37. 'id': video_id,
  38. 'url': video_url,
  39. 'ext': determine_ext(video_url),
  40. 'title': clean_html(get_element_by_id('eptitle', start_webpage)),
  41. 'description': clean_html(get_element_by_id('contentlist', start_webpage)),
  42. 'thumbnail': video_thumbnail
  43. })
  44. return videos
  45. class FKTVPosteckeIE(InfoExtractor):
  46. IE_NAME = u'fernsehkritik.tv:postecke'
  47. _VALID_URL = r'(?:http://)?(?:www\.)?fernsehkritik\.tv/inline-video/postecke\.php\?(.*&)?ep=(?P<ep>[0-9]+)(&|$)'
  48. _TEST = {
  49. u'url': u'http://fernsehkritik.tv/inline-video/postecke.php?iframe=true&width=625&height=440&ep=120',
  50. u'file': u'0120.flv',
  51. u'md5': u'262f0adbac80317412f7e57b4808e5c4',
  52. u'info_dict': {
  53. u"title": u"Postecke 120"
  54. }
  55. }
  56. def _real_extract(self, url):
  57. mobj = re.match(self._VALID_URL, url)
  58. episode = int(mobj.group('ep'))
  59. server = random.randint(2, 4)
  60. video_id = '%04d' % episode
  61. video_url = 'http://dl%d.fernsehkritik.tv/postecke/postecke%d.flv' % (server, episode)
  62. video_title = 'Postecke %d' % episode
  63. return {
  64. 'id': video_id,
  65. 'url': video_url,
  66. 'ext': determine_ext(video_url),
  67. 'title': video_title,
  68. }