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.

64 lines
2.3 KiB

  1. # coding: utf-8
  2. from __future__ import unicode_literals
  3. from .common import InfoExtractor
  4. class KaraoketvIE(InfoExtractor):
  5. _VALID_URL = r'https?://(?:www\.)?karaoketv\.co\.il/[^/]+/(?P<id>\d+)'
  6. _TEST = {
  7. 'url': 'http://www.karaoketv.co.il/%D7%A9%D7%99%D7%A8%D7%99_%D7%A7%D7%A8%D7%99%D7%95%D7%A7%D7%99/58356/%D7%90%D7%99%D7%96%D7%95%D7%9F',
  8. 'info_dict': {
  9. 'id': '58356',
  10. 'ext': 'flv',
  11. 'title': 'קריוקי של איזון',
  12. },
  13. 'params': {
  14. # rtmp download
  15. 'skip_download': True,
  16. }
  17. }
  18. def _real_extract(self, url):
  19. video_id = self._match_id(url)
  20. webpage = self._download_webpage(url, video_id)
  21. api_page_url = self._search_regex(
  22. r'<iframe[^>]+src=(["\'])(?P<url>https?://www\.karaoke\.co\.il/api_play\.php\?.+?)\1',
  23. webpage, 'API play URL', group='url')
  24. api_page = self._download_webpage(api_page_url, video_id)
  25. video_cdn_url = self._search_regex(
  26. r'<iframe[^>]+src=(["\'])(?P<url>https?://www\.video-cdn\.com/embed/iframe/.+?)\1',
  27. api_page, 'video cdn URL', group='url')
  28. video_cdn = self._download_webpage(video_cdn_url, video_id)
  29. play_path = self._parse_json(
  30. self._search_regex(
  31. r'var\s+options\s*=\s*({.+?});', video_cdn, 'options'),
  32. video_id)['clip']['url']
  33. settings = self._parse_json(
  34. self._search_regex(
  35. r'var\s+settings\s*=\s*({.+?});', video_cdn, 'servers', default='{}'),
  36. video_id, fatal=False) or {}
  37. servers = settings.get('servers')
  38. if not servers or not isinstance(servers, list):
  39. servers = ('wowzail.video-cdn.com:80/vodcdn', )
  40. formats = [{
  41. 'url': 'rtmp://%s' % server if not server.startswith('rtmp') else server,
  42. 'play_path': play_path,
  43. 'app': 'vodcdn',
  44. 'page_url': video_cdn_url,
  45. 'player_url': 'http://www.video-cdn.com/assets/flowplayer/flowplayer.commercial-3.2.18.swf',
  46. 'rtmp_real_time': True,
  47. 'ext': 'flv',
  48. } for server in servers]
  49. return {
  50. 'id': video_id,
  51. 'title': self._og_search_title(webpage),
  52. 'formats': formats,
  53. }