aboutsummaryrefslogtreecommitdiff
path: root/pl/local_episodes.pl
diff options
context:
space:
mode:
authorJohn Ankarström <john@ankarstrom.se>2022-02-15 15:38:57 +0100
committerJohn Ankarström <john@ankarstrom.se>2022-02-15 15:38:57 +0100
commit09ec144a99f1234a37d04854bdfb81485540be97 (patch)
treece3050a062a76dd12980b08ef36eb7ac35b7e6f8 /pl/local_episodes.pl
parentfed19b9942575e7c0360a0d77a3c544afdbaeb6c (diff)
downloadEpisodeBrowser-09ec144a99f1234a37d04854bdfb81485540be97.tar.gz
Put C code and Prolog code in separate directories.
Diffstat (limited to 'pl/local_episodes.pl')
-rw-r--r--pl/local_episodes.pl31
1 files changed, 31 insertions, 0 deletions
diff --git a/pl/local_episodes.pl b/pl/local_episodes.pl
new file mode 100644
index 0000000..283ccb7
--- /dev/null
+++ b/pl/local_episodes.pl
@@ -0,0 +1,31 @@
+:- module(local_episodes, [local_episode//1,
+ episode_file/2,
+ open_episode/1]).
+
+:- use_module(library(dcg/basics)).
+:- use_module(atom_dcg).
+
+local_episode -->
+ local_episode(_).
+local_episode(N) -->
+ string(_), "Detective_Conan_-_", integer(N), string(_).
+local_episode(N) -->
+ string(_), "Detective_Conan_-_",
+ integer(First), "-", integer(Last), string(_),
+ { Second is First + 1, between(Second, Last, N) }.
+
+% Find episode on disk.
+
+episode_file(N, F) :-
+ expand_file_name('C:/Users/John/Nedladdningar/Detective Conan season 1 to season 22 + season 23(incomplete)/*/*.*',
+ F1),
+ ( nonvar(N)
+ -> include(atom_phrase(local_episode(N)), F1, [F|_])
+ ; include(atom_phrase(local_episode), F1, F2),
+ member(F, F2),
+ atom_phrase(local_episode(N), F)
+ ).
+
+open_episode(N) :-
+ episode_file(N, F),
+ win_shell(open, F).