Skip to content

Commit

Permalink
Update line length
Browse files Browse the repository at this point in the history
  • Loading branch information
arsaboo committed Nov 11, 2024
1 parent 3586669 commit 35c6e13
Showing 1 changed file with 24 additions and 8 deletions.
32 changes: 24 additions & 8 deletions beetsplug/listenbrainz.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,13 @@ def get_tracks_from_listens(self, listens):
mbid = self.get_mb_recording_id(track)
tracks.append(
{
"album": {"name": track["track_metadata"].get("release_name")},
"album": {
"name": track["track_metadata"].get("release_name")
},
"name": track["track_metadata"].get("track_name"),
"artist": {"name": track["track_metadata"].get("artist_name")},
"artist": {
"name": track["track_metadata"].get("artist_name")
},
"mbid": mbid,
"release_mbid": mbid_mapping.get("release_mbid"),
"listened_at": track.get("listened_at"),
Expand Down Expand Up @@ -153,23 +157,31 @@ def get_listenbrainz_playlists(self):
if playlist_info.get("creator") == "listenbrainz":
title = playlist_info.get("title")
self._log.debug(f"Playlist title: {title}")
playlist_type = "Exploration" if "Exploration" in title else "Jams"
playlist_type = (
"Exploration" if "Exploration" in title else "Jams"
)
if "week of" in title:
date_str = title.split("week of ")[1].split(" ")[0]
date = datetime.datetime.strptime(date_str, "%Y-%m-%d").date()
date = datetime.datetime.strptime(
date_str, "%Y-%m-%d"
).date()
else:
continue
identifier = playlist_info.get("identifier")
id = identifier.split("/")[-1]
listenbrainz_playlists.append(
{"type": playlist_type, "date": date, "identifier": id}
)
listenbrainz_playlists = sorted(listenbrainz_playlists, key=lambda x: x["type"])
listenbrainz_playlists = sorted(
listenbrainz_playlists, key=lambda x: x["type"]
)
listenbrainz_playlists = sorted(
listenbrainz_playlists, key=lambda x: x["date"], reverse=True
)
for playlist in listenbrainz_playlists:
self._log.debug(f'Playlist: {playlist["type"]} - {playlist["date"]}')
self._log.debug(
f'Playlist: {playlist["type"]} - {playlist["date"]}'
)
return listenbrainz_playlists

def get_playlist(self, identifier):
Expand Down Expand Up @@ -231,13 +243,17 @@ def get_weekly_playlist(self, playlist_type, most_recent=True):
# Fetch all playlists
playlists = self.get_listenbrainz_playlists()
# Filter playlists by type
filtered_playlists = [p for p in playlists if p["type"] == playlist_type]
filtered_playlists = [
p for p in playlists if p["type"] == playlist_type
]
# Sort playlists by date in descending order
sorted_playlists = sorted(
filtered_playlists, key=lambda x: x["date"], reverse=True
)
# Select the most recent or older playlist based on the most_recent flag
selected_playlist = sorted_playlists[0] if most_recent else sorted_playlists[1]
selected_playlist = (
sorted_playlists[0] if most_recent else sorted_playlists[1]
)
self._log.debug(
f"Selected playlist: {selected_playlist['type']} - {selected_playlist['date']}"

Check failure on line 258 in beetsplug/listenbrainz.py

View workflow job for this annotation

GitHub Actions / Check linting

Ruff (E501)

beetsplug/listenbrainz.py:258:89: E501 Line too long (91 > 88)
)
Expand Down

0 comments on commit 35c6e13

Please sign in to comment.