fd
This commit is contained in:
parent
c391b52276
commit
6c4fc18188
2 changed files with 6 additions and 1 deletions
|
@ -421,7 +421,7 @@ class Submission(Base, Stndrd, Age_times, Scores, Fuzzing):
|
|||
elif self.url:
|
||||
if v and not v.oldreddit: return self.url.replace("old.reddit.com", "reddit.com")
|
||||
if self.url: return self.url
|
||||
return ""
|
||||
return ""
|
||||
|
||||
@property
|
||||
def body(self):
|
||||
|
|
|
@ -68,6 +68,8 @@ def upload_file(name, file, resize=None):
|
|||
print(e)
|
||||
print(req)
|
||||
print(req.text)
|
||||
return
|
||||
|
||||
else:
|
||||
req = requests.post('https://api.imgur.com/3/upload.json', headers = {"Authorization": f"Client-ID {imgurkey}"}, data = {'image': base64.b64encode(file.read())})
|
||||
try: resp = req.json()['data']
|
||||
|
@ -75,11 +77,14 @@ def upload_file(name, file, resize=None):
|
|||
print(e)
|
||||
print(req)
|
||||
print(req.text)
|
||||
return
|
||||
|
||||
try: url = resp['link'].replace(".png", "_d.png").replace(".jpg", "_d.jpg").replace(".jpeg", "_d.jpeg") + "?maxwidth=9999"
|
||||
except Exception as e:
|
||||
print(e)
|
||||
print(req)
|
||||
print(req.text)
|
||||
return
|
||||
|
||||
new_image = Image(
|
||||
text=url,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue