2020-12-29 02:13:29 +01:00
|
|
|
#!/usr/bin/python3
|
2019-10-05 23:25:52 +02:00
|
|
|
import tweepy
|
2020-12-17 01:31:57 +01:00
|
|
|
from randstrip import createStrip,readConfig
|
2019-10-05 23:25:52 +02:00
|
|
|
import os
|
2020-12-29 02:13:29 +01:00
|
|
|
import sys
|
2019-10-05 23:25:52 +02:00
|
|
|
|
|
|
|
fileDir = os.path.dirname(os.path.abspath(__file__))
|
|
|
|
fileDir = fileDir +"/"
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
2020-12-29 02:13:29 +01:00
|
|
|
if len(sys.argv) == 2:
|
|
|
|
altProfile = [sys.argv[1]]
|
|
|
|
else:
|
|
|
|
altProfile = False
|
|
|
|
config = readConfig(platform="twitter",profile=altProfile)
|
2020-12-17 01:31:57 +01:00
|
|
|
status = createStrip(config)
|
2019-10-05 23:25:52 +02:00
|
|
|
if status == 0:
|
2020-12-17 01:31:57 +01:00
|
|
|
with open(config["token"]) as f:
|
2019-10-05 23:25:52 +02:00
|
|
|
tokens = f.readlines()
|
|
|
|
tokens = [x.strip() for x in tokens]
|
|
|
|
auth = tweepy.OAuthHandler(tokens[0],tokens[1])
|
|
|
|
auth.set_access_token(tokens[2],tokens[3])
|
|
|
|
api = tweepy.API(auth)
|
2020-03-25 15:11:26 +01:00
|
|
|
published = False
|
|
|
|
for i in range(0,100):
|
|
|
|
try:
|
|
|
|
api.verify_credentials()
|
2020-12-29 02:13:29 +01:00
|
|
|
api.update_with_media(config["saveLocation"]+config["filename"],config["text"])
|
2020-03-25 15:11:26 +01:00
|
|
|
published = True
|
|
|
|
except:
|
|
|
|
continue
|
|
|
|
break
|
|
|
|
if not(published):
|
2019-10-05 23:25:52 +02:00
|
|
|
print("Auth error")
|
|
|
|
else:
|
|
|
|
print("Error creating image\n")
|
|
|
|
print(status)
|