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:
|
elif self.url:
|
||||||
if v and not v.oldreddit: return self.url.replace("old.reddit.com", "reddit.com")
|
if v and not v.oldreddit: return self.url.replace("old.reddit.com", "reddit.com")
|
||||||
if self.url: return self.url
|
if self.url: return self.url
|
||||||
return ""
|
return ""
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def body(self):
|
def body(self):
|
||||||
|
|
|
@ -68,6 +68,8 @@ def upload_file(name, file, resize=None):
|
||||||
print(e)
|
print(e)
|
||||||
print(req)
|
print(req)
|
||||||
print(req.text)
|
print(req.text)
|
||||||
|
return
|
||||||
|
|
||||||
else:
|
else:
|
||||||
req = requests.post('https://api.imgur.com/3/upload.json', headers = {"Authorization": f"Client-ID {imgurkey}"}, data = {'image': base64.b64encode(file.read())})
|
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']
|
try: resp = req.json()['data']
|
||||||
|
@ -75,11 +77,14 @@ def upload_file(name, file, resize=None):
|
||||||
print(e)
|
print(e)
|
||||||
print(req)
|
print(req)
|
||||||
print(req.text)
|
print(req.text)
|
||||||
|
return
|
||||||
|
|
||||||
try: url = resp['link'].replace(".png", "_d.png").replace(".jpg", "_d.jpg").replace(".jpeg", "_d.jpeg") + "?maxwidth=9999"
|
try: url = resp['link'].replace(".png", "_d.png").replace(".jpg", "_d.jpg").replace(".jpeg", "_d.jpeg") + "?maxwidth=9999"
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(e)
|
print(e)
|
||||||
print(req)
|
print(req)
|
||||||
print(req.text)
|
print(req.text)
|
||||||
|
return
|
||||||
|
|
||||||
new_image = Image(
|
new_image = Image(
|
||||||
text=url,
|
text=url,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue