Skip to content

Commit

Permalink
バージョンアップ v4.0.2
Browse files Browse the repository at this point in the history
  • Loading branch information
okaits committed Jun 21, 2024
2 parents 286d043 + 6e63adb commit 9d33cd0
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 2 deletions.
2 changes: 1 addition & 1 deletion nicovideo/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
""" nicovideo.py: nicovideo API wrapper for Python3. """
from . import video, errors, user, apirawdicts

__version__ = "4.0.1"
__version__ = "4.0.2"
__all__ = ["video", "user", "errors", "apirawdicts"]
23 changes: 23 additions & 0 deletions nicovideo/video.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ class APIResponse():
description (str): 動画説明欄
duration (str): 動画の長さ
upload_date (datetime.datetime): 動画の投稿時間
thumbnail (dict[typing.Literal["large", "middle", "ogp", "player", "small"], str]): サムネイル
counters (dict[typing.Literal["comment", "like", "mylist", "view"], str]): 各種カウンタ
genre (dict[typing.Literal["label", "key"], str]): 動画ジャンル
"""
__slots__ = ("nicovideo_id", "title", "update", "description",
"duration", "upload_date", "_rawdict")
Expand All @@ -38,6 +41,9 @@ class APIResponse():
description: str
duration: int
upload_date: datetime.datetime
thumbnails: dict[typing.Literal["large", "middle", "ogp", "player", "small"], str]
counters: dict[typing.Literal["comment", "like", "mylist", "view"], str]
genre: dict[typing.Literal["label", "key"], str]

def __init__(self, video_id: str):
"""
Expand Down Expand Up @@ -77,6 +83,23 @@ def __init__(self, video_id: str):
super().__setattr__("upload_date", datetime.datetime.fromisoformat(
self._rawdict["video"]["registeredAt"]
))
super().__setattr__("thumbnail", {
"large": self._rawdict["video"]["thumbnail"]["largeUrl"],
"middle": self._rawdict["video"]["thumbnail"]["middleUrl"],
"ogp": self._rawdict["video"]["thumbnail"]["ogp"],
"player": self._rawdict["video"]["thumbnail"]["player"],
"small": self._rawdict["video"]["thumbnail"]["url"]
})
super().__setattr__("counters", {
"comment": self._rawdict["video"]["count"]["comment"],
"like": self._rawdict["video"]["count"]["like"],
"mylist": self._rawdict["video"]["count"]["mylist"],
"view": self._rawdict["video"]["count"]["view"]
})
super().__setattr__("genre", {
"label": self._rawdict["genre"]["label"],
"key": self._rawdict["genre"]["key"]
})

@property
def uploader(self) -> user.APIResponse:
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "nicovideo.py"
version = "4.0.1"
version = "4.0.2"
description = "ニコニコ動画のAPIを使用して、動画や投稿者などの情報を取得するライブラリです。"
license = "MIT"
authors = ["okaits7534 <[email protected]>"]
Expand Down

0 comments on commit 9d33cd0

Please sign in to comment.