feat/archive bookmarks and favourites
This commit is contained in:
parent
76922be81b
commit
b615a5ed23
1 changed files with 25 additions and 20 deletions
23
BDSM/toot.py
23
BDSM/toot.py
|
@ -222,27 +222,32 @@ def toot_process(statuses, my_acct, duplicates_counter=0):
|
||||||
def archive_toot(url):
|
def archive_toot(url):
|
||||||
mastodon, user = app_login(url)
|
mastodon, user = app_login(url)
|
||||||
acct = mastodon.me().acct
|
acct = mastodon.me().acct
|
||||||
statuses_count = str(mastodon.me().statuses_count)
|
|
||||||
|
|
||||||
statuses = mastodon.account_statuses(user["id"], limit=20)
|
|
||||||
# xx = statuses['created_at'].astimezone(tz_cn)
|
|
||||||
# pprint(xx.strftime("%m/%d/%Y, %H:%M:%S"))
|
|
||||||
# pprint(statuses)
|
|
||||||
|
|
||||||
|
def archive(statuses, skip_duplicates=True):
|
||||||
happy_counter = 20
|
happy_counter = 20
|
||||||
duplicates_counter = 0
|
duplicates_counter = 0
|
||||||
|
|
||||||
while(True):
|
while(True):
|
||||||
duplicates_counter = toot_process(statuses, acct)
|
duplicates_counter = toot_process(statuses, acct)
|
||||||
db.session.commit()
|
db.session.commit()
|
||||||
print(str(happy_counter) + ' / ' + statuses_count)
|
print(str(happy_counter) + ' / ' + statuses_count)
|
||||||
happy_counter += 20
|
happy_counter += 20
|
||||||
|
|
||||||
if duplicates_counter >= 10:
|
if duplicates_counter >= 10 and skip_duplicates:
|
||||||
print("检测到重复嘟文达到十次,取消存档……")
|
print("检测到重复嘟文达到十次,取消存档……")
|
||||||
break
|
break
|
||||||
|
|
||||||
statuses = mastodon.fetch_next(statuses)
|
statuses = mastodon.fetch_next(statuses)
|
||||||
# statuses = None
|
|
||||||
if statuses == None:
|
if statuses == None:
|
||||||
break
|
break
|
||||||
|
|
||||||
|
statuses_count = str(mastodon.me().statuses_count)
|
||||||
|
statuses = mastodon.account_statuses(user["id"], limit=20)
|
||||||
|
archive(statuses)
|
||||||
|
|
||||||
|
statuses_count = '???'
|
||||||
|
statuses = mastodon.favourites()
|
||||||
|
archive(statuses)
|
||||||
|
|
||||||
|
statuses = mastodon.bookmarks()
|
||||||
|
archive(statuses, skip_duplicates=False)
|
||||||
|
|
Loading…
Reference in a new issue