Add Export Playist
This commit is contained in:
parent
280e966f01
commit
a35181bae7
@ -122,6 +122,7 @@ class Window(QMainWindow, Ui_MainWindow):
|
|||||||
self.actionAdd_file.triggered.connect(self.add_file)
|
self.actionAdd_file.triggered.connect(self.add_file)
|
||||||
self.action_Clear_selection.triggered.connect(self.clear_selection)
|
self.action_Clear_selection.triggered.connect(self.clear_selection)
|
||||||
self.actionClosePlaylist.triggered.connect(self.close_playlist)
|
self.actionClosePlaylist.triggered.connect(self.close_playlist)
|
||||||
|
self.actionExport_playlist.triggered.connect(self.export_playlist)
|
||||||
self.actionFade.triggered.connect(self.fade)
|
self.actionFade.triggered.connect(self.fade)
|
||||||
self.actionMoveSelected.triggered.connect(self.move_selected)
|
self.actionMoveSelected.triggered.connect(self.move_selected)
|
||||||
self.actionNewPlaylist.triggered.connect(self.create_playlist)
|
self.actionNewPlaylist.triggered.connect(self.create_playlist)
|
||||||
@ -195,6 +196,39 @@ class Window(QMainWindow, Ui_MainWindow):
|
|||||||
DEBUG("enable_play_next_controls()")
|
DEBUG("enable_play_next_controls()")
|
||||||
self.actionPlay_next.setEnabled(True)
|
self.actionPlay_next.setEnabled(True)
|
||||||
|
|
||||||
|
def export_playlist(self):
|
||||||
|
"Export the current playlist to an m3u file"
|
||||||
|
|
||||||
|
if not self.visible_playlist():
|
||||||
|
return
|
||||||
|
|
||||||
|
# Get output filename
|
||||||
|
pathspec = QFileDialog.getSaveFileName(
|
||||||
|
self, 'Save Playlist',
|
||||||
|
directory=f"{self.visible_playlist().db.name}.m3u",
|
||||||
|
filter="M3U files (*.m3u);;All files (*.*)"
|
||||||
|
)
|
||||||
|
if not pathspec:
|
||||||
|
return
|
||||||
|
|
||||||
|
path = 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.visible_playlist().db.get_tracks():
|
||||||
|
f.write(
|
||||||
|
"#EXTINF:"
|
||||||
|
f"{int(track.duration / 1000)},"
|
||||||
|
f"{track.title} - "
|
||||||
|
f"{track.artist}"
|
||||||
|
"\n"
|
||||||
|
f"{track.path}"
|
||||||
|
"\n"
|
||||||
|
)
|
||||||
|
|
||||||
def fade(self):
|
def fade(self):
|
||||||
"Fade currently playing track"
|
"Fade currently playing track"
|
||||||
|
|
||||||
|
|||||||
@ -751,7 +751,7 @@ border: 1px solid rgb(85, 87, 83);</string>
|
|||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>1164</width>
|
<width>1164</width>
|
||||||
<height>29</height>
|
<height>18</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<widget class="QMenu" name="menuFile">
|
<widget class="QMenu" name="menuFile">
|
||||||
@ -775,6 +775,8 @@ border: 1px solid rgb(85, 87, 83);</string>
|
|||||||
<addaction name="action_Clear_selection"/>
|
<addaction name="action_Clear_selection"/>
|
||||||
<addaction name="separator"/>
|
<addaction name="separator"/>
|
||||||
<addaction name="actionMoveSelected"/>
|
<addaction name="actionMoveSelected"/>
|
||||||
|
<addaction name="separator"/>
|
||||||
|
<addaction name="actionExport_playlist"/>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QMenu" name="menu_Tracks">
|
<widget class="QMenu" name="menu_Tracks">
|
||||||
<property name="title">
|
<property name="title">
|
||||||
@ -958,6 +960,11 @@ border: 1px solid rgb(85, 87, 83);</string>
|
|||||||
<string>Mo&ve selected tracks to...</string>
|
<string>Mo&ve selected tracks to...</string>
|
||||||
</property>
|
</property>
|
||||||
</action>
|
</action>
|
||||||
|
<action name="actionExport_playlist">
|
||||||
|
<property name="text">
|
||||||
|
<string>E&xport playlist...</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
</widget>
|
</widget>
|
||||||
<resources>
|
<resources>
|
||||||
<include location="icons.qrc"/>
|
<include location="icons.qrc"/>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user