0
0
Fork 0
mirror of https://github.com/yt-dlp/yt-dlp.git synced 2024-11-30 03:33:02 +00:00
yt-dlp/youtube_dl/extractor/karaoketv.py

41 lines
1.2 KiB
Python
Raw Normal View History

2014-09-29 18:58:42 +00:00
# coding: utf-8
from __future__ import unicode_literals
from .common import InfoExtractor
from ..compat import compat_urllib_parse_unquote_plus
2015-01-10 17:03:36 +00:00
from ..utils import (
js_to_json,
)
2014-09-29 18:58:42 +00:00
class KaraoketvIE(InfoExtractor):
_VALID_URL = r'http://karaoketv\.co\.il/\?container=songs&id=(?P<id>[0-9]+)'
_TEST = {
'url': 'http://karaoketv.co.il/?container=songs&id=171568',
'info_dict': {
'id': '171568',
'ext': 'mp4',
'title': 'אל העולם שלך - רותם כהן - שרים קריוקי',
}
}
def _real_extract(self, url):
2015-01-10 17:03:36 +00:00
video_id = self._match_id(url)
2014-09-29 18:58:42 +00:00
webpage = self._download_webpage(url, video_id)
2015-01-10 17:03:36 +00:00
page_video_url = self._og_search_video_url(webpage, video_id)
config_json = compat_urllib_parse_unquote_plus(self._search_regex(
2015-01-10 17:03:36 +00:00
r'config=(.*)', page_video_url, 'configuration'))
2014-09-29 18:58:42 +00:00
2015-01-10 17:03:36 +00:00
urls_info_json = self._download_json(
config_json, video_id, 'Downloading configuration',
transform_source=js_to_json)
2014-09-29 18:58:42 +00:00
url = urls_info_json['playlist'][0]['url']
return {
'id': video_id,
'title': self._og_search_title(webpage),
'url': url,
2015-01-10 17:03:36 +00:00
}