fix
This commit is contained in:
parent
20a60d8e6b
commit
56ba6bd562
1
dm.py
1
dm.py
@ -144,7 +144,6 @@ class TableWidgetExample(QMainWindow):
|
|||||||
self.statusBar().showMessage("主机、端口、数据库名、用户名和密码不能为空!")
|
self.statusBar().showMessage("主机、端口、数据库名、用户名和密码不能为空!")
|
||||||
QMessageBox.critical(self, "Error", "主机、端口、数据库名、用户名和密码不能为空!")
|
QMessageBox.critical(self, "Error", "主机、端口、数据库名、用户名和密码不能为空!")
|
||||||
return
|
return
|
||||||
|
|
||||||
try:
|
try:
|
||||||
socket.gethostbyname(host)
|
socket.gethostbyname(host)
|
||||||
except socket.error:
|
except socket.error:
|
||||||
|
|||||||
36
getDm.py
Normal file
36
getDm.py
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
import asyncio
|
||||||
|
|
||||||
|
import httpx
|
||||||
|
|
||||||
|
|
||||||
|
class DanMu():
|
||||||
|
def __init__(self):
|
||||||
|
super().__init__()
|
||||||
|
|
||||||
|
async def tencent(self, vid):
|
||||||
|
async with httpx.AsyncClient() as client:
|
||||||
|
base_url = f"https://dm.video.qq.com/barrage/base/{vid}"
|
||||||
|
res = await client.get(base_url)
|
||||||
|
if res.status_code == 200:
|
||||||
|
json_data = res.json()
|
||||||
|
segment_data = json_data.get("segment_index")
|
||||||
|
# data index
|
||||||
|
max_index = len(segment_data) - 1
|
||||||
|
# max end page
|
||||||
|
max_page = max_index * 30000
|
||||||
|
# Calculate the amount of data acquired per page
|
||||||
|
per_count = 20000 / max_index
|
||||||
|
for i in range(0, 1):
|
||||||
|
print(i)
|
||||||
|
else:
|
||||||
|
# 处理请求失败的情况
|
||||||
|
return None
|
||||||
|
|
||||||
|
async def main():
|
||||||
|
dm = DanMu()
|
||||||
|
result = await dm.tencent("p0047s9euki")
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
loop = asyncio.get_event_loop()
|
||||||
|
loop.run_until_complete(main())
|
||||||
|
loop.close()
|
||||||
Loading…
Reference in New Issue
Block a user