Change avatar and profile information on update too
* It was only setting this information on /<username>/add
This commit is contained in:
parent
2051406397
commit
cd0147562b
12
igmirror.py
12
igmirror.py
|
@ -70,8 +70,10 @@ def update_igaccount(acc_id):
|
|||
print('E| User "'+acc_id+'" has not been created yet, maybe you wanted to call /<username>/add ?')
|
||||
return 1
|
||||
|
||||
# do it on a thread because it might take long to download the latest posts
|
||||
data = getig_user_data(acc_id)
|
||||
pixelfed_setpic(acc_id, data['graphql']['user']['profile_pic_url'])
|
||||
pixelfed_setinfo(acc_id, data['graphql']['user']['biography'],\
|
||||
data['graphql']['user']['external_url'])
|
||||
pixelfed_dlposts(acc_id, data['graphql']['user'])
|
||||
|
||||
def update_allaccounts_async():
|
||||
|
@ -261,6 +263,7 @@ def pixelfed_setpic(acc_id, pic_url, count=0):
|
|||
|
||||
cachef = pixelfed_cacheimg(pic_url)
|
||||
accdata = db_get('accounts', acc_id)
|
||||
print('I| setting avatar for "{}" '.format(acc_id), end="")
|
||||
_, _token = pixelfed_token_url('/settings/home', accdata['cookie'])
|
||||
r = requests.post( 'https://'+config()['instance']+'/settings/avatar',\
|
||||
data={'_token': _token}, cookies=accdata['cookie'], files={'avatar': open(cachef, 'rb')}
|
||||
|
@ -268,9 +271,12 @@ def pixelfed_setpic(acc_id, pic_url, count=0):
|
|||
|
||||
# try to login if the upload failed
|
||||
if r.status_code == 419 and count < 3:
|
||||
print('err (login required)')
|
||||
pixelfed_login(acc_id, True)
|
||||
return pixelfed_setpic(acc_id, pic_url, count)
|
||||
|
||||
print('ok')
|
||||
|
||||
return True
|
||||
|
||||
def pixelfed_setinfo(acc_id, bio, website, count=0):
|
||||
|
@ -278,6 +284,7 @@ def pixelfed_setinfo(acc_id, bio, website, count=0):
|
|||
pixelfed_login(acc_id)
|
||||
|
||||
accdata = db_get('accounts', acc_id)
|
||||
print('I| setting account-info for "{}" '.format(acc_id), end="")
|
||||
_, _token = pixelfed_token_url('/settings/home', accdata['cookie'])
|
||||
r = requests.post( 'https://'+config()['instance']+'/settings/home',\
|
||||
data={
|
||||
|
@ -289,9 +296,12 @@ def pixelfed_setinfo(acc_id, bio, website, count=0):
|
|||
|
||||
# try to login if the upload failed
|
||||
if r.status_code == 419 and count < 3:
|
||||
print('err (login required)')
|
||||
pixelfed_login(acc_id, True)
|
||||
return pixelfed_setinfo(acc_id, bio, website, count)
|
||||
|
||||
print('ok')
|
||||
|
||||
return True
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue