next: allow shows to be late
This commit is contained in:
parent
437857c735
commit
d4d266e7c5
1 changed files with 12 additions and 2 deletions
14
ics-now.py
14
ics-now.py
|
@ -48,6 +48,13 @@ class IcsNow:
|
|||
default=parse_minutes(60),
|
||||
help='How many minute should "next" include?',
|
||||
)
|
||||
self.parser.add_argument(
|
||||
"--next-late",
|
||||
metavar="DURATION",
|
||||
type=parse_minutes,
|
||||
default=parse_minutes(10),
|
||||
help='How many minutes can the "next" show be late?',
|
||||
)
|
||||
self.parser.add_argument(
|
||||
"--ics-query",
|
||||
type=Path,
|
||||
|
@ -78,8 +85,11 @@ class IcsNow:
|
|||
# FIXME: sort by priority
|
||||
return events[0]
|
||||
|
||||
def pick_next(self, events: list[Event], current) -> Event | None:
|
||||
events.remove(current)
|
||||
def pick_next(self, events: list[Event], current) -> Optional[Event]:
|
||||
events = [
|
||||
e for e in events
|
||||
if e['DTSTART'].dt > (self.args.now - self.args.next_late)
|
||||
]
|
||||
if not events:
|
||||
return None
|
||||
events.sort(key=lambda e: e['DTSTART'].dt)
|
||||
|
|
Loading…
Reference in a new issue