Skip to content

Commit

Permalink
Merge pull request #323 from eichblatt/dev
Browse files Browse the repository at this point in the history
next show by artist
  • Loading branch information
eichblatt authored Oct 30, 2022
2 parents 1f88e7a + 58641a7 commit 9e65d31
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 5 deletions.
2 changes: 1 addition & 1 deletion timemachine/.latest_tag
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v1.3.10
v1.3.11
22 changes: 19 additions & 3 deletions timemachine/controls.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import os
import string
import subprocess
from bisect import bisect
from time import sleep
from threading import BoundedSemaphore, Event

Expand Down Expand Up @@ -275,6 +276,21 @@ def shows_available(self):
def tape_available(self):
return len(self.shows_available()) > 0

def next_show_by_artist(self, artist):
if self.archive is None:
return None
self._update()
current_index = bisect(self.archive.dates, self.fmtdate())
for d in self.archive.dates[current_index:] + self.archive.dates[:current_index]:
artists = [t.artist for t in self.archive.tape_dates[d]]
artists = list(dict.fromkeys(artists)) # make it the unique set
if not artist in artists:
continue
shownum = artists.index(artist)
logger.debug(f" artist is {artist}. artists: {artists}. date {d}. Shownum {shownum}")
return (datetime.datetime.fromisoformat(d).date(), shownum)
return None

def next_show(self):
if self.archive is None:
return None
Expand All @@ -288,9 +304,9 @@ def next_date(self):
if self.archive is None:
return None
self._update()
for d in self.archive.dates:
if d > self.fmtdate():
return datetime.datetime.fromisoformat(d).date()
current_index = bisect(self.archive.dates, self.fmtdate())
for d in self.archive.dates[current_index:] + self.archive.dates[:current_index]:
return datetime.datetime.fromisoformat(d).date()
return self.date


Expand Down
6 changes: 5 additions & 1 deletion timemachine/livemusic.py
Original file line number Diff line number Diff line change
Expand Up @@ -468,7 +468,11 @@ def day_button(button, state):
if button.is_pressed or button.is_held:
return
logger.debug("pressing day button")
state.date_reader.set_date(*state.date_reader.next_show())
current = state.get_current()
if current['EXPERIENCE'] and current['ARTIST'] is not None:
state.date_reader.set_date(*state.date_reader.next_show_by_artist(current['ARTIST']))
else:
state.date_reader.set_date(*state.date_reader.next_show())
stagedate_event.set()


Expand Down

0 comments on commit 9e65d31

Please sign in to comment.