Compare commits
No commits in common. "79f9a496591766e331ab7bb50442a11f57c2ad3b" and "ccbe8fdb1b3480e95f1cebe564d7a4b3de089d99" have entirely different histories.
79f9a49659
...
ccbe8fdb1b
@ -22,7 +22,6 @@ class Config(object):
|
|||||||
ERRORS_TO = ['kae@midnighthax.com']
|
ERRORS_TO = ['kae@midnighthax.com']
|
||||||
FADE_STEPS = 20
|
FADE_STEPS = 20
|
||||||
FADE_TIME = 3000
|
FADE_TIME = 3000
|
||||||
INFO_TAB_TITLE_LENGTH = 15
|
|
||||||
LOG_LEVEL_STDERR = logging.INFO
|
LOG_LEVEL_STDERR = logging.INFO
|
||||||
LOG_LEVEL_SYSLOG = logging.DEBUG
|
LOG_LEVEL_SYSLOG = logging.DEBUG
|
||||||
LOG_NAME = "musicmuster"
|
LOG_NAME = "musicmuster"
|
||||||
@ -31,7 +30,6 @@ class Config(object):
|
|||||||
MAIL_SERVER = os.environ.get('MAIL_SERVER') or "woodlands.midnighthax.com"
|
MAIL_SERVER = os.environ.get('MAIL_SERVER') or "woodlands.midnighthax.com"
|
||||||
MAIL_USERNAME = os.environ.get('MAIL_USERNAME')
|
MAIL_USERNAME = os.environ.get('MAIL_USERNAME')
|
||||||
MAIL_USE_TLS = os.environ.get('MAIL_USE_TLS') is not None
|
MAIL_USE_TLS = os.environ.get('MAIL_USE_TLS') is not None
|
||||||
MAX_INFO_TABS = 3
|
|
||||||
MILLISECOND_SIGFIGS = 0
|
MILLISECOND_SIGFIGS = 0
|
||||||
MYSQL_CONNECT = os.environ.get('MYSQL_CONNECT') or "mysql+mysqldb://musicmuster:musicmuster@localhost/musicmuster_dev" # noqa E501
|
MYSQL_CONNECT = os.environ.get('MYSQL_CONNECT') or "mysql+mysqldb://musicmuster:musicmuster@localhost/musicmuster_dev" # noqa E501
|
||||||
NORMALISE_ON_IMPORT = True
|
NORMALISE_ON_IMPORT = True
|
||||||
|
|||||||
@ -9,9 +9,8 @@ import urllib.parse
|
|||||||
from datetime import datetime, timedelta
|
from datetime import datetime, timedelta
|
||||||
from log import DEBUG, EXCEPTION
|
from log import DEBUG, EXCEPTION
|
||||||
|
|
||||||
from PyQt5.QtCore import Qt, QTimer, QUrl
|
from PyQt5.QtCore import Qt, QTimer
|
||||||
from PyQt5.QtGui import QFontMetrics, QPainter
|
from PyQt5.QtGui import QFontMetrics, QPainter
|
||||||
from PyQt5.QtWebEngineWidgets import QWebEngineView as QWebView
|
|
||||||
from PyQt5.QtWidgets import (
|
from PyQt5.QtWidgets import (
|
||||||
QApplication,
|
QApplication,
|
||||||
QDialog,
|
QDialog,
|
||||||
@ -64,7 +63,6 @@ class Window(QMainWindow, Ui_MainWindow):
|
|||||||
self.music = music.Music()
|
self.music = music.Music()
|
||||||
self.current_track = None
|
self.current_track = None
|
||||||
self.current_track_playlist_tab = None
|
self.current_track_playlist_tab = None
|
||||||
self.info_tabs = {}
|
|
||||||
self.next_track = None
|
self.next_track = None
|
||||||
self.next_track_playlist_tab = None
|
self.next_track_playlist_tab = None
|
||||||
self.previous_track = None
|
self.previous_track = None
|
||||||
@ -265,41 +263,6 @@ class Window(QMainWindow, Ui_MainWindow):
|
|||||||
# Enable controls
|
# Enable controls
|
||||||
self.enable_play_next_controls()
|
self.enable_play_next_controls()
|
||||||
|
|
||||||
def ensure_info_tabs(self, title_list):
|
|
||||||
"""
|
|
||||||
Ensure we have info tabs for each of the passed titles
|
|
||||||
"""
|
|
||||||
|
|
||||||
for title in title_list:
|
|
||||||
if title in self.info_tabs.keys():
|
|
||||||
# We already have a tab for this track
|
|
||||||
continue
|
|
||||||
if len(self.info_tabs) >= Config.MAX_INFO_TABS:
|
|
||||||
# Find an unneeded info tab
|
|
||||||
try:
|
|
||||||
old_title = list(
|
|
||||||
set(self.info_tabs.keys()) - set(title_list)
|
|
||||||
)[0]
|
|
||||||
except IndexError:
|
|
||||||
DEBUG(
|
|
||||||
f"ensure_info_tabs({title_list}): unable to add "
|
|
||||||
f"{title=}"
|
|
||||||
)
|
|
||||||
return
|
|
||||||
# Assign redundant widget a new title
|
|
||||||
widget = self.info_tabs[title] = self.info_tabs[old_title]
|
|
||||||
idx = self.tabPlaylist.indexOf(widget)
|
|
||||||
self.tabPlaylist.setTabText(
|
|
||||||
idx, title[:Config.INFO_TAB_TITLE_LENGTH])
|
|
||||||
del self.info_tabs[old_title]
|
|
||||||
else:
|
|
||||||
widget = self.info_tabs[title] = QWebView()
|
|
||||||
self.tabPlaylist.addTab(
|
|
||||||
widget, title[:Config.INFO_TAB_TITLE_LENGTH])
|
|
||||||
str = urllib.parse.quote_plus(title)
|
|
||||||
url = f"https://www.wikipedia.org/w/index.php?search={str}"
|
|
||||||
widget.setUrl(QUrl(url))
|
|
||||||
|
|
||||||
def export_playlist_tab(self):
|
def export_playlist_tab(self):
|
||||||
"Export the current playlist to an m3u file"
|
"Export the current playlist to an m3u file"
|
||||||
|
|
||||||
@ -704,39 +667,32 @@ class Window(QMainWindow, Ui_MainWindow):
|
|||||||
self.stop_playing()
|
self.stop_playing()
|
||||||
|
|
||||||
def update_headers(self):
|
def update_headers(self):
|
||||||
"""
|
"Update last / current / next track headers"
|
||||||
Update last / current / next track headers.
|
|
||||||
Ensure a Wikipedia tab for each title.
|
|
||||||
"""
|
|
||||||
|
|
||||||
titles = []
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
self.hdrPreviousTrack.setText(
|
self.hdrPreviousTrack.setText(
|
||||||
f"{self.previous_track.title} - {self.previous_track.artist}"
|
f"{self.previous_track.title} - "
|
||||||
|
f"{self.previous_track.artist}"
|
||||||
)
|
)
|
||||||
titles.append(self.previous_track.title)
|
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
self.hdrPreviousTrack.setText("")
|
self.hdrPreviousTrack.setText("")
|
||||||
|
|
||||||
try:
|
try:
|
||||||
self.hdrCurrentTrack.setText(
|
self.hdrCurrentTrack.setText(
|
||||||
f"{self.current_track.title} - {self.current_track.artist}"
|
f"{self.current_track.title} - "
|
||||||
|
f"{self.current_track.artist}"
|
||||||
)
|
)
|
||||||
titles.append(self.current_track.title)
|
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
self.hdrCurrentTrack.setText("")
|
self.hdrCurrentTrack.setText("")
|
||||||
|
|
||||||
try:
|
try:
|
||||||
self.hdrNextTrack.setText(
|
self.hdrNextTrack.setText(
|
||||||
f"{self.next_track.title} - {self.next_track.artist}"
|
f"{self.next_track.title} - "
|
||||||
|
f"{self.next_track.artist}"
|
||||||
)
|
)
|
||||||
titles.append(self.next_track.title)
|
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
self.hdrNextTrack.setText("")
|
self.hdrNextTrack.setText("")
|
||||||
|
|
||||||
self.ensure_info_tabs(titles)
|
|
||||||
|
|
||||||
|
|
||||||
class DbDialog(QDialog):
|
class DbDialog(QDialog):
|
||||||
def __init__(self, parent, session):
|
def __init__(self, parent, session):
|
||||||
|
|||||||
@ -62,9 +62,7 @@ def create_track_from_file(session, path, verbose=False):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
if verbose:
|
if verbose:
|
||||||
str = f"Importing {path}"
|
INFO(f"Importing {path}...")
|
||||||
INFO(str)
|
|
||||||
INFO("-" * len(str))
|
|
||||||
track = Tracks.get_or_create(session, path)
|
track = Tracks.get_or_create(session, path)
|
||||||
if verbose:
|
if verbose:
|
||||||
INFO("Get track info...")
|
INFO("Get track info...")
|
||||||
|
|||||||
4
mmimport
4
mmimport
@ -1,6 +1,4 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
# cd /home/kae/mm
|
# cd /home/kae/mm
|
||||||
# MYSQL_CONNECT="mysql+mysqldb://musicmuster:musicmuster@localhost/musicmuster_prod" ROOT="/home/kae/music" direnv exec .
|
# MYSQL_CONNECT="mysql+mysqldb://musicmuster:musicmuster@localhost/musicmuster_prod" ROOT="/home/kae/music" direnv exec .
|
||||||
for file in "$@"; do
|
app/songdb.py -i "$1"
|
||||||
app/songdb.py -i "$file"
|
|
||||||
done
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user