Added a timeout btw posts updates + more verbose logs

This commit is contained in:
Bofh 2021-02-08 22:59:50 +01:00
parent 469990388a
commit 2c05de69aa
2 changed files with 9 additions and 4 deletions

View File

@ -4,5 +4,8 @@
"instance": "pixel.nogafam.es", "instance": "pixel.nogafam.es",
// maximum video size in MB (depends MAX_PHOTO_SIZE Pixelfed) // maximum video size in MB (depends MAX_PHOTO_SIZE Pixelfed)
"max_video_size": 30 "max_video_size": 30,
// time to sleep between posts successfull updates
"timeout_btw_posts": 0
} }

View File

@ -234,11 +234,11 @@ def pixelfed_dlposts(acc_id, data):
if size_in_mb > config()['max_video_size']: if size_in_mb > config()['max_video_size']:
# hack, we "add" it on posts so it doesn't try it again! # hack, we "add" it on posts so it doesn't try it again!
accposts.append(item['shortcode']) accposts.append(item['shortcode'])
print('W| image exceeds the configured Maximum of "{}MB"'.format(config()['max_video_size'])) print('W| video exceeds the configured Maximum of "{}MB"'.format(config()['max_video_size']))
continue continue
# try to upload to Pixelfed, it might failed depending on MAX_PHOTO_SIZE setting # try to upload to Pixelfed, it might failed depending on MAX_PHOTO_SIZE setting
print('I| fetching video for {}:{}... '.format(acc_id, item['shortcode']), end='') print('I| fetching VIDO for {}:{}... '.format(acc_id, item['shortcode']), end='')
_token, jsdata = pixelfed_postvideo(acc_id, item['video_url']) _token, jsdata = pixelfed_postvideo(acc_id, item['video_url'])
if not jsdata: if not jsdata:
print('err') print('err')
@ -249,7 +249,7 @@ def pixelfed_dlposts(acc_id, data):
print('done') print('done')
else: else:
print('I| uploading media for {}:{}... '.format(acc_id, item['shortcode']), end='') print('I| uploading IMAGES for {}:{}... '.format(acc_id, item['shortcode']), end='')
media2iterate = [a['node']['display_url'] for a in multmedia] if multiple else [item['display_url']] media2iterate = [a['node']['display_url'] for a in multmedia] if multiple else [item['display_url']]
# we add support to multiple media here # we add support to multiple media here
for media in media2iterate: for media in media2iterate:
@ -313,11 +313,13 @@ def pixelfed_dlposts(acc_id, data):
print('done') print('done')
accposts.append(item['shortcode']) accposts.append(item['shortcode'])
print('I| uploaded post {}:{} : OK'.format(acc_id, item['shortcode'])) print('I| uploaded post {}:{} : OK'.format(acc_id, item['shortcode']))
time.sleep(int(config()['timeout_btw_posts']))
else: else:
print(r.text) print(r.text)
print(r.headers) print(r.headers)
return return
print('I| done updating "{}" account'.format(acc_id))
db_set('posts', acc_id, accposts) db_set('posts', acc_id, accposts)
# upload media and return data # upload media and return data