def find_cached_playlist(name): """Returns the ID of the playlist with this name or something close enough to it, if it's in the playlist cache. Returns None if no such ID found.""" playlists = {} # name: id for filename in CATEGORIES.keys(): group = CachedPlaylistGroup.from_filename(filename) playlists.update({playlist.name: playlist for playlist in group}) matches = difflib.get_close_matches(name, playlists.keys(), n=1) if matches: return playlists[matches[0]] matches = difflib.get_close_matches("WCS " + name, playlists.keys(), n=1) if matches: return playlists[matches[0]] return None
sp.playlist_remove( playlist_id, ["spotify:track:" + track_id for track_id in found_in_playlist]) def log_output(message): print(message) if args.confirm_remove: args.output_file.write(message + "\n") log_output("=== " + datetime.datetime.now().isoformat() + " ===") handle_playlist(ALL_PLAYLIST_ID, ALL_PLAYLIST_NAME) for filename in CATEGORIES.keys(): playlists = json.load(open(filename)) for playlist in playlists: if playlist['id'] == REMOVED_PLAYLIST_ID: continue handle_playlist(playlist['id'], playlist['name']) for item in removed_items: if len(removed_track_playlists[item.track.id]) == 0: continue remove_string = "Removed" if args.confirm_remove else "Would remove" log_output( "{remove_string} [{track_id}] \"{name}\" ({artist}), which was in:". format( remove_string=remove_string,
def all_cached_playlists(): group = CachedPlaylistGroup() for filename in CATEGORIES.keys(): group.add_from_filename(filename) return group
def selectCategory(self, category): """ set a filter """ category = str(category) if not category in CATEGORIES.keys(): category = None self.database.search(category)