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