1
0
mirror of https://github.com/yt-dlp/yt-dlp.git synced 2024-11-05 10:42:37 +01:00
yt-dlp/youtube_dl/extractor/karaoketv.py

65 lines
2.3 KiB
Python
Raw Normal View History

2014-09-29 20:58:42 +02:00
# coding: utf-8
from __future__ import unicode_literals
from .common import InfoExtractor
class KaraoketvIE(InfoExtractor):
2016-09-08 13:29:05 +02:00
_VALID_URL = r'https?://(?:www\.)?karaoketv\.co\.il/[^/]+/(?P<id>\d+)'
2014-09-29 20:58:42 +02:00
_TEST = {
'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',
2014-09-29 20:58:42 +02:00
'info_dict': {
'id': '58356',
'ext': 'flv',
'title': 'קריוקי של איזון',
2016-04-15 17:26:54 +02:00
},
'params': {
# rtmp download
'skip_download': True,
2014-09-29 20:58:42 +02:00
}
}
def _real_extract(self, url):
2015-01-10 18:03:36 +01:00
video_id = self._match_id(url)
2016-04-15 17:26:54 +02:00
2014-09-29 20:58:42 +02:00
webpage = self._download_webpage(url, video_id)
2016-04-15 17:26:54 +02:00
api_page_url = self._search_regex(
r'<iframe[^>]+src=(["\'])(?P<url>https?://www\.karaoke\.co\.il/api_play\.php\?.+?)\1',
webpage, 'API play URL', group='url')
api_page = self._download_webpage(api_page_url, video_id)
video_cdn_url = self._search_regex(
r'<iframe[^>]+src=(["\'])(?P<url>https?://www\.video-cdn\.com/embed/iframe/.+?)\1',
api_page, 'video cdn URL', group='url')
video_cdn = self._download_webpage(video_cdn_url, video_id)
play_path = self._parse_json(
self._search_regex(
r'var\s+options\s*=\s*({.+?});', video_cdn, 'options'),
video_id)['clip']['url']
2014-09-29 20:58:42 +02:00
2016-04-15 17:26:54 +02:00
settings = self._parse_json(
self._search_regex(
r'var\s+settings\s*=\s*({.+?});', video_cdn, 'servers', default='{}'),
video_id, fatal=False) or {}
servers = settings.get('servers')
if not servers or not isinstance(servers, list):
servers = ('wowzail.video-cdn.com:80/vodcdn', )
formats = [{
'url': 'rtmp://%s' % server if not server.startswith('rtmp') else server,
'play_path': play_path,
'app': 'vodcdn',
'page_url': video_cdn_url,
'player_url': 'http://www.video-cdn.com/assets/flowplayer/flowplayer.commercial-3.2.18.swf',
'rtmp_real_time': True,
'ext': 'flv',
} for server in servers]
2014-09-29 20:58:42 +02:00
return {
'id': video_id,
'title': self._og_search_title(webpage),
2016-04-15 17:26:54 +02:00
'formats': formats,
2015-01-10 18:03:36 +01:00
}