From 48c5663c5f7dd9ecc4720f7c1522627665197939 Mon Sep 17 00:00:00 2001 From: Toan Nguyen Date: Thu, 22 Oct 2020 19:15:05 +0700 Subject: [PATCH 1/2] [afreecatv] Fix typo (#26970) --- youtube_dl/extractor/afreecatv.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/youtube_dl/extractor/afreecatv.py b/youtube_dl/extractor/afreecatv.py index 6275e5209..b56abb1e6 100644 --- a/youtube_dl/extractor/afreecatv.py +++ b/youtube_dl/extractor/afreecatv.py @@ -275,7 +275,7 @@ class AfreecaTVIE(InfoExtractor): video_element = video_xml.findall(compat_xpath('./track/video'))[-1] if video_element is None or video_element.text is None: raise ExtractorError( - 'Video %s video does not exist' % video_id, expected=True) + 'Video %s does not exist' % video_id, expected=True) video_url = video_element.text.strip() From 1baea2d4f33c9867eb41cd046c3215d109f233e0 Mon Sep 17 00:00:00 2001 From: Florian Staudacher Date: Thu, 22 Oct 2020 19:16:49 +0200 Subject: [PATCH 2/2] handle different syntax for boolean values in js_to_json --- test/test_utils.py | 6 ++++++ youtube_dl/utils.py | 8 +++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/test/test_utils.py b/test/test_utils.py index c2d1e4fb1..878ac6268 100644 --- a/test/test_utils.py +++ b/test/test_utils.py @@ -1000,6 +1000,12 @@ class TestUtil(unittest.TestCase): on = js_to_json('{ "040": "040" }') self.assertEqual(json.loads(on), {'040': '040'}) + on = js_to_json('{ "defaultQuality":!0}') + self.assertEqual(json.loads(on), {'defaultQuality': 'true'}) + + on = js_to_json('{ "onFullscreen":!1}') + self.assertEqual(json.loads(on), {'onFullscreen': 'false'}) + def test_js_to_json_malformed(self): self.assertEqual(js_to_json('42a1'), '42"a1"') self.assertEqual(js_to_json('42a-1'), '42"a"-1') diff --git a/youtube_dl/utils.py b/youtube_dl/utils.py index 737e2810e..2abd807b7 100644 --- a/youtube_dl/utils.py +++ b/youtube_dl/utils.py @@ -4081,6 +4081,11 @@ def js_to_json(code): elif v.startswith('/*') or v.startswith('//') or v == ',': return "" + if v == "!0": + v = 'true' + if v == "!1": + v = 'false' + if v[0] in ("'", '"'): v = re.sub(r'(?s)\\.|"', lambda m: { '"': '\\"', @@ -4103,7 +4108,8 @@ def js_to_json(code): {comment}|,(?={skip}[\]}}])| (?:(?