Compare commits

..

No commits in common. "ccbe8fdb1b3480e95f1cebe564d7a4b3de089d99" and "0e3e30391b02e3726221ae97e379ac7774e6dfba" have entirely different histories.

4 changed files with 10 additions and 57 deletions

View File

@ -71,8 +71,6 @@ class Window(QMainWindow, Ui_MainWindow):
self.menuTest.menuAction().setVisible(Config.TESTMODE)
self.set_main_window_size()
self.lblSumPlaytime = QLabel("")
self.statusbar.addPermanentWidget(self.lblSumPlaytime)
self.visible_playlist_tab = self.tabPlaylist.currentWidget
@ -254,10 +252,9 @@ class Window(QMainWindow, Ui_MainWindow):
self.current_track = None
# Clean up display
self.frame_fade.setStyleSheet("")
self.label_silent_timer.setText("00:00")
self.frame_silent.setStyleSheet("")
self.label_end_timer.setText("00:00")
self.frame_silent.setStyleSheet("")
self.frame_fade.setStyleSheet("")
self.update_headers()
# Enable controls

View File

@ -89,8 +89,6 @@ class PlaylistTab(QTableWidget):
self.customContextMenuRequested.connect(self._context_menu)
self.viewport().installEventFilter(self)
self.itemSelectionChanged.connect(self._select_event)
self.current_track_start_time = None
self.played_tracks = []
@ -1003,29 +1001,8 @@ class PlaylistTab(QTableWidget):
PlaylistTracks.add_track(
session, self.id, self._get_row_id(row), row)
def _select_event(self):
"""
Called when item selection changes.
If multiple rows are selected, display sum of durations in status bar.
"""
# Clear label
self.master_process.lblSumPlaytime.setText("")
rows = set([item.row() for item in self.selectedItems()])
notes = self._meta_get_notes()
ms = 0
with Session() as session:
for row in rows:
if row in notes:
continue
ms += Tracks.get_duration(session, self._get_row_id(row))
# Only paint message if there are selected track rows
if ms > 0:
self.master_process.lblSumPlaytime.setText(
f"Selected duration: {helpers.ms_to_mmss(ms)}")
def _set_column_widths(self):
# Column widths from settings
with Session() as session:
for column in range(self.columnCount()):

View File

@ -21,16 +21,12 @@ def main():
# Parse command line
p = argparse.ArgumentParser()
# Only allow one option to be specified
group = p.add_mutually_exclusive_group()
group.add_argument('-u', '--update',
action="store_true", dest="update",
default=False, help="Update database")
group.add_argument('-f', '--full-update',
action="store_true", dest="full_update",
default=False, help="Update database")
group.add_argument('-i', '--import', dest="fname", help="Input file")
p.add_argument('-u', '--update',
action="store_true", dest="update",
default=False, help="Update database")
p.add_argument('-f', '--full-update',
action="store_true", dest="full_update",
default=False, help="Update database")
args = p.parse_args()
# Run as required
@ -42,18 +38,13 @@ def main():
INFO("Full update of database")
with Session() as session:
full_update_db(session)
elif args.fname:
fname = os.path.realpath(args.fname)
with Session() as session:
create_track_from_file(session, fname, verbose=True)
else:
INFO("No action specified")
INFO("Finished")
def create_track_from_file(session, path, verbose=False):
def create_track_from_file(session, path):
"""
Create track in database from passed path, or update database entry
if path already in database.
@ -61,19 +52,13 @@ def create_track_from_file(session, path, verbose=False):
Return track.
"""
if verbose:
INFO(f"Importing {path}...")
track = Tracks.get_or_create(session, path)
if verbose:
INFO("Get track info...")
t = get_music_info(path)
track.title = t['title']
track.artist = t['artist']
track.duration = int(round(
t['duration'], Config.MILLISECOND_SIGFIGS) * 1000)
if verbose:
INFO("Parse for start, fade and silence...")
audio = get_audio_segment(path)
track.start_gap = leading_silence(audio)
track.fade_at = round(fade_point(audio) / 1000,
@ -84,8 +69,6 @@ def create_track_from_file(session, path, verbose=False):
session.commit()
if Config.NORMALISE_ON_IMPORT:
if verbose:
INFO("Normalise...")
# Check type
ftype = os.path.splitext(path)[1][1:]
if ftype not in ['mp3', 'flac']:

View File

@ -1,4 +0,0 @@
#!/bin/bash
# cd /home/kae/mm
# MYSQL_CONNECT="mysql+mysqldb://musicmuster:musicmuster@localhost/musicmuster_prod" ROOT="/home/kae/music" direnv exec .
app/songdb.py -i "$1"