Compare commits
No commits in common. "2861511f1fcd58f90191f579f3459a301942a1e3" and "de710b1dc70bcc380ca5b96e04e179d75cc2c90a" have entirely different histories.
2861511f1f
...
de710b1dc7
@ -217,5 +217,4 @@ class TrackSequence:
|
|||||||
now = PlaylistTrack()
|
now = PlaylistTrack()
|
||||||
previous = PlaylistTrack()
|
previous = PlaylistTrack()
|
||||||
|
|
||||||
|
|
||||||
track_sequence = TrackSequence()
|
track_sequence = TrackSequence()
|
||||||
|
|||||||
@ -44,12 +44,12 @@ class Config(object):
|
|||||||
COLUMN_NAME_TITLE = "Title"
|
COLUMN_NAME_TITLE = "Title"
|
||||||
DBFS_SILENCE = -50
|
DBFS_SILENCE = -50
|
||||||
DEBUG_FUNCTIONS: List[Optional[str]] = []
|
DEBUG_FUNCTIONS: List[Optional[str]] = []
|
||||||
DEBUG_MODULES: List[Optional[str]] = ["dbconfig"]
|
DEBUG_MODULES: List[Optional[str]] = ['dbconfig']
|
||||||
DEFAULT_COLUMN_WIDTH = 200
|
DEFAULT_COLUMN_WIDTH = 200
|
||||||
DISPLAY_SQL = False
|
DISPLAY_SQL = False
|
||||||
EPOCH = datetime.datetime(1970, 1, 1)
|
EPOCH = datetime.datetime(1970, 1, 1)
|
||||||
ERRORS_FROM = ["noreply@midnighthax.com"]
|
ERRORS_FROM = ['noreply@midnighthax.com']
|
||||||
ERRORS_TO = ["kae@midnighthax.com"]
|
ERRORS_TO = ['kae@midnighthax.com']
|
||||||
FADE_CURVE_BACKGROUND = "lightyellow"
|
FADE_CURVE_BACKGROUND = "lightyellow"
|
||||||
FADE_CURVE_FOREGROUND = "blue"
|
FADE_CURVE_FOREGROUND = "blue"
|
||||||
FADE_CURVE_MS_BEFORE_FADE = 5000
|
FADE_CURVE_MS_BEFORE_FADE = 5000
|
||||||
@ -71,11 +71,11 @@ class Config(object):
|
|||||||
LOG_LEVEL_STDERR = logging.ERROR
|
LOG_LEVEL_STDERR = logging.ERROR
|
||||||
LOG_LEVEL_SYSLOG = logging.DEBUG
|
LOG_LEVEL_SYSLOG = logging.DEBUG
|
||||||
LOG_NAME = "musicmuster"
|
LOG_NAME = "musicmuster"
|
||||||
MAIL_PASSWORD = os.environ.get("MAIL_PASSWORD")
|
MAIL_PASSWORD = os.environ.get('MAIL_PASSWORD')
|
||||||
MAIL_PORT = int(os.environ.get("MAIL_PORT") or 25)
|
MAIL_PORT = int(os.environ.get('MAIL_PORT') or 25)
|
||||||
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_IMPORT_MATCHES = 5
|
MAX_IMPORT_MATCHES = 5
|
||||||
MAX_INFO_TABS = 5
|
MAX_INFO_TABS = 5
|
||||||
MAX_MISSING_FILES_TO_REPORT = 10
|
MAX_MISSING_FILES_TO_REPORT = 10
|
||||||
@ -86,7 +86,7 @@ class Config(object):
|
|||||||
OBS_PASSWORD = "auster"
|
OBS_PASSWORD = "auster"
|
||||||
OBS_PORT = 4455
|
OBS_PORT = 4455
|
||||||
PLAY_SETTLE = 500000
|
PLAY_SETTLE = 500000
|
||||||
ROOT = os.environ.get("ROOT") or "/home/kae/music"
|
ROOT = os.environ.get('ROOT') or "/home/kae/music"
|
||||||
ROWS_FROM_ZERO = True
|
ROWS_FROM_ZERO = True
|
||||||
IMPORT_DESTINATION = os.path.join(ROOT, "Singles")
|
IMPORT_DESTINATION = os.path.join(ROOT, "Singles")
|
||||||
SCROLL_TOP_MARGIN = 3
|
SCROLL_TOP_MARGIN = 3
|
||||||
|
|||||||
@ -431,6 +431,23 @@ class PlaylistRows(Base):
|
|||||||
track_id=plr.track_id,
|
track_id=plr.track_id,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def delete_higher_rows(
|
||||||
|
session: scoped_session, playlist_id: int, maxrow: int
|
||||||
|
) -> None:
|
||||||
|
"""
|
||||||
|
Delete rows in given playlist that have a higher row number
|
||||||
|
than 'maxrow'
|
||||||
|
"""
|
||||||
|
|
||||||
|
session.execute(
|
||||||
|
delete(PlaylistRows).where(
|
||||||
|
PlaylistRows.playlist_id == playlist_id,
|
||||||
|
PlaylistRows.plr_rownum > maxrow,
|
||||||
|
)
|
||||||
|
)
|
||||||
|
session.flush()
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def deep_row(
|
def deep_row(
|
||||||
cls, session: scoped_session, playlist_id: int, row_number: int
|
cls, session: scoped_session, playlist_id: int, row_number: int
|
||||||
@ -471,38 +488,6 @@ class PlaylistRows(Base):
|
|||||||
|
|
||||||
return session.scalars(stmt).unique().all()
|
return session.scalars(stmt).unique().all()
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def delete_higher_rows(
|
|
||||||
session: scoped_session, playlist_id: int, maxrow: int
|
|
||||||
) -> None:
|
|
||||||
"""
|
|
||||||
Delete rows in given playlist that have a higher row number
|
|
||||||
than 'maxrow'
|
|
||||||
"""
|
|
||||||
|
|
||||||
session.execute(
|
|
||||||
delete(PlaylistRows).where(
|
|
||||||
PlaylistRows.playlist_id == playlist_id,
|
|
||||||
PlaylistRows.plr_rownum > maxrow,
|
|
||||||
)
|
|
||||||
)
|
|
||||||
session.flush()
|
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def delete_rows(
|
|
||||||
session: scoped_session, playlist_id: int, row_numbers: List[int]
|
|
||||||
) -> None:
|
|
||||||
"""
|
|
||||||
Delete passed rows in given playlist.
|
|
||||||
"""
|
|
||||||
|
|
||||||
session.execute(
|
|
||||||
delete(PlaylistRows).where(
|
|
||||||
PlaylistRows.playlist_id == playlist_id,
|
|
||||||
PlaylistRows.plr_rownum.in_(row_numbers),
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def fixup_rownumbers(session: scoped_session, playlist_id: int) -> None:
|
def fixup_rownumbers(session: scoped_session, playlist_id: int) -> None:
|
||||||
"""
|
"""
|
||||||
|
|||||||
@ -740,7 +740,10 @@ class Window(QMainWindow, Ui_MainWindow):
|
|||||||
times a second; this function has much better resolution.
|
times a second; this function has much better resolution.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
if track_sequence.now.track_id is None or track_sequence.now.start_time is None:
|
if (
|
||||||
|
track_sequence.now.track_id is None
|
||||||
|
or track_sequence.now.start_time is None
|
||||||
|
):
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
now = datetime.now()
|
now = datetime.now()
|
||||||
@ -897,7 +900,8 @@ class Window(QMainWindow, Ui_MainWindow):
|
|||||||
plrs_to_move = [
|
plrs_to_move = [
|
||||||
plr
|
plr
|
||||||
for plr in playlistrows
|
for plr in playlistrows
|
||||||
if plr.id not in [track_sequence.now.plr_id, track_sequence.next.plr_id]
|
if plr.id
|
||||||
|
not in [track_sequence.now.plr_id, track_sequence.next.plr_id]
|
||||||
]
|
]
|
||||||
|
|
||||||
rows_to_delete = [
|
rows_to_delete = [
|
||||||
|
|||||||
@ -347,11 +347,8 @@ class PlaylistModel(QAbstractTableModel):
|
|||||||
Delete passed rows from model
|
Delete passed rows from model
|
||||||
"""
|
"""
|
||||||
|
|
||||||
with Session() as session:
|
# TODO
|
||||||
PlaylistRows.delete_rows(session, self.playlist_id, row_numbers)
|
print(f"Delete rows {row_numbers=}")
|
||||||
PlaylistRows.fixup_rownumbers(session, self.playlist_id)
|
|
||||||
self.refresh_data(session)
|
|
||||||
self.update_track_times()
|
|
||||||
|
|
||||||
def display_role(self, row: int, column: int, prd: PlaylistRowData) -> QVariant:
|
def display_role(self, row: int, column: int, prd: PlaylistRowData) -> QVariant:
|
||||||
"""
|
"""
|
||||||
@ -448,17 +445,6 @@ class PlaylistModel(QAbstractTableModel):
|
|||||||
|
|
||||||
return QVariant(boldfont)
|
return QVariant(boldfont)
|
||||||
|
|
||||||
def get_rows_duration(self, row_numbers: List[int]) -> int:
|
|
||||||
"""
|
|
||||||
Return the total duration of the passed rows
|
|
||||||
"""
|
|
||||||
|
|
||||||
duration = 0
|
|
||||||
for row_number in row_numbers:
|
|
||||||
duration += self.playlist_rows[row_number].duration
|
|
||||||
|
|
||||||
return duration
|
|
||||||
|
|
||||||
def headerData(
|
def headerData(
|
||||||
self,
|
self,
|
||||||
section: int,
|
section: int,
|
||||||
@ -726,9 +712,7 @@ class PlaylistModel(QAbstractTableModel):
|
|||||||
|
|
||||||
# Check to see whether any rows in track_sequence have moved
|
# Check to see whether any rows in track_sequence have moved
|
||||||
if track_sequence.previous.plr_rownum in row_map:
|
if track_sequence.previous.plr_rownum in row_map:
|
||||||
track_sequence.previous.plr_rownum = row_map[
|
track_sequence.previous.plr_rownum = row_map[track_sequence.previous.plr_rownum]
|
||||||
track_sequence.previous.plr_rownum
|
|
||||||
]
|
|
||||||
if track_sequence.now.plr_rownum in row_map:
|
if track_sequence.now.plr_rownum in row_map:
|
||||||
track_sequence.now.plr_rownum = row_map[track_sequence.now.plr_rownum]
|
track_sequence.now.plr_rownum = row_map[track_sequence.now.plr_rownum]
|
||||||
if track_sequence.next.plr_rownum in row_map:
|
if track_sequence.next.plr_rownum in row_map:
|
||||||
@ -939,7 +923,7 @@ class PlaylistModel(QAbstractTableModel):
|
|||||||
Sort selected rows by artist
|
Sort selected rows by artist
|
||||||
"""
|
"""
|
||||||
|
|
||||||
self.sort_by_attribute(row_numbers, "artist")
|
self.sort_by_attribute(row_numbers, 'artist')
|
||||||
|
|
||||||
def sort_by_attribute(self, row_numbers: List[int], attr_name: str) -> None:
|
def sort_by_attribute(self, row_numbers: List[int], attr_name: str) -> None:
|
||||||
"""
|
"""
|
||||||
@ -951,8 +935,8 @@ class PlaylistModel(QAbstractTableModel):
|
|||||||
# interested in
|
# interested in
|
||||||
shortlist_rows = {k: self.playlist_rows[k] for k in row_numbers}
|
shortlist_rows = {k: self.playlist_rows[k] for k in row_numbers}
|
||||||
sorted_list = [
|
sorted_list = [
|
||||||
plr.plr_rownum
|
plr.plr_rownum for plr in
|
||||||
for plr in sorted(shortlist_rows.values(), key=attrgetter(attr_name))
|
sorted(shortlist_rows.values(), key=attrgetter(attr_name))
|
||||||
]
|
]
|
||||||
self.move_rows(sorted_list, min(sorted_list))
|
self.move_rows(sorted_list, min(sorted_list))
|
||||||
|
|
||||||
@ -961,21 +945,21 @@ class PlaylistModel(QAbstractTableModel):
|
|||||||
Sort selected rows by duration
|
Sort selected rows by duration
|
||||||
"""
|
"""
|
||||||
|
|
||||||
self.sort_by_attribute(row_numbers, "duration")
|
self.sort_by_attribute(row_numbers, 'duration')
|
||||||
|
|
||||||
def sort_by_lastplayed(self, row_numbers: List[int]) -> None:
|
def sort_by_lastplayed(self, row_numbers: List[int]) -> None:
|
||||||
"""
|
"""
|
||||||
Sort selected rows by lastplayed
|
Sort selected rows by lastplayed
|
||||||
"""
|
"""
|
||||||
|
|
||||||
self.sort_by_attribute(row_numbers, "lastplayed")
|
self.sort_by_attribute(row_numbers, 'lastplayed')
|
||||||
|
|
||||||
def sort_by_title(self, row_numbers: List[int]) -> None:
|
def sort_by_title(self, row_numbers: List[int]) -> None:
|
||||||
"""
|
"""
|
||||||
Sort selected rows by title
|
Sort selected rows by title
|
||||||
"""
|
"""
|
||||||
|
|
||||||
self.sort_by_attribute(row_numbers, "title")
|
self.sort_by_attribute(row_numbers, 'title')
|
||||||
|
|
||||||
def supportedDropActions(self) -> Qt.DropAction:
|
def supportedDropActions(self) -> Qt.DropAction:
|
||||||
return Qt.DropAction.MoveAction | Qt.DropAction.CopyAction
|
return Qt.DropAction.MoveAction | Qt.DropAction.CopyAction
|
||||||
@ -1001,10 +985,7 @@ class PlaylistModel(QAbstractTableModel):
|
|||||||
continue
|
continue
|
||||||
|
|
||||||
# Set start time for next row if we have a current track
|
# Set start time for next row if we have a current track
|
||||||
if (
|
if row_number == track_sequence.next.plr_rownum and track_sequence.now.end_time:
|
||||||
row_number == track_sequence.next.plr_rownum
|
|
||||||
and track_sequence.now.end_time
|
|
||||||
):
|
|
||||||
stend.start_time = track_sequence.now.end_time
|
stend.start_time = track_sequence.now.end_time
|
||||||
stend.end_time = stend.start_time + timedelta(milliseconds=prd.duration)
|
stend.end_time = stend.start_time + timedelta(milliseconds=prd.duration)
|
||||||
next_start_time = stend.end_time
|
next_start_time = stend.end_time
|
||||||
|
|||||||
1907
app/playlists.py
1907
app/playlists.py
File diff suppressed because it is too large
Load Diff
@ -18,6 +18,7 @@ test_tracks = [
|
|||||||
|
|
||||||
|
|
||||||
def create_model_with_tracks(session: scoped_session) -> "playlistmodel.PlaylistModel":
|
def create_model_with_tracks(session: scoped_session) -> "playlistmodel.PlaylistModel":
|
||||||
|
|
||||||
playlist = Playlists(session, "test playlist")
|
playlist = Playlists(session, "test playlist")
|
||||||
model = playlistmodel.PlaylistModel(playlist.id)
|
model = playlistmodel.PlaylistModel(playlist.id)
|
||||||
|
|
||||||
@ -227,12 +228,14 @@ def test_insert_header_row_middle(monkeypatch, session):
|
|||||||
|
|
||||||
|
|
||||||
def test_create_model_with_tracks(monkeypatch, session):
|
def test_create_model_with_tracks(monkeypatch, session):
|
||||||
|
|
||||||
monkeypatch.setattr(playlistmodel, "Session", session)
|
monkeypatch.setattr(playlistmodel, "Session", session)
|
||||||
model = create_model_with_tracks(session)
|
model = create_model_with_tracks(session)
|
||||||
assert len(model.playlist_rows) == len(test_tracks)
|
assert len(model.playlist_rows) == len(test_tracks)
|
||||||
|
|
||||||
|
|
||||||
def test_timing_one_track(monkeypatch, session):
|
def test_timing_one_track(monkeypatch, session):
|
||||||
|
|
||||||
START_ROW = 0
|
START_ROW = 0
|
||||||
END_ROW = 2
|
END_ROW = 2
|
||||||
|
|
||||||
@ -264,3 +267,4 @@ def test_timing_one_track(monkeypatch, session):
|
|||||||
# model.edit_role(model.rowCount(), playlistmodel.Col.NOTE.value, prd)
|
# model.edit_role(model.rowCount(), playlistmodel.Col.NOTE.value, prd)
|
||||||
# == note_text
|
# == note_text
|
||||||
# )
|
# )
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user