From f60c1f03a52e3d9aeb5035a969939f4eec648338 Mon Sep 17 00:00:00 2001 From: Ching Date: Wed, 24 Jan 2024 21:26:34 +0800 Subject: [PATCH] =?UTF-8?q?fix(main.py):=20=E4=BF=AE=E5=A4=8D=E5=9B=BE?= =?UTF-8?q?=E7=89=87=E6=89=B9=E6=AC=A1=E6=80=BB=E6=95=B0=E9=87=8F=E6=BF=80?= =?UTF-8?q?=E7=B4=A0=E6=9C=89=E8=AF=AF=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 修复图片批次总数量激素有误的问题 Signed-off-by: Ching --- main.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/main.py b/main.py index 1231100..ab1d2f0 100644 --- a/main.py +++ b/main.py @@ -147,13 +147,13 @@ unsynced_photos = Photo.select().where(Photo.synced == False).order_by(Photo.cre # get titles unsynced_titles = set([p.title for p in unsynced_photos]) for title in unsynced_titles: - # get photos by title - photos = Photo.select().where(Photo.title == title).order_by(Photo.created_at.asc()) + # get unsynced photos by title + photos = Photo.select().where(Photo.title == title, Photo.synced == False).order_by(Photo.created_at.asc()) if len(photos) > 1: batches = [photos[i:i+4] for i in range(0, len(photos), 4)] for i, batch in enumerate(batches): idx = i + 1 - status = f'{title} ({idx}/{len(batches)}) \n' + status = f'{title} ({idx}/{len(batches)})' media_ids = [] for p in batch: # upload photo to mastodon @@ -163,7 +163,7 @@ for title in unsynced_titles: img_id = upload_photo_to_mastodon(photo_url) if img_id: media_ids.append(img_id) - status += f'{short_url} \n' + status += f'\n{short_url}' else: logger.error('Error: {}'.format(p.title)) # post to mastodon