what
This commit is contained in:
parent
a22e246257
commit
aea3a6cdc3
@ -15,16 +15,22 @@ import logging
|
|||||||
|
|
||||||
|
|
||||||
class AddToPlaylistWindow(QDialog):
|
class AddToPlaylistWindow(QDialog):
|
||||||
def __init__(self, list_options: dict, song_db_ids: list):
|
def __init__(self, song_db_ids: list):
|
||||||
super(AddToPlaylistWindow, self).__init__()
|
super(AddToPlaylistWindow, self).__init__()
|
||||||
self.song_db_ids = song_db_ids
|
self.song_db_ids = song_db_ids
|
||||||
self.setWindowTitle("Add songs to playlist:")
|
self.setWindowTitle("Add songs to playlist:")
|
||||||
self.setMinimumSize(400, 400)
|
# self.setMinimumSize(400, 400)
|
||||||
layout = QVBoxLayout()
|
layout = QVBoxLayout()
|
||||||
|
|
||||||
|
playlist_dict: dict = {}
|
||||||
|
with DBA.DBAccess() as db:
|
||||||
|
data = db.query("SELECT id, name from playlist;", ())
|
||||||
|
for row in data:
|
||||||
|
playlist_dict[row[0]] = row[1]
|
||||||
|
|
||||||
self.item_dict = {}
|
self.item_dict = {}
|
||||||
self.listWidget = QListWidget(self)
|
self.listWidget = QListWidget(self)
|
||||||
for i, (k, v) in enumerate(list_options.items()):
|
for i, (k, v) in enumerate(playlist_dict.items()):
|
||||||
item_text = f"{i} | {v}"
|
item_text = f"{i} | {v}"
|
||||||
item = QListWidgetItem(item_text)
|
item = QListWidgetItem(item_text)
|
||||||
self.listWidget.addItem(item)
|
self.listWidget.addItem(item)
|
||||||
|
|||||||
68
components/ExportPlaylistWindow.py
Normal file
68
components/ExportPlaylistWindow.py
Normal file
@ -0,0 +1,68 @@
|
|||||||
|
import logging
|
||||||
|
from PyQt5.QtWidgets import (
|
||||||
|
QDialog,
|
||||||
|
QHBoxLayout,
|
||||||
|
QLineEdit,
|
||||||
|
QLabel,
|
||||||
|
QPushButton,
|
||||||
|
QVBoxLayout,
|
||||||
|
QListWidget,
|
||||||
|
QListWidgetItem,
|
||||||
|
)
|
||||||
|
from PyQt5.QtGui import QFont
|
||||||
|
import DBA
|
||||||
|
|
||||||
|
|
||||||
|
class ExportPlaylistWindow(QDialog):
|
||||||
|
def __init__(self):
|
||||||
|
super(ExportPlaylistWindow, self).__init__()
|
||||||
|
self.setWindowTitle("Export playlist")
|
||||||
|
layout = QVBoxLayout()
|
||||||
|
# button_layout = QHBoxLayout()
|
||||||
|
|
||||||
|
playlist_dict = {}
|
||||||
|
with DBA.DBAccess() as db:
|
||||||
|
data = db.query("SELECT id, name from playlist;", ())
|
||||||
|
for row in data:
|
||||||
|
playlist_dict[row[0]] = row[1]
|
||||||
|
|
||||||
|
self.item_dict = {}
|
||||||
|
self.listWidget = QListWidget(self)
|
||||||
|
for i, (k, v) in enumerate(playlist_dict.items()):
|
||||||
|
item_text = f"{i} | {v}"
|
||||||
|
item = QListWidgetItem(item_text)
|
||||||
|
self.listWidget.addItem(item)
|
||||||
|
self.item_dict[item_text] = k
|
||||||
|
|
||||||
|
# add ui elements to window
|
||||||
|
label = QLabel("Playlists")
|
||||||
|
label.setFont(QFont("Sans", weight=QFont.Bold))
|
||||||
|
layout.addWidget(label)
|
||||||
|
layout.addWidget(self.listWidget)
|
||||||
|
|
||||||
|
# Save button
|
||||||
|
save_button = QPushButton("Export")
|
||||||
|
save_button.clicked.connect(self.save)
|
||||||
|
layout.addWidget(save_button)
|
||||||
|
self.setLayout(layout)
|
||||||
|
self.show()
|
||||||
|
|
||||||
|
def save(self) -> None:
|
||||||
|
"""Exports the chosen database playlist to a .m3u file"""
|
||||||
|
value = self.input.text()
|
||||||
|
if value == "" or value is None:
|
||||||
|
self.close()
|
||||||
|
return
|
||||||
|
else:
|
||||||
|
try:
|
||||||
|
with DBA.DBAccess() as db:
|
||||||
|
db.execute("INSERT INTO playlist (name) VALUES (?);", (value,))
|
||||||
|
except Exception as e:
|
||||||
|
logging.error(
|
||||||
|
f"CreatePlaylistWindow.py save() | Could not create playlist: {e}"
|
||||||
|
)
|
||||||
|
self.close()
|
||||||
|
|
||||||
|
def cancel(self) -> None:
|
||||||
|
self.close()
|
||||||
|
return
|
||||||
@ -175,15 +175,7 @@ class MusicTable(QTableView):
|
|||||||
|
|
||||||
def add_selected_files_to_playlist(self):
|
def add_selected_files_to_playlist(self):
|
||||||
"""Opens a playlist choice menu and adds the currently selected files to the chosen playlist"""
|
"""Opens a playlist choice menu and adds the currently selected files to the chosen playlist"""
|
||||||
playlist_dict = {}
|
playlist_choice_window = AddToPlaylistWindow(self.get_selected_songs_db_ids())
|
||||||
print(type(playlist_dict))
|
|
||||||
with DBA.DBAccess() as db:
|
|
||||||
data = db.query("SELECT id, name from playlist;", ())
|
|
||||||
for row in data:
|
|
||||||
playlist_dict[row[0]] = row[1]
|
|
||||||
playlist_choice_window = AddToPlaylistWindow(
|
|
||||||
playlist_dict, self.get_selected_songs_db_ids()
|
|
||||||
)
|
|
||||||
playlist_choice_window.exec_()
|
playlist_choice_window.exec_()
|
||||||
|
|
||||||
def show_lyrics_menu(self):
|
def show_lyrics_menu(self):
|
||||||
|
|||||||
@ -7,3 +7,4 @@ from .LyricsWindow import LyricsWindow
|
|||||||
from .AddToPlaylistWindow import AddToPlaylistWindow
|
from .AddToPlaylistWindow import AddToPlaylistWindow
|
||||||
from .CreatePlaylistWindow import CreatePlaylistWindow
|
from .CreatePlaylistWindow import CreatePlaylistWindow
|
||||||
from .PlaylistsPane import PlaylistsPane
|
from .PlaylistsPane import PlaylistsPane
|
||||||
|
from .ExportPlaylistWindow import ExportPlaylistWindow
|
||||||
|
|||||||
17
main.py
17
main.py
@ -28,6 +28,7 @@ from components import (
|
|||||||
PreferencesWindow,
|
PreferencesWindow,
|
||||||
AudioVisualizer,
|
AudioVisualizer,
|
||||||
CreatePlaylistWindow,
|
CreatePlaylistWindow,
|
||||||
|
ExportPlaylistWindow,
|
||||||
)
|
)
|
||||||
|
|
||||||
# Create ui.py file from Qt Designer
|
# Create ui.py file from Qt Designer
|
||||||
@ -97,6 +98,7 @@ class ApplicationWindow(QMainWindow, Ui_MainWindow):
|
|||||||
# FILE MENU
|
# FILE MENU
|
||||||
self.actionOpenFiles.triggered.connect(self.open_files) # Open files window
|
self.actionOpenFiles.triggered.connect(self.open_files) # Open files window
|
||||||
self.actionNewPlaylist.triggered.connect(self.create_playlist)
|
self.actionNewPlaylist.triggered.connect(self.create_playlist)
|
||||||
|
self.actionExportPlaylist.triggered.connect(self.export_playlist)
|
||||||
# EDIT MENU
|
# EDIT MENU
|
||||||
# VIEW MENU
|
# VIEW MENU
|
||||||
self.actionPreferences.triggered.connect(
|
self.actionPreferences.triggered.connect(
|
||||||
@ -358,6 +360,21 @@ class ApplicationWindow(QMainWindow, Ui_MainWindow):
|
|||||||
create_playlist_window = CreatePlaylistWindow()
|
create_playlist_window = CreatePlaylistWindow()
|
||||||
create_playlist_window.exec_()
|
create_playlist_window.exec_()
|
||||||
|
|
||||||
|
def import_playlist(self) -> None:
|
||||||
|
"""
|
||||||
|
Imports a .m3u file, given a base path attempts to match playlist files to
|
||||||
|
database records that currently exist
|
||||||
|
"""
|
||||||
|
pass
|
||||||
|
|
||||||
|
def export_playlist(self) -> None:
|
||||||
|
"""
|
||||||
|
Export playlist window
|
||||||
|
Takes a certain database playlist and turns it into a .m3u file
|
||||||
|
"""
|
||||||
|
export_playlist_window = ExportPlaylistWindow()
|
||||||
|
export_playlist_window.exec_()
|
||||||
|
|
||||||
def open_preferences(self) -> None:
|
def open_preferences(self) -> None:
|
||||||
"""Opens the preferences window"""
|
"""Opens the preferences window"""
|
||||||
preferences_window = PreferencesWindow(self.config)
|
preferences_window = PreferencesWindow(self.config)
|
||||||
|
|||||||
@ -1,12 +0,0 @@
|
|||||||
#EXTM3U
|
|
||||||
#PLAYLIST:Playlist title
|
|
||||||
#EXTINF:100, Artist - Title
|
|
||||||
/path/to/file.mp3
|
|
||||||
#EXTINF:[length_of_song_in_seconds], Artist - Title
|
|
||||||
/path/to/file.mp3
|
|
||||||
|
|
||||||
# apparently also m3u can just be a list
|
|
||||||
#EXTM3U
|
|
||||||
/path/to/song.mp3
|
|
||||||
/path/to/song.mp3
|
|
||||||
/path/to/song.mp3
|
|
||||||
@ -13,5 +13,5 @@ extensions = mp3,wav,ogg,flac
|
|||||||
|
|
||||||
[table]
|
[table]
|
||||||
# Music table options
|
# Music table options
|
||||||
columns = title,artist,album,genre,codec,album_date,filepath
|
columns = title,artist,album,track_number,genre,codec,album_date,filepath
|
||||||
column_widths = 181,116,222,76,74,72,287
|
column_widths = 181,116,222,76,74,72,287,150
|
||||||
|
|||||||
4
ui.py
4
ui.py
@ -192,8 +192,11 @@ class Ui_MainWindow(object):
|
|||||||
self.actionDeleteDatabase.setObjectName("actionDeleteDatabase")
|
self.actionDeleteDatabase.setObjectName("actionDeleteDatabase")
|
||||||
self.actionNewPlaylist = QtWidgets.QAction(MainWindow)
|
self.actionNewPlaylist = QtWidgets.QAction(MainWindow)
|
||||||
self.actionNewPlaylist.setObjectName("actionNewPlaylist")
|
self.actionNewPlaylist.setObjectName("actionNewPlaylist")
|
||||||
|
self.actionExportPlaylist = QtWidgets.QAction(MainWindow)
|
||||||
|
self.actionExportPlaylist.setObjectName("actionExportPlaylist")
|
||||||
self.menuFile.addAction(self.actionOpenFiles)
|
self.menuFile.addAction(self.actionOpenFiles)
|
||||||
self.menuFile.addAction(self.actionNewPlaylist)
|
self.menuFile.addAction(self.actionNewPlaylist)
|
||||||
|
self.menuFile.addAction(self.actionExportPlaylist)
|
||||||
self.menuEdit.addAction(self.actionPreferences)
|
self.menuEdit.addAction(self.actionPreferences)
|
||||||
self.menuQuick_Actions.addAction(self.actionScanLibraries)
|
self.menuQuick_Actions.addAction(self.actionScanLibraries)
|
||||||
self.menuQuick_Actions.addAction(self.actionDeleteLibrary)
|
self.menuQuick_Actions.addAction(self.actionDeleteLibrary)
|
||||||
@ -229,5 +232,6 @@ class Ui_MainWindow(object):
|
|||||||
self.actionOpenFiles.setText(_translate("MainWindow", "Open file(s)"))
|
self.actionOpenFiles.setText(_translate("MainWindow", "Open file(s)"))
|
||||||
self.actionDeleteDatabase.setText(_translate("MainWindow", "Delete Database"))
|
self.actionDeleteDatabase.setText(_translate("MainWindow", "Delete Database"))
|
||||||
self.actionNewPlaylist.setText(_translate("MainWindow", "New playlist"))
|
self.actionNewPlaylist.setText(_translate("MainWindow", "New playlist"))
|
||||||
|
self.actionExportPlaylist.setText(_translate("MainWindow", "Export playlist"))
|
||||||
from components import AlbumArtGraphicsView, MusicTable, PlaylistsPane
|
from components import AlbumArtGraphicsView, MusicTable, PlaylistsPane
|
||||||
from pyqtgraph import PlotWidget
|
from pyqtgraph import PlotWidget
|
||||||
|
|||||||
6
ui.ui
6
ui.ui
@ -308,6 +308,7 @@
|
|||||||
</property>
|
</property>
|
||||||
<addaction name="actionOpenFiles"/>
|
<addaction name="actionOpenFiles"/>
|
||||||
<addaction name="actionNewPlaylist"/>
|
<addaction name="actionNewPlaylist"/>
|
||||||
|
<addaction name="actionExportPlaylist"/>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QMenu" name="menuEdit">
|
<widget class="QMenu" name="menuEdit">
|
||||||
<property name="title">
|
<property name="title">
|
||||||
@ -367,6 +368,11 @@
|
|||||||
<string>New playlist</string>
|
<string>New playlist</string>
|
||||||
</property>
|
</property>
|
||||||
</action>
|
</action>
|
||||||
|
<action name="actionExportPlaylist">
|
||||||
|
<property name="text">
|
||||||
|
<string>Export playlist</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
</widget>
|
</widget>
|
||||||
<customwidgets>
|
<customwidgets>
|
||||||
<customwidget>
|
<customwidget>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user