Skip to content

Commit

Permalink
feat: parse_link -> Opus
Browse files Browse the repository at this point in the history
  • Loading branch information
Nemo2011 committed Feb 11, 2025
1 parent 41929f6 commit 48e2217
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions bilibili_api/utils/parse_link.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
from ..interactive_video import InteractiveVideo
from ..favorite_list import FavoriteList, FavoriteListType
from ..user import User, ChannelSeries, ChannelSeriesType, get_self_info
from ..opus import Opus

from .initial_state import get_initial_state

Expand All @@ -53,6 +54,7 @@ class ResourceType(Enum):
+ TOPIC: 话题
+ MANGA: 漫画
+ NOTE: 笔记
+ OPUS: 图文
+ FAILED: 错误
"""

Expand All @@ -75,6 +77,7 @@ class ResourceType(Enum):
TOPIC = "topic"
MANGA = "manga"
NOTE = "note"
OPUS = "opus"
FAILED = "failed"


Expand Down Expand Up @@ -216,7 +219,7 @@ async def parse_link(url: str, credential: Union[Credential, None] = None) -> Un
obj = (manga, ResourceType.MANGA)
opus_dynamic = parse_opus_dynamic(url, credential) # type: ignore
if not opus_dynamic == -1:
obj = (opus_dynamic, ResourceType.DYNAMIC)
obj = (opus_dynamic, ResourceType.OPUS)

if obj == None or obj[0] == None:
return (-1, ResourceType.FAILED)
Expand Down Expand Up @@ -647,5 +650,5 @@ def parse_nianshizhiwang(url: URL) -> None:
def parse_opus_dynamic(url: URL, credential: Credential) -> Union[Dynamic, int]:
# https://www.bilibili.com/opus/767674573455884292
if url.host == "www.bilibili.com" and url.parts[:2] == ("/", "opus"):
return Dynamic(dynamic_id=int(url.parts[-1]), credential=credential)
return Opus(opus_id=int(url.parts[-1]), credential=credential)
return -1

0 comments on commit 48e2217

Please sign in to comment.