Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle any 451's as if they were 404s #17

Merged
merged 1 commit into from
Jul 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions app/adapters/osu_api_v1.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ async def fetch_one_beatmap(
"authorized": True,
},
)
if response.status_code == 404:
if response.status_code in (404, 451):
return None
if response.status_code == 403:
raise ValueError("osu api is down") from None
Expand Down Expand Up @@ -113,7 +113,7 @@ async def fetch_beatmap_osu_file_data(beatmap_id: int) -> bytes | None:
"authorized": False,
},
)
if response.status_code == 404:
if response.status_code in (404, 451):
return None
if response.status_code == 403:
raise ValueError("osu api is down") from None
Expand Down
4 changes: 2 additions & 2 deletions app/adapters/osu_api_v2/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ async def get_beatmap(beatmap_id: int) -> BeatmapExtended | None:
osu_api_response_data: dict[str, Any] | None = None
try:
response = await osu_api_v2_http_client.get(f"beatmaps/{beatmap_id}")
if response.status_code == 404:
if response.status_code in (404, 451):
return None
response.raise_for_status()
osu_api_response_data = response.json()
Expand All @@ -59,7 +59,7 @@ async def get_beatmapset(beatmapset_id: int) -> BeatmapsetExtended | None:
osu_api_response_data: dict[str, Any] | None = None
try:
response = await osu_api_v2_http_client.get(f"beatmapsets/{beatmapset_id}")
if response.status_code == 404:
if response.status_code in (404, 451):
return None
response.raise_for_status()
osu_api_response_data = response.json()
Expand Down
2 changes: 1 addition & 1 deletion app/adapters/osu_mirrors/backends/gatari.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ async def fetch_beatmap_zip_data(
f"{self.base_url}/d/{beatmapset_id}",
follow_redirects=True,
)
if response.status_code == 404:
if response.status_code in (404, 451):
return BeatmapMirrorResponse(
data=None,
is_success=True,
Expand Down
4 changes: 2 additions & 2 deletions app/adapters/osu_mirrors/backends/mino.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ async def fetch_beatmap_zip_data(
headers={"x-ratelimit-key": settings.MINO_INCREASED_RATELIMIT_KEY},
timeout=httpx.Timeout(None, connect=2),
)
if response.status_code == 404:
if response.status_code in (404, 451):
return BeatmapMirrorResponse(
data=None,
is_success=True,
Expand Down Expand Up @@ -61,7 +61,7 @@ async def fetch_beatmap_background_image(
f"{self.base_url}/preview/background/{beatmap_id}",
timeout=httpx.Timeout(None, connect=2),
)
if response.status_code == 404:
if response.status_code in (404, 451):
return BeatmapMirrorResponse(
data=None,
is_success=True,
Expand Down
2 changes: 1 addition & 1 deletion app/adapters/osu_mirrors/backends/nerinyan.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ async def fetch_beatmap_zip_data(
response = await self.http_client.get(
f"{self.base_url}/d/{beatmapset_id}",
)
if response.status_code == 404:
if response.status_code in (404, 451):
return BeatmapMirrorResponse(
data=None,
is_success=True,
Expand Down
4 changes: 2 additions & 2 deletions app/adapters/osu_mirrors/backends/osu_direct.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ async def fetch_beatmap_zip_data(
f"{self.base_url}/api/d/{beatmapset_id}",
timeout=httpx.Timeout(None, connect=2),
)
if response.status_code == 404:
if response.status_code in (404, 451):
return BeatmapMirrorResponse(
data=None,
is_success=True,
Expand Down Expand Up @@ -58,7 +58,7 @@ async def fetch_beatmap_background_image(
f"{self.base_url}/api/media/background/{beatmap_id}",
timeout=httpx.Timeout(None, connect=2),
)
if response.status_code == 404:
if response.status_code in (404, 451):
return BeatmapMirrorResponse(
data=None,
is_success=True,
Expand Down
2 changes: 1 addition & 1 deletion app/adapters/osu_mirrors/backends/ripple.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ async def fetch_beatmap_zip_data(
response = await self.http_client.get(
f"{self.base_url}/d/{beatmapset_id}",
)
if response.status_code == 404:
if response.status_code in (404, 451):
return BeatmapMirrorResponse(
data=None,
is_success=True,
Expand Down