Fix videoinfo.py

A bit ugly, but I couldn't solve it any other way. I'm bad with regex.
This commit is contained in:
Etian Daniel Alavardo Mtz
2020-08-20 22:29:59 -05:00
committed by GitHub
parent 78373bf45c
commit 96474f10c6

View File

@@ -7,7 +7,7 @@ from ..util.extract_video_id import extract_video_id
headers = config.headers headers = config.headers
pattern = re.compile(r"yt\.setConfig\({'PLAYER_CONFIG': ({.*})}\);") pattern = re.compile(r"'PLAYER_CONFIG': ({.*}}})")
item_channel_id = [ item_channel_id = [
"videoDetails", "videoDetails",
@@ -91,7 +91,8 @@ class VideoInfo:
def _parse(self, text): def _parse(self, text):
result = re.search(pattern, 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) response = self._get_item(res, item_response)
if response is None: if response is None:
self._check_video_is_private(res.get("args")) self._check_video_is_private(res.get("args"))