-
Notifications
You must be signed in to change notification settings - Fork 25
Expand file tree
/
Copy pathmain.py
More file actions
29 lines (21 loc) · 1 KB
/
main.py
File metadata and controls
29 lines (21 loc) · 1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import asyncio
import aiohttp
from util import dreamMachineMake, refreshDreamMachine
async def main():
access_token = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOnsidXNlcl91dWlkIjoiYWE2MzVkY2EtMWU0NC00YjFiLTk1YTItOWEyYjA1ZWY3NTAxIiwiY2xpZW50X2lkIjoiIn0sImV4cCI6MTcxODg1Mjk4MX0.QdmkCSJ0NTvU-l2_vfhuNAAiYJpNPfurXcC6R36435A"
# 这里替换成您的access_token
prompt = "Little pigs are running on the grass"
dreamMachineMake(prompt, access_token)
async with aiohttp.ClientSession() as session:
previous_ids = set()
while True:
response_json = await refreshDreamMachine(session, access_token)
item = response_json[0]
if item['id'] not in previous_ids and item['state'] == 'completed':
previous_ids.add(item['id'])
if item['video']:
print(f"New video link: {item['video']['url']}")
break
await asyncio.sleep(3)
if __name__ == "__main__":
asyncio.run(main())