From 96474f10c6fc421f8091d02648504592fe0f469a Mon Sep 17 00:00:00 2001 From: Etian Daniel Alavardo Mtz <42478705+EtianAM@users.noreply.github.com> Date: Thu, 20 Aug 2020 22:29:59 -0500 Subject: [PATCH 1/2] Fix videoinfo.py A bit ugly, but I couldn't solve it any other way. I'm bad with regex. --- pytchat/tool/videoinfo.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pytchat/tool/videoinfo.py b/pytchat/tool/videoinfo.py index a87e0c4..15bac14 100644 --- a/pytchat/tool/videoinfo.py +++ b/pytchat/tool/videoinfo.py @@ -7,7 +7,7 @@ from ..util.extract_video_id import extract_video_id headers = config.headers -pattern = re.compile(r"yt\.setConfig\({'PLAYER_CONFIG': ({.*})}\);") +pattern = re.compile(r"'PLAYER_CONFIG': ({.*}}})") item_channel_id = [ "videoDetails", @@ -91,7 +91,8 @@ class VideoInfo: def _parse(self, text): result = re.search(pattern, text) - res = json.loads(result.group(1)) + result = result.group(1)[:-1] + res = json.loads(result) response = self._get_item(res, item_response) if response is None: self._check_video_is_private(res.get("args")) From 89b51c420f42a88a922fab2342008e690cd92a1e Mon Sep 17 00:00:00 2001 From: Etian Daniel Alavardo Mtz <42478705+EtianAM@users.noreply.github.com> Date: Thu, 20 Aug 2020 22:39:32 -0500 Subject: [PATCH 2/2] Avoid changing the type of result. However, if this argument is used elsewhere in the code it should be corrected. --- pytchat/tool/videoinfo.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/pytchat/tool/videoinfo.py b/pytchat/tool/videoinfo.py index 15bac14..7b37771 100644 --- a/pytchat/tool/videoinfo.py +++ b/pytchat/tool/videoinfo.py @@ -91,8 +91,7 @@ class VideoInfo: def _parse(self, text): result = re.search(pattern, text) - result = result.group(1)[:-1] - res = json.loads(result) + res = json.loads(result.group(1)[:-1]) response = self._get_item(res, item_response) if response is None: self._check_video_is_private(res.get("args"))