Skip to content

Commit 71efa2b

Browse files
author
Arav K.
committed
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 a119af7 commit 71efa2b

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
@@ -82,11 +82,8 @@ class CAAHelper:
8282
MBID_RELEASE = "rid"
8383
MBID_GROUP = "rgid"
8484

85-
RELEASE_URL = f"coverartarchive.org/release/{MBID_RELEASE}"
86-
GROUP_URL = f"coverartarchive.org/release-group/{MBID_GROUP}"
87-
88-
RELEASE_URL = "https://" + RELEASE_URL
89-
GROUP_URL = "https://" + GROUP_URL
85+
RELEASE_URL = f"https://coverartarchive.org/release/{MBID_RELEASE}"
86+
GROUP_URL = f"https://coverartarchive.org/release-group/{MBID_GROUP}"
9087

9188
RESPONSE_RELEASE = """{
9289
"images": [

test/plugins/test_ipfs.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ def test_stored_hashes(self):
4848
ipfs_item = os.path.basename(want_item.path).decode(
4949
_fsencoding(),
5050
)
51-
want_path = f"/ipfs/{test_album.ipfs}/{ipfs_item}"
51+
want_path = "/ipfs/{}/{}".format(test_album.ipfs, ipfs_item)
5252
want_path = bytestring_path(want_path)
5353
self.assertEqual(check_item.path, want_path)
5454
self.assertEqual(

0 commit comments

Comments
 (0)