]> Raphaël G. Git Repositories - youtubedl/blob - youtube_dl/extractor/karaoketv.py
e3b43ff8dbfec5e065aa069a0fb140dcfb5822c9
[youtubedl] / youtube_dl / extractor / karaoketv.py
1 # coding: utf-8
2 from __future__ import unicode_literals
3
4 from .common import InfoExtractor
5 from ..compat import compat_urllib_parse
6 from ..utils import (
7 js_to_json,
8 )
9
10
11 class KaraoketvIE(InfoExtractor):
12 _VALID_URL = r'http://karaoketv\.co\.il/\?container=songs&id=(?P<id>[0-9]+)'
13 _TEST = {
14 'url': 'http://karaoketv.co.il/?container=songs&id=171568',
15 'info_dict': {
16 'id': '171568',
17 'ext': 'mp4',
18 'title': 'אל העולם שלך - רותם כהן - שרים קריוקי',
19 }
20 }
21
22 def _real_extract(self, url):
23 video_id = self._match_id(url)
24 webpage = self._download_webpage(url, video_id)
25
26 page_video_url = self._og_search_video_url(webpage, video_id)
27 config_json = compat_urllib_parse.unquote_plus(self._search_regex(
28 r'config=(.*)', page_video_url, 'configuration'))
29
30 urls_info_json = self._download_json(
31 config_json, video_id, 'Downloading configuration',
32 transform_source=js_to_json)
33
34 url = urls_info_json['playlist'][0]['url']
35
36 return {
37 'id': video_id,
38 'title': self._og_search_title(webpage),
39 'url': url,
40 }