-
Notifications
You must be signed in to change notification settings - Fork 0
/
upload_pics.py
68 lines (60 loc) · 2.04 KB
/
upload_pics.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
from instapy_cli import client
import requests
import os
from PIL import Image
import subprocess
def Reformat_Image(ImageFilePath):
image = Image.open(ImageFilePath, 'r')
image_size = image.size
width = image_size[0]
height = image_size[1]
if(width != height):
bigside = width if width > height else height
background = Image.new('RGBA', (bigside, bigside), (255, 255, 255, 255))
offset = (int(round(((bigside - width) / 2), 0)), int(round(((bigside - height) / 2),0)))
background.paste(image, offset)
background.save('out.png')
else:
image.save('out.png')
account = open('Account.txt','r')
username = account.readline().rstrip()
password = account.readline().rstrip()
account.close()
try:
file = open('./img_urls.txt','r')
except:
print("Web Scraping Failed")
exit(1)
urls = file.readlines()
urls = [i[:-1] for i in urls]
urls = [i.split('^^') for i in urls]
file.close()
cli = client(username,password)
try:
for i in urls:
r = requests.get(i[0])
f = open("image",'wb')
f.write(r.content)
viewer = subprocess.Popen(['eog','image'])
print("URL - " + i[2])
c = input("upload?[y/n]")
if c=='n':
viewer.terminate()
viewer.kill()
os.remove('image')
f.close()
continue
Reformat_Image('image')
cli.upload('out.png',"Post mirrored from Reddit\nCREDITS: "+i[1]+".\n.\n.\n.\n.\n.\n#memes #dankmemes #reddit #sadmemes #spicymemes #humor #funny #pewdiepie #fortnite #dailymemes #thanosmemes #minecraft #memereview #lwiay #pewnews #pewpew #memestgram #memedaily #memesfunny #epicmemes #normiememes #spicymeme #stolenmemes #dankmemesdaily #mememachine")
viewer.terminate()
viewer.kill()
os.remove('image')
os.remove('out.png')
f.close()
finally:
if(os.path.exists("./image")):
os.remove("image")
if(os.path.exists("./out.png")):
os.remove("out.png")
os.remove('post_urls.txt')
os.remove('img_urls.txt')