Export played tracks csv works
This commit is contained in:
parent
63acc025f9
commit
9485b244f5
@ -249,13 +249,20 @@ class Playdates(Base):
|
|||||||
return last_played[0]
|
return last_played[0]
|
||||||
else:
|
else:
|
||||||
return None
|
return None
|
||||||
#
|
|
||||||
# @staticmethod
|
@staticmethod
|
||||||
# def played_after(session: Session, since: datetime) -> List["Playdates"]:
|
def played_after(session: Session, since: datetime) -> List["Playdates"]:
|
||||||
# """Return a list of Playdates objects since passed time"""
|
"""Return a list of Playdates objects since passed time"""
|
||||||
#
|
|
||||||
# return session.query(Playdates).filter(
|
return (
|
||||||
# Playdates.lastplayed >= since).all()
|
session.execute(
|
||||||
|
select(Playdates)
|
||||||
|
.where(Playdates.lastplayed >= since)
|
||||||
|
.order_by(Playdates.lastplayed)
|
||||||
|
)
|
||||||
|
.scalars()
|
||||||
|
.all()
|
||||||
|
)
|
||||||
#
|
#
|
||||||
# @staticmethod
|
# @staticmethod
|
||||||
# def remove_track(session: Session, track_id: int) -> None:
|
# def remove_track(session: Session, track_id: int) -> None:
|
||||||
|
|||||||
@ -7,14 +7,13 @@ import sys
|
|||||||
|
|
||||||
from datetime import datetime, timedelta
|
from datetime import datetime, timedelta
|
||||||
# from typing import Callable, Dict, List, Optional, Tuple
|
# from typing import Callable, Dict, List, Optional, Tuple
|
||||||
#
|
|
||||||
# from PyQt5.QtCore import QDate, QProcess, Qt, QTime, QTimer, QUrl
|
from PyQt5.QtCore import QDate, QEvent, Qt, QTime, QTimer
|
||||||
from PyQt5.QtCore import QEvent, Qt, QTimer
|
|
||||||
from PyQt5.QtGui import QColor
|
from PyQt5.QtGui import QColor
|
||||||
from PyQt5.QtWidgets import (
|
from PyQt5.QtWidgets import (
|
||||||
QApplication,
|
QApplication,
|
||||||
QDialog,
|
QDialog,
|
||||||
# QFileDialog,
|
QFileDialog,
|
||||||
# QInputDialog,
|
# QInputDialog,
|
||||||
QLabel,
|
QLabel,
|
||||||
# QLineEdit,
|
# QLineEdit,
|
||||||
@ -39,7 +38,7 @@ from playlists import PlaylistTab
|
|||||||
from sqlalchemy.orm.exc import DetachedInstanceError
|
from sqlalchemy.orm.exc import DetachedInstanceError
|
||||||
# from ui.dlg_search_database_ui import Ui_Dialog
|
# from ui.dlg_search_database_ui import Ui_Dialog
|
||||||
from ui.dlg_SelectPlaylist_ui import Ui_dlgSelectPlaylist # type: ignore
|
from ui.dlg_SelectPlaylist_ui import Ui_dlgSelectPlaylist # type: ignore
|
||||||
# from ui.downloadcsv_ui import Ui_DateSelect
|
from ui.downloadcsv_ui import Ui_DateSelect # type: ignore
|
||||||
from config import Config
|
from config import Config
|
||||||
from ui.main_window_ui import Ui_MainWindow # type: ignore
|
from ui.main_window_ui import Ui_MainWindow # type: ignore
|
||||||
# from utilities import create_track_from_file, update_db
|
# from utilities import create_track_from_file, update_db
|
||||||
@ -171,8 +170,9 @@ class Window(QMainWindow, Ui_MainWindow):
|
|||||||
# self.actionAdd_note.triggered.connect(self.create_note)
|
# self.actionAdd_note.triggered.connect(self.create_note)
|
||||||
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_tab)
|
self.actionClosePlaylist.triggered.connect(self.close_playlist_tab)
|
||||||
# self.actionDownload_CSV_of_played_tracks.triggered.connect(
|
self.actionDownload_CSV_of_played_tracks.triggered.connect(
|
||||||
# self.download_played_tracks)
|
self.download_played_tracks)
|
||||||
|
# ***kae
|
||||||
self.actionEnable_controls.triggered.connect(
|
self.actionEnable_controls.triggered.connect(
|
||||||
self.enable_play_next_controls)
|
self.enable_play_next_controls)
|
||||||
# self.actionExport_playlist.triggered.connect(self.export_playlist_tab)
|
# self.actionExport_playlist.triggered.connect(self.export_playlist_tab)
|
||||||
@ -275,32 +275,32 @@ class Window(QMainWindow, Ui_MainWindow):
|
|||||||
|
|
||||||
self.actionPlay_next.setEnabled(False)
|
self.actionPlay_next.setEnabled(False)
|
||||||
self.statusbar.showMessage("Play controls: Disabled", 0)
|
self.statusbar.showMessage("Play controls: Disabled", 0)
|
||||||
#
|
|
||||||
# def download_played_tracks(self) -> None:
|
def download_played_tracks(self) -> None:
|
||||||
# """Download a CSV of played tracks"""
|
"""Download a CSV of played tracks"""
|
||||||
#
|
|
||||||
# dlg = DownloadCSV(self)
|
dlg = DownloadCSV(self)
|
||||||
# if dlg.exec():
|
if dlg.exec():
|
||||||
# start_dt = dlg.ui.dateTimeEdit.dateTime().toPyDateTime()
|
start_dt = dlg.ui.dateTimeEdit.dateTime().toPyDateTime()
|
||||||
# # Get output filename
|
# Get output filename
|
||||||
# pathspec: Tuple[str, str] = QFileDialog.getSaveFileName(
|
pathspec = QFileDialog.getSaveFileName(
|
||||||
# self, 'Save CSV of tracks played',
|
self, 'Save CSV of tracks played',
|
||||||
# directory="/tmp/playlist.csv",
|
directory="/tmp/playlist.csv",
|
||||||
# filter="CSV files (*.csv)"
|
filter="CSV files (*.csv)"
|
||||||
# )
|
)
|
||||||
# if not pathspec:
|
if not pathspec:
|
||||||
# return
|
return
|
||||||
#
|
|
||||||
# path: str = pathspec[0]
|
path = pathspec[0]
|
||||||
# if not path.endswith(".csv"):
|
if not path.endswith(".csv"):
|
||||||
# path += ".csv"
|
path += ".csv"
|
||||||
#
|
|
||||||
# with open(path, "w") as f:
|
with open(path, "w") as f:
|
||||||
# with Session() as session:
|
with Session() as session:
|
||||||
# for playdate in Playdates.played_after(session, start_dt):
|
for playdate in Playdates.played_after(session, start_dt):
|
||||||
# f.write(
|
f.write(
|
||||||
# f"{playdate.track.artist},{playdate.track.title}\n"
|
f"{playdate.track.artist},{playdate.track.title}\n"
|
||||||
# )
|
)
|
||||||
#
|
#
|
||||||
# def drop3db(self) -> None:
|
# def drop3db(self) -> None:
|
||||||
# """Drop music level by 3db if button checked"""
|
# """Drop music level by 3db if button checked"""
|
||||||
@ -974,18 +974,18 @@ class Window(QMainWindow, Ui_MainWindow):
|
|||||||
# item = self.ui.matchList.currentItem()
|
# item = self.ui.matchList.currentItem()
|
||||||
# track = item.data(Qt.UserRole)
|
# track = item.data(Qt.UserRole)
|
||||||
# self.ui.dbPath.setText(track.path)
|
# self.ui.dbPath.setText(track.path)
|
||||||
#
|
|
||||||
#
|
|
||||||
# class DownloadCSV(QDialog):
|
class DownloadCSV(QDialog):
|
||||||
# def __init__(self, parent=None):
|
def __init__(self, parent=None):
|
||||||
# super().__init__(parent)
|
super().__init__(parent)
|
||||||
#
|
|
||||||
# self.ui = Ui_DateSelect()
|
self.ui = Ui_DateSelect()
|
||||||
# self.ui.setupUi(self)
|
self.ui.setupUi(self)
|
||||||
# self.ui.dateTimeEdit.setDate(QDate.currentDate())
|
self.ui.dateTimeEdit.setDate(QDate.currentDate())
|
||||||
# self.ui.dateTimeEdit.setTime(QTime(19, 59, 0))
|
self.ui.dateTimeEdit.setTime(QTime(19, 59, 0))
|
||||||
# self.ui.buttonBox.accepted.connect(self.accept)
|
self.ui.buttonBox.accepted.connect(self.accept)
|
||||||
# self.ui.buttonBox.rejected.connect(self.reject)
|
self.ui.buttonBox.rejected.connect(self.reject)
|
||||||
|
|
||||||
|
|
||||||
class SelectPlaylistDialog(QDialog):
|
class SelectPlaylistDialog(QDialog):
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user