Compare commits
No commits in common. "21fe8fff8382aa488443f9f9d68a9234667c25ce" and "32fb44439dfe7d52817a62f948c61e2f51656f26" have entirely different histories.
21fe8fff83
...
32fb44439d
@ -106,7 +106,7 @@ class Playdates(Base):
|
|||||||
pd.lastplayed = datetime.now()
|
pd.lastplayed = datetime.now()
|
||||||
pd.track_id = track.id
|
pd.track_id = track.id
|
||||||
session.add(pd)
|
session.add(pd)
|
||||||
track.update_lastplayed(session, track.id)
|
track.update_lastplayed()
|
||||||
session.commit()
|
session.commit()
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@ -596,11 +596,8 @@ class Tracks(Base):
|
|||||||
return session.query(Tracks).filter(
|
return session.query(Tracks).filter(
|
||||||
Tracks.id == id).one()
|
Tracks.id == id).one()
|
||||||
|
|
||||||
@staticmethod
|
def update_lastplayed(self):
|
||||||
def update_lastplayed(session, track_id):
|
self.lastplayed = datetime.now()
|
||||||
track = session.query(Tracks).filter(Tracks.id == track_id).one()
|
|
||||||
track.lastplayed = datetime.now()
|
|
||||||
session.commit()
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def update_artist(session, track_id, artist):
|
def update_artist(session, track_id, artist):
|
||||||
|
|||||||
@ -511,6 +511,7 @@ class Window(QMainWindow, Ui_MainWindow):
|
|||||||
QColor(Config.COLOUR_NEXT_TAB))
|
QColor(Config.COLOUR_NEXT_TAB))
|
||||||
|
|
||||||
# Tell database to record it as played
|
# Tell database to record it as played
|
||||||
|
self.current_track.update_lastplayed()
|
||||||
Playdates.add_playdate(session, self.current_track)
|
Playdates.add_playdate(session, self.current_track)
|
||||||
|
|
||||||
self.disable_play_next_controls()
|
self.disable_play_next_controls()
|
||||||
|
|||||||
@ -66,27 +66,12 @@ def create_track_from_file(session, path, verbose=False):
|
|||||||
str = f"Importing {path}"
|
str = f"Importing {path}"
|
||||||
INFO(str)
|
INFO(str)
|
||||||
INFO("-" * len(str))
|
INFO("-" * len(str))
|
||||||
|
track = Tracks.get_or_create(session, path)
|
||||||
|
if verbose:
|
||||||
INFO("Get track info...")
|
INFO("Get track info...")
|
||||||
t = get_music_info(path)
|
t = get_music_info(path)
|
||||||
title = t['title']
|
track.title = t['title']
|
||||||
artist = t['artist']
|
track.artist = t['artist']
|
||||||
if verbose:
|
|
||||||
INFO(f" Title: \"{title}\"")
|
|
||||||
INFO(f" Artist: \"{artist}\"")
|
|
||||||
# Check for duplicate
|
|
||||||
tracks = Tracks.search_titles(session, title)
|
|
||||||
if tracks:
|
|
||||||
print("Found the following possible matches:")
|
|
||||||
for track in tracks:
|
|
||||||
print(f'"{track.title}" by {track.artist}')
|
|
||||||
response = input("Continue [c] or abort [a]?")
|
|
||||||
if not response:
|
|
||||||
return
|
|
||||||
if response[0].lower() not in ['c', 'y']:
|
|
||||||
return
|
|
||||||
track = Tracks.get_or_create(session, path)
|
|
||||||
track.title = title
|
|
||||||
track.artist = artist
|
|
||||||
track.duration = int(round(
|
track.duration = int(round(
|
||||||
t['duration'], Config.MILLISECOND_SIGFIGS) * 1000)
|
t['duration'], Config.MILLISECOND_SIGFIGS) * 1000)
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user