From adbb8935f4a75d5933f0b3bc688c9c5a69e725b7 Mon Sep 17 00:00:00 2001 From: Ovler Date: Sun, 1 Dec 2024 10:11:07 -0500 Subject: [PATCH] feat: add uploader check --- biliarchiver/_biliarchiver_upload_bvid.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/biliarchiver/_biliarchiver_upload_bvid.py b/biliarchiver/_biliarchiver_upload_bvid.py index af3d465..6be58cf 100644 --- a/biliarchiver/_biliarchiver_upload_bvid.py +++ b/biliarchiver/_biliarchiver_upload_bvid.py @@ -4,7 +4,7 @@ import time from typing import List from urllib.parse import urlparse -from internetarchive import get_item +from internetarchive import get_item, get_username from requests import Response, HTTPError from rich import print from pathlib import Path @@ -105,6 +105,12 @@ def _upload_bvid( item = get_item(remote_identifier) if item.exists and not update_existing: print(f"item {remote_identifier} {_('已存在')} (item.exists)") + + # check if the user is the same + if item.metadata.get("uploader") != get_username(access_key=access_key, secret_key=secret_key): + print(f"{remote_identifier} {_('不是你上传的,跳过')} (item.metadata.creator)") + return + if item.metadata.get("upload-state") == "uploaded": print(f"{remote_identifier} {_('已经上传过了,跳过')} (item.metadata.uploaded)") with open(