Skip to content

Commit

Permalink
chore: update credential attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
Nemo2011 committed Aug 26, 2024
1 parent ca727cd commit 0eafcac
Show file tree
Hide file tree
Showing 24 changed files with 38 additions and 38 deletions.
2 changes: 1 addition & 1 deletion bilibili_api/article.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ def __init__(self, rlid: int, credential: Union[Credential, None] = None):
credential (Credential | None, optional): 凭据类. Defaults to None.
"""
self.__rlid = rlid
self.credential = credential
self.credential: Credential = credential

def get_rlid(self) -> int:
return self.__rlid
Expand Down
4 changes: 2 additions & 2 deletions bilibili_api/ass.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ async def make_ass_file_subtitle(
out: Optional[str] = "test.ass",
lan_name: Optional[str] = "中文(自动生成)",
lan_code: Optional[str] = "ai-zh",
credential: Credential = Credential(),
credential: Optional[Credential] = None,
) -> None:
"""
生成视频字幕文件
Expand All @@ -109,7 +109,7 @@ async def make_ass_file_subtitle(
lan_code (str, optional) : 字幕语言代码,如 ”中文(自动翻译)” 和 ”中文(自动生成)“ 为 "ai-zh"
credential (Credential) : Credential 类. 必须在此处或传入的视频 obj 中传入凭据,两者均存在则优先此处
credential (Credential, optional): Credential 类. 必须在此处或传入的视频 obj 中传入凭据,两者均存在则优先此处
"""
# 目测必须得有 Credential 才能获取字幕
if credential.has_sessdata():
Expand Down
4 changes: 2 additions & 2 deletions bilibili_api/audio.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def __init__(self, auid: int, credential: Union[Credential, None] = None):
credential (Credential | None, optional): 凭据. Defaults to None
"""
self.credential = credential if credential is not None else Credential()
self.credential: Credential = credential if credential is not None else Credential()
self.__auid = auid

def get_auid(self) -> int:
Expand Down Expand Up @@ -111,7 +111,7 @@ def __init__(self, amid: int, credential: Union[Credential, None] = None):
credential (Credential | None, optional): 凭据. Defaults to None.
"""
self.__amid = amid
self.credential = credential if credential is not None else Credential()
self.credential: Credential = credential if credential is not None else Credential()

def get_amid(self) -> int:
return self.__amid
Expand Down
6 changes: 3 additions & 3 deletions bilibili_api/audio_uploader.py
Original file line number Diff line number Diff line change
Expand Up @@ -516,9 +516,9 @@ def __init__(self, path: str, meta: SongMeta, credential: Credential):
credential (Credential): 账号信息
"""
super().__init__()
self.path = path
self.meta = meta
self.credential = credential
self.path: str = path
self.meta: str = meta
self.credential: Credential = credential
self.__upos_file = UposFile(path)

async def _preupload(self) -> dict:
Expand Down
2 changes: 1 addition & 1 deletion bilibili_api/bangumi.py
Original file line number Diff line number Diff line change
Expand Up @@ -1003,7 +1003,7 @@ def __init__(
"""
if media_id == -1 and ssid == -1 and epid == -1:
raise ValueError("需要 Media_id 或 Season_id 或 epid 中的一个 !")
self.credential = credential if credential else Credential()
self.credential: Credential = credential if credential else Credential()
# 处理极端情况
params = {}
self.__ssid = ssid
Expand Down
4 changes: 2 additions & 2 deletions bilibili_api/black_room.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ def __init__(self, black_room_id: int, credential: Union[Credential, None] = Non
credential (Credential | None, optional): 凭据类. Defaults to None.
"""
self.__id = black_room_id
self.credential = credential if credential else Credential()
self.credential: Credential = credential if credential else Credential()

async def get_details(self) -> dict:
"""
Expand Down Expand Up @@ -238,7 +238,7 @@ def __init__(self, case_id: str, credential: Credential):
credential (Credential) : 凭据类
"""
self.case_id = case_id
self.credential = credential
self.credential: Credential = credential

async def get_details(self) -> dict:
"""
Expand Down
2 changes: 1 addition & 1 deletion bilibili_api/channel_series.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ def __init__(
self.is_new = type_.value
self.id_ = id_
self.owner = User(self.__uid, credential=credential)
self.credential = credential
self.credential: Credential = credential
self.meta = None
if not f"{type_.value}-{id_}" in channel_meta_cache.keys():
if self.is_new:
Expand Down
4 changes: 2 additions & 2 deletions bilibili_api/cheese.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def __init__(
raise ValueError("season id 和 ep id 必须选一个")
self.__season_id = season_id
self.__ep_id = ep_id
self.credential = credential if credential else Credential()
self.credential: Credential = credential if credential else Credential()
if self.__season_id == -1:
# self.season_id = str(sync(self.get_meta())["season_id"])
api = API["info"]["meta"]
Expand Down Expand Up @@ -150,7 +150,7 @@ def __init__(self, epid, credential: Union[Credential, None] = None):
self.cheese = CheeseList(ep_id=self.__epid)
else:
self.cheese = CheeseList(season_id=meta["ssid"])
self.credential = credential if credential else Credential()
self.credential: Credential = credential if credential else Credential()
if meta == None:
api = API["info"]["meta"]
params = {"season_id": self.cheese.get_season_id(), "ep_id": self.__epid}
Expand Down
2 changes: 1 addition & 1 deletion bilibili_api/comment.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ def __init__(
self.__oid = oid
self.__rpid = rpid
self.__type = type_
self.credential = credential if credential else Credential()
self.credential: Credential = credential if credential else Credential()

def __get_data(self, status: bool) -> dict:
"""
Expand Down
2 changes: 1 addition & 1 deletion bilibili_api/dynamic.py
Original file line number Diff line number Diff line change
Expand Up @@ -738,7 +738,7 @@ def __init__(
credential (Credential | None, optional): 凭据类. Defaults to None.
"""
self.__dynamic_id = dynamic_id
self.credential = credential if credential is not None else Credential()
self.credential: Credential = credential if credential is not None else Credential()

if cache_pool.dynamic_is_opus.get(self.__dynamic_id):
self.__opus = cache_pool.dynamic_is_opus[self.__dynamic_id]
Expand Down
2 changes: 1 addition & 1 deletion bilibili_api/favorite_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def __init__(
"""
self.__type = type_
self.__media_id = media_id
self.credential = credential if credential else Credential()
self.credential: Credential = credential if credential else Credential()

def is_video_favorite_list(self) -> bool:
"""
Expand Down
2 changes: 1 addition & 1 deletion bilibili_api/festival.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def __init__(self, fes_id: str, credential: Optional[Credential] = None) -> None
credential (Credential, optional): 凭据类. Defaults to None.
"""
self.fes_id = fes_id
self.credential = credential if credential else Credential()
self.credential: Credential = credential if credential else Credential()

async def get_info(self) -> dict:
"""
Expand Down
2 changes: 1 addition & 1 deletion bilibili_api/game.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def __init__(self, game_id: int, credential: Union[None, Credential] = None):
credential (Credential): 凭据类. Defaults to None.
"""
self.__game_id = game_id
self.credential = credential if credential else Credential()
self.credential: Credential = credential if credential else Credential()

def get_game_id(self) -> int:
return self.__game_id
Expand Down
14 changes: 7 additions & 7 deletions bilibili_api/live.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,9 @@ def __init__(
self.room_display_id = room_display_id

if credential is None:
self.credential = Credential()
self.credential: Credential = Credential()
else:
self.credential = credential
self.credential: Credential = credential

self.__ruid = None

Expand Down Expand Up @@ -884,17 +884,17 @@ def __init__(
"""
super().__init__()

self.credential = credential if credential is not None else Credential()
self.room_display_id = room_display_id
self.max_retry = max_retry
self.retry_after = retry_after
self.credential: Credential = credential if credential is not None else Credential()
self.room_display_id: int = room_display_id
self.max_retry: int = max_retry
self.retry_after: float = retry_after
self.__room_real_id = None
self.__status = 0
self.__ws = None
self.__tasks = []
self.__debug = debug
self.__heartbeat_timer = 60.0
self.err_reason = ""
self.err_reason: str = ""

# logging
self.logger = logging.getLogger(f"LiveDanmaku_{self.room_display_id}")
Expand Down
2 changes: 1 addition & 1 deletion bilibili_api/manga.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ def __init__(self, manga_id: int, credential: Optional[Credential] = None):
"""
credential = credential if credential else Credential()
self.__manga_id = manga_id
self.credential = credential
self.credential: Credential = credential
self.__info: Optional[Dict] = None

def get_manga_id(self) -> int:
Expand Down
2 changes: 1 addition & 1 deletion bilibili_api/opus.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def __init__(self, opus_id: int, credential: Optional[Credential] = None):
self.__id = opus_id
self.__is_note = False
self.__info = None
self.credential = credential if credential else Credential()
self.credential: Credential = credential if credential else Credential()

if cache_pool.opus_type.get(self.__id):
self.__is_note = cache_pool.opus_is_note[self.__id]
Expand Down
2 changes: 1 addition & 1 deletion bilibili_api/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,7 @@ def __init__(self, credential: Credential, debug=False):
self.maxSeqno = dict()

# 凭证
self.credential = credential
self.credential: Credential = credential

# 异步定时任务框架
self.sched = AsyncIOScheduler(timezone="Asia/Shanghai")
Expand Down
2 changes: 1 addition & 1 deletion bilibili_api/topic.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def __init__(self, topic_id: int, credential: Union[Credential, None] = None):
credential (Credential): 凭据类
"""
self.__topic_id = topic_id
self.credential = credential if credential else Credential()
self.credential: Credential = credential if credential else Credential()

def get_topic_id(self) -> int:
"""
Expand Down
2 changes: 1 addition & 1 deletion bilibili_api/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ def __init__(self, uid: int, credential: Union[Credential, None] = None):

if credential is None:
credential = Credential()
self.credential = credential
self.credential: Credential = credential
self.__self_info = None

def get_user_info_sync(self) -> dict:
Expand Down
2 changes: 1 addition & 1 deletion bilibili_api/video.py
Original file line number Diff line number Diff line change
Expand Up @@ -1777,7 +1777,7 @@ def __init__(
debug (bool, optional) : 调试模式,将输出更详细信息. Defaults to False.
"""
super().__init__()
self.credential = credential
self.credential: Credential = credential if credential else Credential()
self.__video = Video(bvid, aid, credential=credential)

# 智能选择在 log 中展示的 ID。
Expand Down
2 changes: 1 addition & 1 deletion bilibili_api/video_tag.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def __init__(
else:
self.__tag_id = tag_id
credential = credential if credential else Credential()
self.credential = credential
self.credential: Credential = credential

def get_tag_id(self) -> int:
return self.__tag_id
Expand Down
4 changes: 2 additions & 2 deletions bilibili_api/video_uploader.py
Original file line number Diff line number Diff line change
Expand Up @@ -728,7 +728,7 @@ def __init__(
super().__init__()
self.meta = meta
self.pages = pages
self.credential = credential
self.credential: Credential = credential
self.cover = (
self.meta.cover
if isinstance(self.meta, VideoMeta)
Expand Down Expand Up @@ -1410,7 +1410,7 @@ def __init__(
super().__init__()
self.bvid = bvid
self.meta = meta
self.credential = credential if credential else Credential()
self.credential: Credential = credential if credential else Credential()
self.cover_path = cover
self.__old_configs = {}
self.meta["aid"] = bvid2aid(bvid)
Expand Down
4 changes: 2 additions & 2 deletions bilibili_api/vote.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,15 +87,15 @@ class Vote:
credential (Credential): 凭据类
"""

def __init__(self, vote_id: int, credential: Credential = Credential()) -> None:
def __init__(self, vote_id: int, credential: Optional[Credential] = None) -> None:
"""
Args:
vote_id (int): vote_id, 获取:https://nemo2011.github.io/bilibili-api/#/vote_id
credential (Credential): 凭据类,非必要.
"""
self.__vote_id = vote_id
self.credential = credential
self.credential: Credential = credential if credential else Credential()
self.title: Optional[str] = None

def get_vote_id(self) -> int:
Expand Down
2 changes: 1 addition & 1 deletion bilibili_api/watchroom.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ def __init__(self, room_id: int, credential: Credential = None):
"""
credential = credential if credential else Credential()
self.__room_id = room_id
self.credential = credential
self.credential: Credential = credential
self.credential.raise_for_no_sessdata()
self.credential.raise_for_no_bili_jct()
if room_id in watch_room_bangumi_cache.keys():
Expand Down

0 comments on commit 0eafcac

Please sign in to comment.