WIP: New submission system
This commit is contained in:
@@ -55,11 +55,13 @@ async def upload_pic(filepath: str) -> Tuple[bool, list]:
|
||||
try:
|
||||
pic_name = path.basename(filepath)
|
||||
files = {'file': (pic_name, open(filepath, 'rb'), 'image/jpeg')}
|
||||
response = post(f'{configGet("address", "posting", "api")}/albums/{configGet("album", "posting", "api")}/photos&caption=queue', headers={"Authorization": f"Bearer {token}"}, files=files).json()
|
||||
print(response, flush=True)
|
||||
response = post(f'{configGet("address", "posting", "api")}/albums/{configGet("album", "posting", "api")}/photos', params={"caption": "queue", "compress": False}, headers={"Authorization": f"Bearer {token}"}, files=files)
|
||||
if response.status_code != 200 and response.status_code != 409:
|
||||
logWrite(f"Could not upload '{filepath}' to API: HTTP {response.status_code} with message '{response.content}'")
|
||||
return False, []
|
||||
duplicates = []
|
||||
if "duplicates" in response:
|
||||
for duplicate in response["duplicates"]:
|
||||
if "duplicates" in response.json():
|
||||
for duplicate in response.json()["duplicates"]:
|
||||
duplicates.append(f'{configGet("address", "posting", "api")}/photos/{duplicate["id"]}')
|
||||
return True, duplicates
|
||||
except:
|
||||
|
Reference in New Issue
Block a user