Skip to content

Commit 35c6e13

Browse files
committed
Update line length
1 parent 3586669 commit 35c6e13

File tree

1 file changed

+24
-8
lines changed

1 file changed

+24
-8
lines changed

beetsplug/listenbrainz.py

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -116,9 +116,13 @@ def get_tracks_from_listens(self, listens):
116116
mbid = self.get_mb_recording_id(track)
117117
tracks.append(
118118
{
119-
"album": {"name": track["track_metadata"].get("release_name")},
119+
"album": {
120+
"name": track["track_metadata"].get("release_name")
121+
},
120122
"name": track["track_metadata"].get("track_name"),
121-
"artist": {"name": track["track_metadata"].get("artist_name")},
123+
"artist": {
124+
"name": track["track_metadata"].get("artist_name")
125+
},
122126
"mbid": mbid,
123127
"release_mbid": mbid_mapping.get("release_mbid"),
124128
"listened_at": track.get("listened_at"),
@@ -153,23 +157,31 @@ def get_listenbrainz_playlists(self):
153157
if playlist_info.get("creator") == "listenbrainz":
154158
title = playlist_info.get("title")
155159
self._log.debug(f"Playlist title: {title}")
156-
playlist_type = "Exploration" if "Exploration" in title else "Jams"
160+
playlist_type = (
161+
"Exploration" if "Exploration" in title else "Jams"
162+
)
157163
if "week of" in title:
158164
date_str = title.split("week of ")[1].split(" ")[0]
159-
date = datetime.datetime.strptime(date_str, "%Y-%m-%d").date()
165+
date = datetime.datetime.strptime(
166+
date_str, "%Y-%m-%d"
167+
).date()
160168
else:
161169
continue
162170
identifier = playlist_info.get("identifier")
163171
id = identifier.split("/")[-1]
164172
listenbrainz_playlists.append(
165173
{"type": playlist_type, "date": date, "identifier": id}
166174
)
167-
listenbrainz_playlists = sorted(listenbrainz_playlists, key=lambda x: x["type"])
175+
listenbrainz_playlists = sorted(
176+
listenbrainz_playlists, key=lambda x: x["type"]
177+
)
168178
listenbrainz_playlists = sorted(
169179
listenbrainz_playlists, key=lambda x: x["date"], reverse=True
170180
)
171181
for playlist in listenbrainz_playlists:
172-
self._log.debug(f'Playlist: {playlist["type"]} - {playlist["date"]}')
182+
self._log.debug(
183+
f'Playlist: {playlist["type"]} - {playlist["date"]}'
184+
)
173185
return listenbrainz_playlists
174186

175187
def get_playlist(self, identifier):
@@ -231,13 +243,17 @@ def get_weekly_playlist(self, playlist_type, most_recent=True):
231243
# Fetch all playlists
232244
playlists = self.get_listenbrainz_playlists()
233245
# Filter playlists by type
234-
filtered_playlists = [p for p in playlists if p["type"] == playlist_type]
246+
filtered_playlists = [
247+
p for p in playlists if p["type"] == playlist_type
248+
]
235249
# Sort playlists by date in descending order
236250
sorted_playlists = sorted(
237251
filtered_playlists, key=lambda x: x["date"], reverse=True
238252
)
239253
# Select the most recent or older playlist based on the most_recent flag
240-
selected_playlist = sorted_playlists[0] if most_recent else sorted_playlists[1]
254+
selected_playlist = (
255+
sorted_playlists[0] if most_recent else sorted_playlists[1]
256+
)
241257
self._log.debug(
242258
f"Selected playlist: {selected_playlist['type']} - {selected_playlist['date']}"
243259
)

0 commit comments

Comments
 (0)