This commit is contained in:
Keith Edmunds 2021-08-14 18:44:05 +01:00
parent e813a01e14
commit 89d49f3e34
2 changed files with 24 additions and 1 deletions

View File

@ -2,7 +2,7 @@
import sqlalchemy
from datetime import datetime
from datetime import datetime, time
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy import (
Boolean,
@ -130,6 +130,24 @@ class Playdates(Base):
).delete()
session.commit()
@staticmethod
def last_show(session, track):
"""
Return datetime track last played during show time or None
FIXME: hard coded times in here
"""
# dayofweek: 1 = Sunday, 2 = Monday, ..., 7 = Saturday.
friday = 6
after = time(20, 0)
return session.query(Playdates).filter(
(Playdates.track_id == track.id),
(func.dayofweek(Playdates.lastplayed) == friday),
(func.time(Playdates.lastplayed) > after),
).order_by(Playdates.lastplayed.desc()).first()
class Playlists(Base):
"""

View File

@ -530,6 +530,11 @@ class PlaylistTab(QTableWidget):
duration = Tracks.get_duration(session, self._get_row_id(row))
return start + timedelta(milliseconds=duration)
def _can_read_track(self, track):
"Check track file is readable"
return os.access(track.path, os.R_OK)
def _context_menu(self, pos):
self.menu.exec_(self.mapToGlobal(pos))