Add Option to delete Files after Upload
This commit is contained in:
parent
ed6552fe41
commit
2e66a44e56
@ -96,7 +96,7 @@ def createNewPost(access_token, url, ImageID, ImageDescription):
|
||||
except requests.exceptions.RequestException as e:
|
||||
print(f"An error occurred during the API call: {e}")
|
||||
|
||||
def sendImages(Token, url, imagedir, uploadType):
|
||||
def sendImages(Token, url, imagedir, uploadType, deleteFile):
|
||||
files = getImages(imagedir)
|
||||
tags = getTags("tags.txt")
|
||||
tagDescription = ""
|
||||
@ -118,6 +118,11 @@ def sendImages(Token, url, imagedir, uploadType):
|
||||
newFileID = newFile.get("id")
|
||||
if uploadType == 1:
|
||||
createNewPost(Token, url, newFileID, tagDescription)
|
||||
|
||||
if deleteFile:
|
||||
for f in files:
|
||||
if os.path.exists(f):
|
||||
os.remove(f)
|
||||
return True
|
||||
|
||||
if __name__ == "__main__":
|
||||
@ -128,5 +133,6 @@ if __name__ == "__main__":
|
||||
accessToken = config.get("access_token")
|
||||
imagedir = config.get("image_path")
|
||||
uploadType = config.get("upload_type")
|
||||
|
||||
sendImages(accessToken, url, imagedir, uploadType)
|
||||
deleteFile = config.get("delete_file")
|
||||
|
||||
sendImages(accessToken, url, imagedir, uploadType, deleteFile)
|
@ -12,7 +12,8 @@ To use this you need a config.json if this cannot be created automatically, here
|
||||
"server_url": "URL TO YOUR PIXELFED",
|
||||
"access_token": "YOUR ACCESS TOKEN",
|
||||
"image_path": "PATH TO YOUR IMAGES",
|
||||
"upload_type": 0|1
|
||||
"upload_type": 0|1,
|
||||
"delete_file": true|false
|
||||
}
|
||||
```
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user