forked from Wobbl/Wobuzz
Implemented deletion of playlists.
This commit is contained in:
parent
5ecc70e637
commit
96a9985099
3 changed files with 34 additions and 9 deletions
|
@ -128,14 +128,31 @@ class Playlist:
|
|||
wbz.write(wbz_data)
|
||||
wbz.close()
|
||||
|
||||
def delete(self):
|
||||
# remove from unique names so a new playlist can have the old name
|
||||
self.app.utils.unique_names.remove(self.title)
|
||||
def rename(self, title: str):
|
||||
# remove from unique names so a new playlist can have the old name and delete old playlist.
|
||||
|
||||
path = f"{self.app.settings.library_path}/playlists/{self.title.replace(" ", "_")}.wbz.m3u"
|
||||
path = os.path.expanduser(path)
|
||||
|
||||
if os.path.exists(path):
|
||||
os.remove(os.path.expanduser(path))
|
||||
|
||||
old_title = self.title
|
||||
self.title = self.app.utils.unique_name(title, ignore=old_title)
|
||||
|
||||
if not old_title == self.title: # remove only when the playlist actually has a different name
|
||||
self.app.utils.unique_names.remove(old_title)
|
||||
|
||||
def delete(self):
|
||||
path = f"{self.app.settings.library_path}/playlists/{self.title.replace(" ", "_")}.wbz.m3u"
|
||||
path = os.path.expanduser(path)
|
||||
|
||||
if os.path.exists(path):
|
||||
os.remove(os.path.expanduser(path))
|
||||
|
||||
self.app.utils.unique_names.remove(self.title)
|
||||
self.app.library.playlists.remove(self)
|
||||
|
||||
def append_track(self, track):
|
||||
self.tracks.append(track)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue