aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Ankarström <john@ankarstrom.se>2022-05-29 00:21:48 +0200
committerJohn Ankarström <john@ankarstrom.se>2022-05-29 00:21:48 +0200
commit6fbb54d91b78cd0f89196ea091ad786469396692 (patch)
treedda863c45429259a5547f0c84e2fda4edf087e42
parent2355ab8c49b91d3d0797408d72d627870bcdd896 (diff)
downloadEpisodeBrowser-6fbb54d91b78cd0f89196ea091ad786469396692.tar.gz
Add Wiki context menu option.
It opens the Detective Conan World wiki page for the focused episode.
-rw-r--r--c/main.c4
-rw-r--r--c/resource.h1
-rw-r--r--c/resource.rc1
-rw-r--r--pl/episode_data.pl32
4 files changed, 30 insertions, 8 deletions
diff --git a/c/main.c b/c/main.c
index 9e56c11..78af35c 100644
--- a/c/main.c
+++ b/c/main.c
@@ -327,6 +327,7 @@ WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
case IDM_TOGGLE:
case IDM_FORGET:
case IDM_LOOKUP:
+ case IDM_WIKI:
case IDM_RATE10:
case IDM_RATE9:
case IDM_RATE8:
@@ -373,6 +374,9 @@ WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
ElvRedraw();
DlvShowEpisode(lvi.lParam);
break;
+ case IDM_WIKI:
+ P("episode_data","open_episode_wiki",1,t);
+ break;
case IDM_RATE10:
PI(t+1,10) break;
goto r;
diff --git a/c/resource.h b/c/resource.h
index 375de8b..6d4c090 100644
--- a/c/resource.h
+++ b/c/resource.h
@@ -21,6 +21,7 @@
#define IDM_TOGGLE 502
#define IDM_FORGET 503
#define IDM_LOOKUP 504
+#define IDM_WIKI 505
#define IDM_RATE10 525
#define IDM_RATE9 526
#define IDM_RATE8 527
diff --git a/c/resource.rc b/c/resource.rc
index 1811634..c6e1246 100644
--- a/c/resource.rc
+++ b/c/resource.rc
@@ -33,6 +33,7 @@ BEGIN
MENUITEM "&Toggle", IDM_TOGGLE
MENUITEM "&Forget", IDM_FORGET
MENUITEM "&Lookup", IDM_LOOKUP
+ MENUITEM "Wi&ki", IDM_WIKI
POPUP "&Rate"
BEGIN
MENUITEM "&10", IDM_RATE10
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) }.