Compare commits
9 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
69c60d085f | ||
|
|
9e3f18c20b | ||
|
|
9d08e5cff6 | ||
|
|
5640c45af6 | ||
|
|
b02a2badf7 | ||
|
|
3aee1b276f | ||
|
|
73026b52af | ||
|
|
c88abc600d | ||
|
|
679f2e9bb8 |
50
README.md
50
README.md
@@ -13,11 +13,8 @@ info.get_title()
|
|||||||
info.get_channel_id()
|
info.get_channel_id()
|
||||||
```
|
```
|
||||||
## Function
|
## Function
|
||||||
### get_info(video_id, session)
|
|
||||||
|
|
||||||
Returns
|
### get_info(video_id, session)
|
||||||
-------
|
|
||||||
+ VideoInfo object.
|
|
||||||
|
|
||||||
Parameters
|
Parameters
|
||||||
----------
|
----------
|
||||||
@@ -25,37 +22,42 @@ Parameters
|
|||||||
|
|
||||||
- session : session object of requests.
|
- session : session object of requests.
|
||||||
|
|
||||||
|
Returns
|
||||||
|
-------
|
||||||
|
+ VideoInfo object.
|
||||||
|
|
||||||
|
|
||||||
## Attributes of VideoInfo object
|
## Attributes of VideoInfo object
|
||||||
### get_duration()
|
|
||||||
- 動画の長さ(アーカイブのみ。ライブ動画または待機画面の場合0)
|
|
||||||
|
|
||||||
### get_title()
|
### get_duration()
|
||||||
- 動画タイトル
|
- 動画の長さ(秒。アーカイブのみ。ライブ動画または待機画面の場合、0が返ります。)
|
||||||
|
|
||||||
### get_title_escaped()
|
### get_title()
|
||||||
- 動画タイトル(絵文字なし。GUIライブラリ等で絵文字が含まれていてエラーが出る場合はこちらを使用してください)
|
- 動画タイトル
|
||||||
|
|
||||||
### get_channel_id()
|
### get_title_escaped()
|
||||||
|
- 動画タイトル(絵文字なし。GUIライブラリ等で絵文字が含まれていてエラーが出る場合はこちらを使用してください)
|
||||||
|
|
||||||
|
### get_channel_id()
|
||||||
- チャンネルID
|
- チャンネルID
|
||||||
|
|
||||||
### get_thumbnail()
|
### get_thumbnail()
|
||||||
- 動画サムネイルURL
|
- 動画サムネイルURL
|
||||||
|
|
||||||
### get_owner_name()
|
### get_owner_name()
|
||||||
- 配信者名
|
- 配信者名
|
||||||
|
|
||||||
### get_owner_name_escaped()
|
### get_owner_name_escaped()
|
||||||
- 配信者名(絵文字なし)
|
- 配信者名(絵文字なし)
|
||||||
|
|
||||||
### get_owner_image()
|
### get_owner_image()
|
||||||
- 配信者プロフィール画像URL
|
- 配信者プロフィール画像URL
|
||||||
|
|
||||||
### get_user_name()
|
### get_user_name()
|
||||||
- 視聴者名
|
- 視聴者名
|
||||||
|
|
||||||
### get_user_name_escaped()
|
### get_user_name_escaped()
|
||||||
- 視聴者名(絵文字なし)
|
- 視聴者名(絵文字なし)
|
||||||
|
|
||||||
### get_user_image()
|
### get_user_image()
|
||||||
- 視聴者プロフィール画像URL
|
- 視聴者プロフィール画像URL
|
||||||
|
|||||||
@@ -1 +1,2 @@
|
|||||||
requests
|
requests
|
||||||
|
emoji
|
||||||
@@ -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.1'
|
__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