Skip to content

Commit

Permalink
- If 403 error is encountered, change the description to the title an…
Browse files Browse the repository at this point in the history
…d retry once

- If still 403 error, clear the description and retry once more
  • Loading branch information
Ovler-Young committed Nov 22, 2024
1 parent b169b02 commit 03b4b8e
Showing 1 changed file with 29 additions and 1 deletion.
30 changes: 29 additions & 1 deletion biliarchiver/_biliarchiver_upload_bvid.py
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,35 @@ def _upload_bvid(
r.raise_for_status()
except HTTPError as e:
if e.response.status_code == 403:
print(f"403 Forbidden error encountered for {remote_identifier}. No retries will be attempted.")
print(f"403 Forbidden error encountered for {remote_identifier}. Retrying with description as title.")
new_md["description"] = md["title"]
try:
r = item.modify_metadata(
metadata=new_md,
access_key=access_key,
secret_key=secret_key,
)
assert isinstance(r, Response)
r.raise_for_status()
except HTTPError as e:
if e.response.status_code == 403:
print(f"403 Forbidden error encountered again for {remote_identifier}. Retrying with empty description.")
new_md["description"] = ""
try:
r = item.modify_metadata(
metadata=new_md,
access_key=access_key,
secret_key=secret_key,
)
assert isinstance(r, Response)
r.raise_for_status()
except HTTPError as e:
if e.response.status_code == 403:
print(f"403 Forbidden error encountered again for {remote_identifier}. No more retries will be attempted.")
else:
raise e
else:
raise e
else:
raise e

Expand Down

0 comments on commit 03b4b8e

Please sign in to comment.