Compare commits

..

No commits in common. "1a16b1022d1f33e013c577bc3b131c18c5cabdb6" and "1a4f842f1f159ce35a8b332c575007c84f4344d6" have entirely different histories.

4 changed files with 15 additions and 32 deletions

View File

@ -197,7 +197,6 @@ class Window(QMainWindow, Ui_MainWindow):
self.btnSongInfo.clicked.connect(self.song_info_search)
self.btnStop.clicked.connect(self.stop)
self.spnVolume.valueChanged.connect(self.change_volume)
self.tabPlaylist.tabCloseRequested.connect(self.close_tab)
self.timer.timeout.connect(self.tick)
@ -229,15 +228,6 @@ class Window(QMainWindow, Ui_MainWindow):
index = self.tabPlaylist.currentIndex()
self.tabPlaylist.removeTab(index)
def close_tab(self, index):
if self.tabPlaylist.widget(index) == self.current_track_playlist_tab:
self.statusbar.showMessage("Can't close current track playlist",
5000)
elif self.tabPlaylist.widget(index) == self.next_track_playlist_tab:
self.statusbar.showMessage("Can't close next track playlist", 5000)
else:
self.tabPlaylist.removeTab(index)
def create_note(self, session, text):
"""
Create note

View File

@ -14,13 +14,11 @@ from mutagen.mp3 import MP3
from pydub import AudioSegment, effects
from tinytag import TinyTag
# Globals (I know)
messages = []
def main():
"Main loop"
DEBUG("Starting")
INFO("Starting")
# Parse command line
p = argparse.ArgumentParser()
@ -38,25 +36,25 @@ def main():
# Run as required
if args.update:
DEBUG("Updating database")
INFO("Updating database")
with Session() as session:
update_db(session)
elif args.full_update:
DEBUG("Full update of database")
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, interactive=True)
create_track_from_file(session, fname, verbose=True)
else:
INFO("No action specified")
DEBUG("Finished")
INFO("Finished")
def create_track_from_file(session, path, interactive=False):
def create_track_from_file(session, path, verbose=False):
"""
Create track in database from passed path, or update database entry
if path already in database.
@ -64,7 +62,7 @@ def create_track_from_file(session, path, interactive=False):
Return track.
"""
if interactive:
if verbose:
str = f"Importing {path}"
INFO(str)
INFO("-" * len(str))
@ -72,7 +70,7 @@ def create_track_from_file(session, path, interactive=False):
t = get_music_info(path)
title = t['title']
artist = t['artist']
if interactive:
if verbose:
INFO(f" Title: \"{title}\"")
INFO(f" Artist: \"{artist}\"")
# Check for duplicate
@ -92,7 +90,7 @@ def create_track_from_file(session, path, interactive=False):
track.duration = int(round(
t['duration'], Config.MILLISECOND_SIGFIGS) * 1000)
if interactive:
if verbose:
INFO("Parse for start, fade and silence...")
audio = get_audio_segment(path)
track.start_gap = leading_silence(audio)
@ -104,7 +102,7 @@ def create_track_from_file(session, path, interactive=False):
session.commit()
if Config.NORMALISE_ON_IMPORT:
if interactive:
if verbose:
INFO("Normalise...")
# Check type
ftype = os.path.splitext(path)[1][1:]
@ -331,7 +329,8 @@ def update_db(session):
# is filename in database?
track = Tracks.get_track_from_filename(session, os.path.basename(path))
if not track:
messages.append(f"Track missing from database: {path}")
INFO(f"songdb.update_db: Adding to database: {path}")
create_track_from_file(session, path)
else:
# Check track info matches found track
t = get_music_info(path)
@ -346,7 +345,7 @@ def update_db(session):
for path in list(db_paths - os_paths):
# Manage tracks listed in database but where path is invalid
track = Tracks.get_track_from_path(session, path)
messages.append(f"Remove from database: {path=} {track=}")
INFO(f"songdb.update_db(): remove from database: {path=} {track=}")
# Remove references from Playdates
Playdates.remove_track(session, track.id)
@ -365,12 +364,6 @@ def update_db(session):
# Remove Track entry pointing to invalid path
Tracks.remove_path(session, path)
# Output messages (so if running via cron, these will get sent to
# user)
if messages:
print("Messages")
print("\n".join(messages))
def update_meta(session, track, artist=None, title=None):
"""

View File

@ -468,7 +468,7 @@ border: 1px solid rgb(85, 87, 83);</string>
<bool>false</bool>
</property>
<property name="tabsClosable">
<bool>true</bool>
<bool>false</bool>
</property>
<property name="movable">
<bool>true</bool>

View File

@ -208,7 +208,7 @@ class Ui_MainWindow(object):
self.gridLayout_3.addWidget(self.frame_5, 1, 0, 1, 1)
self.tabPlaylist = QtWidgets.QTabWidget(self.centralwidget)
self.tabPlaylist.setDocumentMode(False)
self.tabPlaylist.setTabsClosable(True)
self.tabPlaylist.setTabsClosable(False)
self.tabPlaylist.setMovable(True)
self.tabPlaylist.setObjectName("tabPlaylist")
self.gridLayout_3.addWidget(self.tabPlaylist, 2, 0, 1, 1)