forked from Nemo2011/bilibili-api
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
56 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,42 @@ | ||
import asyncio | ||
from bilibili_api import video | ||
import sys | ||
|
||
async def main() -> None: | ||
from bilibili_api import * | ||
|
||
|
||
async def main1() -> None: | ||
# 实例化 Video 类 | ||
v = video.Video(bvid="BV1cF411D7x4") | ||
# 获取信息 | ||
info = await v.get_info() | ||
# 打印信息 | ||
print(info) | ||
|
||
|
||
async def main2() -> None: | ||
# 实例化 Credential 类 | ||
credential = Credential( | ||
sessdata="", | ||
bili_jct="", buvid3="") | ||
# 实例化 Video 类 | ||
v = video.Video(bvid="BV1TP411a7op", credential=credential) | ||
info = await v.get_info() | ||
print(info) | ||
# 给视频点赞 | ||
await v.like(True) | ||
|
||
|
||
async def getVideo(obj): | ||
info = await obj.get_info() | ||
print(info) | ||
|
||
|
||
if __name__ == '__main__': | ||
asyncio.get_event_loop().run_until_complete(main()) | ||
asyncio.get_event_loop().run_until_complete(main2()) | ||
c = getattr(video, "Video")(bvid="BV1cF411D7x4") | ||
d = getattr(video, "Video")(bvid="BV1cF411D7x4") | ||
|
||
print(dir(sys.modules[__name__])) | ||
b = getattr(sys.modules[__name__], "video") | ||
e = getattr(b, "Video")(bvid="BV1cF411D7x4") | ||
asyncio.run(getVideo(e)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
from sanic import Sanic | ||
from sanic.response import text | ||
import asyncio | ||
|
||
import bilibili_api.video | ||
from bilibili_api import * | ||
|
||
app = Sanic("MyHelloWorldApp") | ||
|
||
|
||
@app.get("/<i>/<j>") | ||
async def hello_world(request, i, j): | ||
print(i) | ||
print(j) | ||
print(type("video", (object, ), {})) | ||
clazz = type("bilibili_api.video.Video", (), dict(bvid="asd1")) | ||
print(hasattr(clazz, "get_info")) | ||
print(clazz()) | ||
print(bilibili_api.video.Video) | ||
return text("Hello, world.") | ||
|
||
|
||
if __name__ == '__main__': | ||
app.run(host="0.0.0.0", port=9000, dev=True) |