Fix playlist export
This commit is contained in:
parent
ca1b11b545
commit
1c56505ab0
@ -315,32 +315,35 @@ class Window(QMainWindow, Ui_MainWindow):
|
||||
if not self.visible_playlist_tab():
|
||||
return
|
||||
|
||||
# Get output filename
|
||||
pathspec: Tuple[str, str] = QFileDialog.getSaveFileName(
|
||||
self, 'Save Playlist',
|
||||
directory=f"{self.visible_playlist_tab().name}.m3u",
|
||||
filter="M3U files (*.m3u);;All files (*.*)"
|
||||
)
|
||||
if not pathspec:
|
||||
return
|
||||
with Session() as session:
|
||||
playlist = Playlists.get_by_id(
|
||||
session, self.visible_playlist_tab().playlist_id)
|
||||
# Get output filename
|
||||
pathspec: Tuple[str, str] = QFileDialog.getSaveFileName(
|
||||
self, 'Save Playlist',
|
||||
directory=f"{playlist.name}.m3u",
|
||||
filter="M3U files (*.m3u);;All files (*.*)"
|
||||
)
|
||||
if not pathspec:
|
||||
return
|
||||
|
||||
path: str = pathspec[0]
|
||||
if not path.endswith(".m3u"):
|
||||
path += ".m3u"
|
||||
path: str = pathspec[0]
|
||||
if not path.endswith(".m3u"):
|
||||
path += ".m3u"
|
||||
|
||||
with open(path, "w") as f:
|
||||
# Required directive on first line
|
||||
f.write("#EXTM3U\n")
|
||||
for track in self.playlist.tracks:
|
||||
f.write(
|
||||
"#EXTINF:"
|
||||
f"{int(track.duration / 1000)},"
|
||||
f"{track.title} - "
|
||||
f"{track.artist}"
|
||||
"\n"
|
||||
f"{track.path}"
|
||||
"\n"
|
||||
)
|
||||
with open(path, "w") as f:
|
||||
# Required directive on first line
|
||||
f.write("#EXTM3U\n")
|
||||
for _, track in playlist.tracks.items():
|
||||
f.write(
|
||||
"#EXTINF:"
|
||||
f"{int(track.duration / 1000)},"
|
||||
f"{track.title} - "
|
||||
f"{track.artist}"
|
||||
"\n"
|
||||
f"{track.path}"
|
||||
"\n"
|
||||
)
|
||||
|
||||
def fade(self) -> None:
|
||||
"""Fade currently playing track"""
|
||||
|
||||
Loading…
Reference in New Issue
Block a user