aboutsummaryrefslogtreecommitdiff
path: root/pl
diff options
context:
space:
mode:
Diffstat (limited to 'pl')
-rw-r--r--pl/episode_data.pl32
1 files changed, 24 insertions, 8 deletions
diff --git a/pl/episode_data.pl b/pl/episode_data.pl
index bde723f..f6c599c 100644
--- a/pl/episode_data.pl
+++ b/pl/episode_data.pl
@@ -16,6 +16,7 @@
:- use_module(atom_dcg).
:- persistent episode_title(episode:integer, title:atom).
+:- persistent episode_wiki(episode:integer, wiki:atom).
:- persistent episode_datum(episode:integer, key:atom, value:atom).
:- persistent episode_rating(episode:integer, rating:integer).
@@ -61,20 +62,29 @@ rate_episode(Ep, R) :-
assert_episode_rating(Ep, R)
).
+open_episode_wiki(Ep) :-
+ episode_wiki(Ep, W),
+ win_shell(open, W).
+
tv_original(Ep) :- episode_datum(Ep, 'Source', 'TV Original').
% Remote data retrieval.
+absolute_url(R) --> "https://www.detectiveconanworld.com", R.
+
update_episode_data :-
- findall(Ep-Title-Data,
- (fetch_episode_title_data(Ep, Title, Data)),
+ findall(Ep-Info,
+ (fetch_episode_info(Ep, Info)),
Set),
- maplist(set_episode_data, Set).
+ maplist(set_episode_info, Set).
-set_episode_data(Ep-Title-Data) :-
- maybe_assert_episode_title(Ep, Title),
- maplist(set_episode_datum(Ep), Data).
+set_episode_info(Ep-Info) :-
+ maplist(set_episode_datum(Ep), Info).
+set_episode_datum(Ep, 'Title'-Title) :- !,
+ maybe_assert_episode_title(Ep, Title).
+set_episode_datum(Ep, 'Wiki'-W) :- !,
+ maybe_assert_episode_wiki(Ep, W).
set_episode_datum(Ep, Key-Value) :-
maybe_assert_episode_datum(Ep, Key, Value).
@@ -83,6 +93,11 @@ maybe_assert_episode_title(Ep, Title) :-
; assert_episode_title(Ep, Title)
).
+maybe_assert_episode_wiki(Ep, W) :-
+ ( episode_wiki(Ep, W), !
+ ; assert_episode_wiki(Ep, W)
+ ).
+
maybe_assert_episode_datum(Ep, Key, Value) :-
( episode_datum(Ep, Key, Value), !
; ( episode_datum(Ep, Key, _)
@@ -95,12 +110,14 @@ maybe_assert_episode_datum(Ep, Key, Value) :-
episode_number(Ep) --> integer(Ep).
episode_number(Ep) --> integer(Ep), "WPS", integer(_).
-fetch_episode_title_data(Ep, Title, ['Date'-Date, 'Source'-Source, 'Hint'-Hint]) :-
+fetch_episode_info(Ep, ['Title'-Title, 'Wiki'-W, 'Date'-Date, 'Source'-Source, 'Hint'-Hint]) :-
cached_html('https://www.detectiveconanworld.com/wiki/Anime', H),
xpath(H, //tr(td(index(3),@style='background:#f2fde9;')), R),
xpath(R, td(index(1),normalize_space), Ep0),
atom_phrase(episode_number(Ep), Ep0),
xpath(R, td(index(3),normalize_space), Title),
+ xpath(R, td(index(3))/a(@href), W0),
+ atom_phrase(absolute_url(W0), W),
xpath(R, td(index(4),normalize_space), Date),
xpath(R, td(index(7),normalize_space), Source0),
re_replace('\\(([0-9])', ' (\\1', Source0, Source1),
@@ -131,7 +148,6 @@ fetch_screenwriter_url(Name, U) :-
xpath(A, /self(normalize_space), Name),
xpath(A, /self(@href), U).
-absolute_url(R) --> "https://www.detectiveconanworld.com", R.
screenwriter_episode(Ep) --> string(_), "(Episode ", integer(Ep), ")".
screenwriter_episode(Ep) --> string(_), "(Episodes ", integer(Ep1), "-", integer(Ep2), ")",
{ between(Ep1, Ep2, Ep) }.