Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit a815aaa

Browse files
author
Arav K.
committedSep 8, 2024
Revert to 'str.format' for most URLs
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)>
1 parent 15c8ac3 commit a815aaa

File tree

4 files changed

+14
-11
lines changed

4 files changed

+14
-11
lines changed
 

‎beetsplug/beatport.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -229,8 +229,8 @@ def __init__(self, data):
229229
if "category" in data:
230230
self.category = data["category"]
231231
if "slug" in data:
232-
self.url = (
233-
f"https://beatport.com/release/{data['slug']}/{data['id']}"
232+
self.url = "https://beatport.com/release/{}/{}".format(
233+
data["slug"], data["id"]
234234
)
235235
self.genre = data.get("genre")
236236

@@ -257,7 +257,9 @@ def __init__(self, data):
257257
except ValueError:
258258
pass
259259
if "slug" in data:
260-
self.url = f"https://beatport.com/track/{data['slug']}/{data['id']}"
260+
self.url = "https://beatport.com/track/{}/{}".format(
261+
data["slug"], data["id"]
262+
)
261263
self.track_number = data.get("trackNumber")
262264
self.bpm = data.get("bpm")
263265
self.initial_key = str((data.get("key") or {}).get("shortName"))

‎beetsplug/plexupdate.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@ def get_music_section(
2222
):
2323
"""Getting the section key for the music library in Plex."""
2424
api_endpoint = append_token("library/sections", token)
25-
url = urljoin(f"{get_protocol(secure)}://{host}:{port}", api_endpoint)
25+
url = urljoin(
26+
"{}://{}:{}".format(get_protocol(secure), host, port), api_endpoint
27+
)
2628

2729
# Sends request.
2830
r = requests.get(
@@ -52,7 +54,9 @@ def update_plex(host, port, token, library_name, secure, ignore_cert_errors):
5254
)
5355
api_endpoint = f"library/sections/{section_key}/refresh"
5456
api_endpoint = append_token(api_endpoint, token)
55-
url = urljoin(f"{get_protocol(secure)}://{host}:{port}", api_endpoint)
57+
url = urljoin(
58+
"{}://{}:{}".format(get_protocol(secure), host, port), api_endpoint
59+
)
5660

5761
# Sends request and returns requests object.
5862
r = requests.get(

‎test/plugins/test_art.py

+2-5
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,8 @@ class CAAHelper:
6767
MBID_RELEASE = "rid"
6868
MBID_GROUP = "rgid"
6969

70-
RELEASE_URL = f"coverartarchive.org/release/{MBID_RELEASE}"
71-
GROUP_URL = f"coverartarchive.org/release-group/{MBID_GROUP}"
72-
73-
RELEASE_URL = "https://" + RELEASE_URL
74-
GROUP_URL = "https://" + GROUP_URL
70+
RELEASE_URL = f"https://coverartarchive.org/release/{MBID_RELEASE}"
71+
GROUP_URL = f"https://coverartarchive.org/release-group/{MBID_GROUP}"
7572

7673
RESPONSE_RELEASE = """{
7774
"images": [

‎test/plugins/test_ipfs.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ def test_stored_hashes(self):
3939
ipfs_item = os.path.basename(want_item.path).decode(
4040
_fsencoding(),
4141
)
42-
want_path = f"/ipfs/{test_album.ipfs}/{ipfs_item}"
42+
want_path = "/ipfs/{}/{}".format(test_album.ipfs, ipfs_item)
4343
want_path = bytestring_path(want_path)
4444
assert check_item.path == want_path
4545
assert (

0 commit comments

Comments
 (0)
Please sign in to comment.