12 }
13
14 def get_video_response(ids):
15 api_url = f"{lumalabs_internal_url}/{ids}"
16 response = requests.get(url = api_url,headers = COMMON_HEADERS)
17 return response.json()
18
19 def get_video(ids):
27 params = {
28 'file_type': 'image',
29 'filename': 'file.jpg'
30 }
31 response = requests.post(full_url, params = params, cookies = Cookie)
32 presigned_url, public_url = response.json()["presigned_url"], response.json()["public_url"]
33 print(presigned_url)
34 print(public_url)
38 try:
39 presigned_url, public_url = get_upload_link(Cookie)
40 time.sleep(1)
41 with open(file_path, 'rb') as file:
42 response = requests.put(presigned_url, data=file,
43 headers={'Content-Type': "image/*", "Referer": "https://lumalabs.ai/", "origin": "https://lumalabs.ai"})
44
45 if response.status_code == 200:
46 print("Upload successful:", public_url)
54 def upload_file_comfyui(Cookie, binary_image):
55 try:
56 presigned_url, public_url = get_upload_link(Cookie)
57 time.sleep(1)
58 response = requests.put(presigned_url, data=binary_image,
59 headers={'Content-Type': "image/*", "Referer": "https://lumalabs.ai/", "origin": "https://lumalabs.ai"})
60
61 if response.status_code == 200:
62 print("Upload successful:", public_url)
89 else: 90 return "Something Wrong" 91 92 93 response = requests.post(lumalabs_internal_url, json=payload, cookies = Cookie_dict, headers=COMMON_HEADERS) 94 response_json = response.json() 95 return response_json 96
97 def check_res(Cookie = str):
98 try:
99 url = "https://internal-api.virginia.labs.lumalabs.ai/api/photon/v1/user/generations/"
100 params = {"offset": "0", "limit": "10"}
101 res = requests.get(url,headers = {"Cookie":Cookie},params = params)
102 return res.json()
103 except Exception as ex:
104 print("Failed to get result: %s"%ex)
109 if ids == i['id']: 110 video_url = i["video"]['url'] 111 if download: 112 with open(output_name, 'wb') as file: 113 response = requests.get(video_url, stream=True) 114 for chunk in response.iter_content(chunk_size=1024): 115 if chunk: 116 file.write(chunk)