Compare commits
2 Commits
1a4f842f1f
...
1a16b1022d
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1a16b1022d | ||
|
|
69fb10fcd9 |
@ -197,6 +197,7 @@ class Window(QMainWindow, Ui_MainWindow):
|
|||||||
self.btnSongInfo.clicked.connect(self.song_info_search)
|
self.btnSongInfo.clicked.connect(self.song_info_search)
|
||||||
self.btnStop.clicked.connect(self.stop)
|
self.btnStop.clicked.connect(self.stop)
|
||||||
self.spnVolume.valueChanged.connect(self.change_volume)
|
self.spnVolume.valueChanged.connect(self.change_volume)
|
||||||
|
self.tabPlaylist.tabCloseRequested.connect(self.close_tab)
|
||||||
|
|
||||||
self.timer.timeout.connect(self.tick)
|
self.timer.timeout.connect(self.tick)
|
||||||
|
|
||||||
@ -228,6 +229,15 @@ class Window(QMainWindow, Ui_MainWindow):
|
|||||||
index = self.tabPlaylist.currentIndex()
|
index = self.tabPlaylist.currentIndex()
|
||||||
self.tabPlaylist.removeTab(index)
|
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):
|
def create_note(self, session, text):
|
||||||
"""
|
"""
|
||||||
Create note
|
Create note
|
||||||
|
|||||||
@ -14,11 +14,13 @@ from mutagen.mp3 import MP3
|
|||||||
from pydub import AudioSegment, effects
|
from pydub import AudioSegment, effects
|
||||||
from tinytag import TinyTag
|
from tinytag import TinyTag
|
||||||
|
|
||||||
|
# Globals (I know)
|
||||||
|
messages = []
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
"Main loop"
|
"Main loop"
|
||||||
|
|
||||||
INFO("Starting")
|
DEBUG("Starting")
|
||||||
|
|
||||||
# Parse command line
|
# Parse command line
|
||||||
p = argparse.ArgumentParser()
|
p = argparse.ArgumentParser()
|
||||||
@ -36,25 +38,25 @@ def main():
|
|||||||
|
|
||||||
# Run as required
|
# Run as required
|
||||||
if args.update:
|
if args.update:
|
||||||
INFO("Updating database")
|
DEBUG("Updating database")
|
||||||
with Session() as session:
|
with Session() as session:
|
||||||
update_db(session)
|
update_db(session)
|
||||||
elif args.full_update:
|
elif args.full_update:
|
||||||
INFO("Full update of database")
|
DEBUG("Full update of database")
|
||||||
with Session() as session:
|
with Session() as session:
|
||||||
full_update_db(session)
|
full_update_db(session)
|
||||||
elif args.fname:
|
elif args.fname:
|
||||||
fname = os.path.realpath(args.fname)
|
fname = os.path.realpath(args.fname)
|
||||||
with Session() as session:
|
with Session() as session:
|
||||||
create_track_from_file(session, fname, verbose=True)
|
create_track_from_file(session, fname, interactive=True)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
INFO("No action specified")
|
INFO("No action specified")
|
||||||
|
|
||||||
INFO("Finished")
|
DEBUG("Finished")
|
||||||
|
|
||||||
|
|
||||||
def create_track_from_file(session, path, verbose=False):
|
def create_track_from_file(session, path, interactive=False):
|
||||||
"""
|
"""
|
||||||
Create track in database from passed path, or update database entry
|
Create track in database from passed path, or update database entry
|
||||||
if path already in database.
|
if path already in database.
|
||||||
@ -62,7 +64,7 @@ def create_track_from_file(session, path, verbose=False):
|
|||||||
Return track.
|
Return track.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
if verbose:
|
if interactive:
|
||||||
str = f"Importing {path}"
|
str = f"Importing {path}"
|
||||||
INFO(str)
|
INFO(str)
|
||||||
INFO("-" * len(str))
|
INFO("-" * len(str))
|
||||||
@ -70,7 +72,7 @@ def create_track_from_file(session, path, verbose=False):
|
|||||||
t = get_music_info(path)
|
t = get_music_info(path)
|
||||||
title = t['title']
|
title = t['title']
|
||||||
artist = t['artist']
|
artist = t['artist']
|
||||||
if verbose:
|
if interactive:
|
||||||
INFO(f" Title: \"{title}\"")
|
INFO(f" Title: \"{title}\"")
|
||||||
INFO(f" Artist: \"{artist}\"")
|
INFO(f" Artist: \"{artist}\"")
|
||||||
# Check for duplicate
|
# Check for duplicate
|
||||||
@ -90,7 +92,7 @@ def create_track_from_file(session, path, verbose=False):
|
|||||||
track.duration = int(round(
|
track.duration = int(round(
|
||||||
t['duration'], Config.MILLISECOND_SIGFIGS) * 1000)
|
t['duration'], Config.MILLISECOND_SIGFIGS) * 1000)
|
||||||
|
|
||||||
if verbose:
|
if interactive:
|
||||||
INFO("Parse for start, fade and silence...")
|
INFO("Parse for start, fade and silence...")
|
||||||
audio = get_audio_segment(path)
|
audio = get_audio_segment(path)
|
||||||
track.start_gap = leading_silence(audio)
|
track.start_gap = leading_silence(audio)
|
||||||
@ -102,7 +104,7 @@ def create_track_from_file(session, path, verbose=False):
|
|||||||
session.commit()
|
session.commit()
|
||||||
|
|
||||||
if Config.NORMALISE_ON_IMPORT:
|
if Config.NORMALISE_ON_IMPORT:
|
||||||
if verbose:
|
if interactive:
|
||||||
INFO("Normalise...")
|
INFO("Normalise...")
|
||||||
# Check type
|
# Check type
|
||||||
ftype = os.path.splitext(path)[1][1:]
|
ftype = os.path.splitext(path)[1][1:]
|
||||||
@ -329,8 +331,7 @@ def update_db(session):
|
|||||||
# is filename in database?
|
# is filename in database?
|
||||||
track = Tracks.get_track_from_filename(session, os.path.basename(path))
|
track = Tracks.get_track_from_filename(session, os.path.basename(path))
|
||||||
if not track:
|
if not track:
|
||||||
INFO(f"songdb.update_db: Adding to database: {path}")
|
messages.append(f"Track missing from database: {path}")
|
||||||
create_track_from_file(session, path)
|
|
||||||
else:
|
else:
|
||||||
# Check track info matches found track
|
# Check track info matches found track
|
||||||
t = get_music_info(path)
|
t = get_music_info(path)
|
||||||
@ -345,7 +346,7 @@ def update_db(session):
|
|||||||
for path in list(db_paths - os_paths):
|
for path in list(db_paths - os_paths):
|
||||||
# Manage tracks listed in database but where path is invalid
|
# Manage tracks listed in database but where path is invalid
|
||||||
track = Tracks.get_track_from_path(session, path)
|
track = Tracks.get_track_from_path(session, path)
|
||||||
INFO(f"songdb.update_db(): remove from database: {path=} {track=}")
|
messages.append(f"Remove from database: {path=} {track=}")
|
||||||
|
|
||||||
# Remove references from Playdates
|
# Remove references from Playdates
|
||||||
Playdates.remove_track(session, track.id)
|
Playdates.remove_track(session, track.id)
|
||||||
@ -364,6 +365,12 @@ def update_db(session):
|
|||||||
# Remove Track entry pointing to invalid path
|
# Remove Track entry pointing to invalid path
|
||||||
Tracks.remove_path(session, 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):
|
def update_meta(session, track, artist=None, title=None):
|
||||||
"""
|
"""
|
||||||
|
|||||||
@ -468,7 +468,7 @@ border: 1px solid rgb(85, 87, 83);</string>
|
|||||||
<bool>false</bool>
|
<bool>false</bool>
|
||||||
</property>
|
</property>
|
||||||
<property name="tabsClosable">
|
<property name="tabsClosable">
|
||||||
<bool>false</bool>
|
<bool>true</bool>
|
||||||
</property>
|
</property>
|
||||||
<property name="movable">
|
<property name="movable">
|
||||||
<bool>true</bool>
|
<bool>true</bool>
|
||||||
|
|||||||
@ -208,7 +208,7 @@ class Ui_MainWindow(object):
|
|||||||
self.gridLayout_3.addWidget(self.frame_5, 1, 0, 1, 1)
|
self.gridLayout_3.addWidget(self.frame_5, 1, 0, 1, 1)
|
||||||
self.tabPlaylist = QtWidgets.QTabWidget(self.centralwidget)
|
self.tabPlaylist = QtWidgets.QTabWidget(self.centralwidget)
|
||||||
self.tabPlaylist.setDocumentMode(False)
|
self.tabPlaylist.setDocumentMode(False)
|
||||||
self.tabPlaylist.setTabsClosable(False)
|
self.tabPlaylist.setTabsClosable(True)
|
||||||
self.tabPlaylist.setMovable(True)
|
self.tabPlaylist.setMovable(True)
|
||||||
self.tabPlaylist.setObjectName("tabPlaylist")
|
self.tabPlaylist.setObjectName("tabPlaylist")
|
||||||
self.gridLayout_3.addWidget(self.tabPlaylist, 2, 0, 1, 1)
|
self.gridLayout_3.addWidget(self.tabPlaylist, 2, 0, 1, 1)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user