Skip to content

Commit

Permalink
fix: Beatmap.url returning an incomplete URL (#545)
Browse files Browse the repository at this point in the history
* Replace `Beatmap.url`'s `/s/sid#mode/bid` with `/b/bid`

* Update beatmap.py

* more fixes for beatmap urls

---------

Co-authored-by: cmyui <[email protected]>
  • Loading branch information
minisbett and cmyui authored Nov 29, 2023
1 parent 76158cc commit a98103c
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 11 deletions.
4 changes: 3 additions & 1 deletion app/api/domains/cho.py
Original file line number Diff line number Diff line change
Expand Up @@ -1539,7 +1539,9 @@ async def handle(self, player: Player) -> None:
elif player.match.map_id == -1:
if player.match.prev_map_id != self.match_data.map_id:
# new map has been chosen, send to match chat.
map_url = f"https://osu.{app.settings.DOMAIN}/beatmapsets/#/{self.match_data.map_id}"
map_url = (
f"https://osu.{app.settings.DOMAIN}/b/{self.match_data.map_id}"
)
map_embed = f"[{map_url} {self.match_data.map_name}]"
player.match.chat.send_bot(f"Selected: {map_embed}.")

Expand Down
5 changes: 1 addition & 4 deletions app/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -352,10 +352,7 @@ async def recent(ctx: Context) -> str | None:
return " | ".join(l)


TOP_SCORE_FMTSTR = (
"{idx}. ({pp:.2f}pp) [https://osu.{domain}/beatmapsets/{map_set_id}/{map_id} "
"{artist} - {title} [{version}]]"
)
TOP_SCORE_FMTSTR = "{idx}. ({pp:.2f}pp) [https://osu.{domain}/b/{map_id} {artist} - {title} [{version}]]"


@command(Privileges.UNRESTRICTED, hidden=True)
Expand Down
10 changes: 5 additions & 5 deletions app/objects/beatmap.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ class Beatmap:
Properties:
Beatmap.full -> str # Artist - Title [Version]
Beatmap.url -> str # https://osu.cmyui.xyz/beatmapsets/123/321
Beatmap.url -> str # https://osu.cmyui.xyz/b/321
Beatmap.embed -> str # [{url} {full}]
Beatmap.has_leaderboard -> bool
Expand Down Expand Up @@ -300,7 +300,7 @@ def full_name(self) -> str:
@property
def url(self) -> str:
"""The osu! beatmap url for `self`."""
return f"https://osu.{app.settings.DOMAIN}/beatmapsets/{self.set.id}/{self.id}"
return f"https://osu.{app.settings.DOMAIN}/b/{self.id}"

@property
def embed(self) -> str:
Expand Down Expand Up @@ -552,7 +552,7 @@ class BeatmapSet:
BeatmapSet.all_officially_loved() -> bool
Properties:
BeatmapSet.url -> str # https://osu.cmyui.xyz/beatmapsets/123
BeatmapSet.url -> str # https://osu.cmyui.xyz/s/123
Lower level API:
await BeatmapSet._from_bsid_cache(bsid: int) -> BeatmapSet | None
Expand Down Expand Up @@ -584,9 +584,9 @@ def __repr__(self) -> str:
return ", ".join(map_names)

@property
def url(self) -> str: # same as above, just no beatmap id
def url(self) -> str:
"""The online url for this beatmap set."""
return f"https://osu.{app.settings.DOMAIN}/beatmapsets/{self.id}"
return f"https://osu.{app.settings.DOMAIN}/s/{self.id}"

def any_beatmaps_have_official_leaderboards(self) -> bool:
"""Whether all the maps in the set have leaderboards on official servers."""
Expand Down
2 changes: 1 addition & 1 deletion app/objects/match.py
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ def url(self) -> str:
@property
def map_url(self) -> str:
"""The osu! beatmap url for `self`'s map."""
return f"https://osu.{app.settings.DOMAIN}/beatmapsets/#/{self.map_id}"
return f"https://osu.{app.settings.DOMAIN}/b/{self.map_id}"

@property
def embed(self) -> str:
Expand Down

0 comments on commit a98103c

Please sign in to comment.