From 02a51c6bef6405b31015909ce890e6843872b3dc Mon Sep 17 00:00:00 2001 From: Ching Date: Tue, 26 Mar 2024 17:52:59 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E4=BF=AE=E6=94=B9=E8=8E=B7?= =?UTF-8?q?=E5=8F=96=E6=96=B0=E6=B6=88=E6=81=AF=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- mas2ff2.py | 22 +--------------------- 1 file changed, 1 insertion(+), 21 deletions(-) diff --git a/mas2ff2.py b/mas2ff2.py index de63031..ea468b7 100644 --- a/mas2ff2.py +++ b/mas2ff2.py @@ -126,16 +126,7 @@ def run(instance, access_token, fanfou_cookie, fanfou_token): me_id = me_info['id'] me_timeline = mastodon_cli.account_statuses( me_id, exclude_replies=True) - min_id = None - max_id = None # first time run - # init min_id - for status in me_timeline: - if not status['reblog'] and status['visibility'] == 'public': - min_id = status['id'] - logger.info(status['content']) - break - # if is in already posted status posted_ids = [] # if file not exist, create it with open('last_id.txt', 'a+') as f: @@ -144,19 +135,8 @@ def run(instance, access_token, fanfou_cookie, fanfou_token): posted_ids = f.readlines() # remove \n posted_ids = [x.strip() for x in posted_ids] - #print(posted_ids) - if str(min_id) not in posted_ids: - content = status['content'].replace('
', '\n') - content = re.sub('<.*?>', '', content) - post_fanfou(fanfou_cookie, fanfou_token, content, status['media_attachments']) - # write to file - with open('last_id.txt', 'a') as f: - f.write(str(min_id) + '\n') - posted_ids.append(min_id) - logger.info('write toot') - - time.sleep(10) + min_id = posted_ids[-1] if posted_ids else None # get every new status while min_id: me_timeline = mastodon_cli.account_statuses(