Skip to content

Commit c6409d2

Browse files
committed
Retry listenbrainz requests for temporary failures
1 parent 2648561 commit c6409d2

2 files changed

Lines changed: 8 additions & 4 deletions

File tree

beetsplug/listenbrainz.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
from ._utils.musicbrainz import MusicBrainzAPIMixin
1717
from ._utils.playcount import update_play_counts
18+
from ._utils.requests import TimeoutAndRetrySession
1819

1920
if TYPE_CHECKING:
2021
from ._utils.playcount import Track
@@ -34,6 +35,7 @@ def __init__(self):
3435
super().__init__()
3536
self.token = self.config["token"].get()
3637
self.username = self.config["username"].get()
38+
self.session = TimeoutAndRetrySession()
3739
self.AUTH_HEADER = {"Authorization": f"Token {self.token}"}
3840
config["listenbrainz"]["token"].redact = True
3941

@@ -108,7 +110,7 @@ def _make_request(self, url, params=None):
108110
returning, so the next call is guaranteed a fresh quota.
109111
"""
110112
try:
111-
response = requests.get(
113+
response = self.session.get(
112114
url=url,
113115
headers=self.AUTH_HEADER,
114116
timeout=10,

docs/changelog.rst

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,11 @@ New features
2626
after upgrading to trigger the migration. Only then you can safely move
2727
the library to a new location.
2828

29-
..
30-
Bug fixes
31-
~~~~~~~~~
29+
Bug fixes
30+
~~~~~~~~~
31+
32+
- :doc:`plugins/listenbrainz`: Retry listenbrainz requests for temporary
33+
failures.
3234

3335
..
3436
For plugin developers

0 commit comments

Comments
 (0)