add tmp folder

This commit is contained in:
Ching 2021-03-11 10:36:34 +08:00
parent a45459dedc
commit 0dc6d037e9
2 changed files with 11 additions and 11 deletions

View File

@ -33,13 +33,13 @@ def ramdom_ua():
def load_id(): def load_id():
id_list = [] id_list = []
with open('/home/captain/dev/id_list') as f: with open('/home/captain/dev/tmp/id_list') as f:
id_list = f.read().splitlines() id_list = f.read().splitlines()
f.close() f.close()
return id_list return id_list
def save_id(id_list): def save_id(id_list):
with open('/home/captain/dev/id_list', 'wb') as f: with open('/home/captain/dev/tmp/id_list', 'wb') as f:
for item in id_list: for item in id_list:
f.write(("%s\n" % item).encode()) f.write(("%s\n" % item).encode())
f.close() f.close()

View File

@ -29,13 +29,13 @@ tvdl_url = 'https://tvdl-api.saif.dev/'
def load_id(): def load_id():
id_ = None id_ = None
with open('/home/captain/dev/setu_dm') as f: with open('/home/captain/dev/tmp/setu_dm') as f:
id_ = f.read() id_ = f.read()
f.close() f.close()
return id_ return id_
def save_id(id_): def save_id(id_):
with open('/home/captain/dev/setu_dm', 'wb') as f: with open('/home/captain/dev/tmp/setu_dm', 'wb') as f:
f.write(("%s\n" % id_).encode()) f.write(("%s\n" % id_).encode())
f.close() f.close()
@ -80,11 +80,11 @@ def post_mentions():
mime_type = 'image/gif' mime_type = 'image/gif'
toot_resp = mastodon.media_post(r.content, mime_type) toot_resp = mastodon.media_post(r.content, mime_type)
else: else:
f = open('/home/captain/dev/temp_download_file.%s' % ext, 'wb') f = open('/home/captain/dev/tmp/temp_download_file.%s' % ext, 'wb')
f.write(r.content) f.write(r.content)
f.close() f.close()
mime_type = None mime_type = None
toot_resp = mastodon.media_post('/home/captain/dev/temp_download_file.%s' % ext, mime_type) toot_resp = mastodon.media_post('/home/captain/dev/tmp/temp_download_file.%s' % ext, mime_type)
except: except:
continue continue
if toot_resp.get('id'): if toot_resp.get('id'):
@ -101,18 +101,18 @@ def post_mentions():
resp = requests.get(media['url']) resp = requests.get(media['url'])
if resp.status_code != 200: if resp.status_code != 200:
continue continue
f = open('/home/captain/dev/temp_video.mp4', 'wb') f = open('/home/captain/dev/tmp/temp_video.mp4', 'wb')
f.write(resp.content) f.write(resp.content)
f.close() f.close()
mime_type = None mime_type = None
try: try:
toot_resp = mastodon.media_post('/home/captain/dev/temp_video.mp4', mime_type) toot_resp = mastodon.media_post('/home/captain/dev/tmp/temp_video.mp4', mime_type)
except: except:
try: try:
clip = VideoFileClip('/home/captain/dev/temp_video.mp4') clip = VideoFileClip('/home/captain/dev/tmp/temp_video.mp4')
clip.write_gif('/home/captain/dev/temp_gif.gif') clip.write_gif('/home/captain/dev/tmp/temp_gif.gif')
mime_type = 'image/gif' mime_type = 'image/gif'
toot_resp = mastodon.media_post('/home/captain/dev/temp_gif.gif', mime_type) toot_resp = mastodon.media_post('/home/captain/dev/tmp/temp_gif.gif', mime_type)
except: except:
continue continue
if toot_resp.get('id'): if toot_resp.get('id'):