diff --git a/ics-now.py b/ics-now.py index 9964493..7b56e5f 100644 --- a/ics-now.py +++ b/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)