Skip to content

Commit

Permalink
Add spotify playlists exclusion
Browse files Browse the repository at this point in the history
  • Loading branch information
jmlrt committed Jan 3, 2025
1 parent 772927a commit edf38b0
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
5 changes: 5 additions & 0 deletions spotfm.example.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,8 @@ password_hash = ""
[spotify]
client_id = ""
client_secret = ""

excluded_playlists = [
# <id_of_playlist_to exclude>,
# ...
]
6 changes: 3 additions & 3 deletions spotfm/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ def count_tracks_by_playlists():
print(f"{playlist}: {count}")


def update_playlists(client):
client.update_playlists()
def update_playlists(client, excluded_playlists):
client.update_playlists(excluded_playlists)


def lastfm_cli(args, config):
Expand Down Expand Up @@ -51,7 +51,7 @@ def spotify_cli(args, config):
case "count-tracks":
count_tracks(args.playlists)
case "update-playlists":
update_playlists(client)
update_playlists(client, config["spotify"]["excluded_playlists"])


def main():
Expand Down
6 changes: 3 additions & 3 deletions spotfm/spotify.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def __init__(self, client_id, client_secret, redirect_uri=REDIRECT_URI, scope=SC
redirect_uri=redirect_uri,
scope=scope,
cache_handler=handler,
)
),
)

def get_playlists_id(self, excluded_playlists=[]):
Expand All @@ -49,8 +49,8 @@ def filter_playlists(playlists):

return playlists_ids

def update_playlists(self):
playlists_id = self.get_playlists_id()
def update_playlists(self, excluded_playlists=[]):
playlists_id = self.get_playlists_id(excluded_playlists)
utils.query_db(utils.DATABASE, ["DELETE FROM playlists", "DELETE FROM playlists_tracks"])
for playlist_id in playlists_id:
Playlist(playlist_id, self.client)
Expand Down

0 comments on commit edf38b0

Please sign in to comment.