about summary refs log tree commit diff
diff options
context:
space:
mode:
authorPhilipp Hagemeister <phihag@phihag.de>2015-01-10 18:03:36 +0100
committerPhilipp Hagemeister <phihag@phihag.de>2015-01-10 18:03:36 +0100
commitc80ede5f1380ce49cf8ad26d84e4eb1aa2d7c004 (patch)
tree65b66447d08e56d4a3ee8f48caa911614a9ce822
parentbc694039e47cc871c98abacdf1c0a2e5a257a8a4 (diff)
downloadyoutube-dl-c80ede5f1380ce49cf8ad26d84e4eb1aa2d7c004.tar.gz
youtube-dl-c80ede5f1380ce49cf8ad26d84e4eb1aa2d7c004.tar.xz
youtube-dl-c80ede5f1380ce49cf8ad26d84e4eb1aa2d7c004.zip
[karaoketv] Simplify (#3853)
-rw-r--r--youtube_dl/extractor/karaoketv.py32
1 files changed, 13 insertions, 19 deletions
diff --git a/youtube_dl/extractor/karaoketv.py b/youtube_dl/extractor/karaoketv.py
index 4d50308cc..4856200d8 100644
--- a/youtube_dl/extractor/karaoketv.py
+++ b/youtube_dl/extractor/karaoketv.py
@@ -1,12 +1,12 @@
 # coding: utf-8
 from __future__ import unicode_literals
 
-import re
-import json
-import sys
-
 from .common import InfoExtractor
-from ..utils import compat_urllib_parse, ExtractorError
+from ..compat import compat_urllib_parse
+from ..utils import (
+    ExtractorError,
+    js_to_json,
+)
 
 
 class KaraoketvIE(InfoExtractor):
@@ -21,22 +21,16 @@ class KaraoketvIE(InfoExtractor):
     }
 
     def _real_extract(self, url):
-
-        # BUG: SSL23_GET_SERVER_HELLO:unknown protocol 
-        if sys.hexversion < 0x03000000:
-            raise ExtractorError("Only python 3 supported.\n")
-
-        mobj = re.match(self._VALID_URL, url)
-        
-        video_id = mobj.group('id')
-
+        video_id = self._match_id(url)
         webpage = self._download_webpage(url, video_id)
 
-        settings_json = compat_urllib_parse.unquote_plus(self._search_regex(r'config=(.*)', self._og_search_video_url(webpage ,video_id), ''))
-        
-        urls_info_webpage = self._download_webpage(settings_json, 'Downloading settings json')
+        page_video_url = self._og_search_video_url(webpage, video_id)
+        config_json = compat_urllib_parse.unquote_plus(self._search_regex(
+            r'config=(.*)', page_video_url, 'configuration'))
 
-        urls_info_json = json.loads(urls_info_webpage.replace('\'', '"'))
+        urls_info_json = self._download_json(
+            config_json, video_id, 'Downloading configuration',
+            transform_source=js_to_json)
 
         url = urls_info_json['playlist'][0]['url']
 
@@ -44,4 +38,4 @@ class KaraoketvIE(InfoExtractor):
             'id': video_id,
             'title': self._og_search_title(webpage),
             'url': url,
-        }
\ No newline at end of file
+        }