Skip to content

Commit

Permalink
Revert to 'str.format' for most URLs
Browse files Browse the repository at this point in the history
In cases where the values being filled in did not intuitively describe
what they represented as URL components, it became difficult to figure
out the structure of the URL.

See: <beetbox#5337 (comment)>
  • Loading branch information
Arav K. committed Sep 8, 2024
1 parent b600151 commit 99fd824
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 11 deletions.
8 changes: 5 additions & 3 deletions beetsplug/beatport.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,8 +229,8 @@ def __init__(self, data):
if "category" in data:
self.category = data["category"]
if "slug" in data:
self.url = (
f"https://beatport.com/release/{data['slug']}/{data['id']}"
self.url = "https://beatport.com/release/{}/{}".format(
data["slug"], data["id"]
)
self.genre = data.get("genre")

Expand All @@ -257,7 +257,9 @@ def __init__(self, data):
except ValueError:
pass
if "slug" in data:
self.url = f"https://beatport.com/track/{data['slug']}/{data['id']}"
self.url = "https://beatport.com/track/{}/{}".format(
data["slug"], data["id"]
)
self.track_number = data.get("trackNumber")
self.bpm = data.get("bpm")
self.initial_key = str((data.get("key") or {}).get("shortName"))
Expand Down
8 changes: 6 additions & 2 deletions beetsplug/plexupdate.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ def get_music_section(
):
"""Getting the section key for the music library in Plex."""
api_endpoint = append_token("library/sections", token)
url = urljoin(f"{get_protocol(secure)}://{host}:{port}", api_endpoint)
url = urljoin(
"{}://{}:{}".format(get_protocol(secure), host, port), api_endpoint
)

# Sends request.
r = requests.get(
Expand Down Expand Up @@ -52,7 +54,9 @@ def update_plex(host, port, token, library_name, secure, ignore_cert_errors):
)
api_endpoint = f"library/sections/{section_key}/refresh"
api_endpoint = append_token(api_endpoint, token)
url = urljoin(f"{get_protocol(secure)}://{host}:{port}", api_endpoint)
url = urljoin(
"{}://{}:{}".format(get_protocol(secure), host, port), api_endpoint
)

# Sends request and returns requests object.
r = requests.get(
Expand Down
7 changes: 2 additions & 5 deletions test/plugins/test_art.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,8 @@ class CAAHelper:
MBID_RELEASE = "rid"
MBID_GROUP = "rgid"

RELEASE_URL = f"coverartarchive.org/release/{MBID_RELEASE}"
GROUP_URL = f"coverartarchive.org/release-group/{MBID_GROUP}"

RELEASE_URL = "https://" + RELEASE_URL
GROUP_URL = "https://" + GROUP_URL
RELEASE_URL = f"https://coverartarchive.org/release/{MBID_RELEASE}"
GROUP_URL = f"https://coverartarchive.org/release-group/{MBID_GROUP}"

RESPONSE_RELEASE = """{
"images": [
Expand Down
2 changes: 1 addition & 1 deletion test/plugins/test_ipfs.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def test_stored_hashes(self):
ipfs_item = os.path.basename(want_item.path).decode(
_fsencoding(),
)
want_path = f"/ipfs/{test_album.ipfs}/{ipfs_item}"
want_path = "/ipfs/{}/{}".format(test_album.ipfs, ipfs_item)
want_path = bytestring_path(want_path)
assert check_item.path == want_path
assert (
Expand Down

0 comments on commit 99fd824

Please sign in to comment.