Merge branch 'hotfix/extract_info' into develop
This commit is contained in:
@@ -2,7 +2,7 @@
|
|||||||
Retriever tool for youtube video information.
|
Retriever tool for youtube video information.
|
||||||
"""
|
"""
|
||||||
__copyright__ = 'Copyright (C) 2020 taizan-hokuto'
|
__copyright__ = 'Copyright (C) 2020 taizan-hokuto'
|
||||||
__version__ = '0.0.2'
|
__version__ = '0.0.3'
|
||||||
__license__ = 'MIT'
|
__license__ = 'MIT'
|
||||||
__author__ = 'taizan-hokuto'
|
__author__ = 'taizan-hokuto'
|
||||||
__author_email__ = '55448286+taizan-hokuto@users.noreply.github.com'
|
__author_email__ = '55448286+taizan-hokuto@users.noreply.github.com'
|
||||||
|
|||||||
@@ -7,3 +7,9 @@ class InvalidVideoIdException(Exception):
|
|||||||
|
|
||||||
class UnknownConnectionError(Exception):
|
class UnknownConnectionError(Exception):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class VideoInfoParseException(Exception):
|
||||||
|
'''
|
||||||
|
thrown when failed to parse video info
|
||||||
|
'''
|
||||||
@@ -4,9 +4,9 @@ import json
|
|||||||
import re
|
import re
|
||||||
import requests
|
import requests
|
||||||
from . import util
|
from . import util
|
||||||
from . exceptions import InvalidVideoIdException
|
from . exceptions import InvalidVideoIdException, VideoInfoParseException
|
||||||
|
|
||||||
pattern = re.compile(r"yt\.setConfig\({'PLAYER_CONFIG': ({.*})}\);")
|
pattern = re.compile(r"'PLAYER_CONFIG': ({.*}}})")
|
||||||
|
|
||||||
item_channel_id = [
|
item_channel_id = [
|
||||||
"videoDetails",
|
"videoDetails",
|
||||||
@@ -98,7 +98,10 @@ class VideoInfo:
|
|||||||
|
|
||||||
def _parse(self, text):
|
def _parse(self, text):
|
||||||
result = re.search(pattern, text)
|
result = re.search(pattern, text)
|
||||||
self._res = json.loads(result.group(1))
|
gr = result.group(1)
|
||||||
|
if gr is None:
|
||||||
|
raise VideoInfoParseException("Failed to parse video info.")
|
||||||
|
self._res = json.loads(gr[:-1])
|
||||||
response = self._get_item(self._res, item_response)
|
response = self._get_item(self._res, item_response)
|
||||||
if response is None:
|
if response is None:
|
||||||
self._check_video_is_private(self._res.get("args"))
|
self._check_video_is_private(self._res.get("args"))
|
||||||
|
|||||||
Reference in New Issue
Block a user