aboutsummaryrefslogtreecommitdiff
path: root/pl/episode_data.pl
diff options
context:
space:
mode:
authorJohn Ankarström <john@ankarstrom.se>2022-04-01 03:57:11 +0200
committerJohn Ankarström <john@ankarstrom.se>2022-04-01 03:57:11 +0200
commit3d907443ef27355ec9ced8a244fd678df1ea2538 (patch)
tree183a6b7a9794c7a43cf5a533b26ea2089712e8be /pl/episode_data.pl
parenta4e988fc5a727cc0c4b9718c6a2ac875d8413752 (diff)
downloadEpisodeBrowser-3d907443ef27355ec9ced8a244fd678df1ea2538.tar.gz
Ensure episode data is downloaded.
Diffstat (limited to 'pl/episode_data.pl')
-rw-r--r--pl/episode_data.pl5
1 files changed, 4 insertions, 1 deletions
diff --git a/pl/episode_data.pl b/pl/episode_data.pl
index 0c43bdc..1bdde79 100644
--- a/pl/episode_data.pl
+++ b/pl/episode_data.pl
@@ -23,6 +23,7 @@ detach :-
% Interface.
last_episode(Ep) :-
+ ensure,
setof(E, N^D^lookup_episode_local(E,N,D), Es),
last(Es, Ep).
@@ -35,7 +36,6 @@ lookup_episode_remote(Ep, Name, Data) :-
update, !,
episode_name_data(Ep, Name, Data).
-
retract_episode(Ep) :-
( episode_name_data(Ep, _, _)
-> retractall_episode_name_data(Ep, _, _)
@@ -52,6 +52,9 @@ episode_number(Ep) --> padding(Ep), integer(Ep).
% Database updating.
+ensure :- episode_name_data(_, _, _), !.
+ensure :- update.
+
update :-
remote(R0), !,
findall(Ep-Name-Data, (xpath(R0, //tr, R),