aboutsummaryrefslogtreecommitdiff
path: root/pl/track_episodes.pl
diff options
context:
space:
mode:
authorJohn Ankarström <john@ankarstrom.se>2022-04-27 16:06:42 +0200
committerJohn Ankarström <john@ankarstrom.se>2022-04-27 16:06:42 +0200
commit00d22febd2c73f5ccb058ca2211294b1a1d99e9c (patch)
tree02612dd2181b5e1abafc0da663f1141dfb05adff /pl/track_episodes.pl
parentdd855b6091c1eb9835cd2466ed2e225dd4f850a4 (diff)
downloadEpisodeBrowser-00d22febd2c73f5ccb058ca2211294b1a1d99e9c.tar.gz
Press left/right to select next/previous unwatched episode.
Diffstat (limited to 'pl/track_episodes.pl')
-rw-r--r--pl/track_episodes.pl18
1 files changed, 17 insertions, 1 deletions
diff --git a/pl/track_episodes.pl b/pl/track_episodes.pl
index f18e85c..1973a75 100644
--- a/pl/track_episodes.pl
+++ b/pl/track_episodes.pl
@@ -2,7 +2,9 @@
toggle_episode/1,
forget_episode/1,
most_recently_watched/1,
- watched/1]).
+ watched/1,
+ next_unwatched/2,
+ previous_unwatched/2]).
:- use_module(library(dcg/basics)).
:- use_module(library(registry)).
@@ -94,3 +96,17 @@ most_recently_watched(Ep) :-
watched(Ep) :-
episode_watched(Ep, true).
+
+next_unwatched(Ep0, Ep) :-
+ Ep1 is Ep0 + 1,
+ ( \+ watched(Ep1)
+ -> Ep = Ep1
+ ; next_unwatched(Ep1, Ep)
+ ).
+
+previous_unwatched(Ep0, Ep) :-
+ Ep1 is Ep0 - 1,
+ ( \+ watched(Ep1)
+ -> Ep = Ep1
+ ; previous_unwatched(Ep1, Ep)
+ ).