Skip to content

Commit

Permalink
server
Browse files Browse the repository at this point in the history
  • Loading branch information
nooblong committed Sep 15, 2023
1 parent 8339ab5 commit b64642d
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 3 deletions.
35 changes: 32 additions & 3 deletions main.py
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))
24 changes: 24 additions & 0 deletions server.py
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)

0 comments on commit b64642d

Please sign in to comment.