aboutsummaryrefslogtreecommitdiff
path: root/pl/cfg.pl
blob: fa17b38392012faa9eca6c6ed7e093c6c55be0a3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
:- module(cfg, [set_glob/1,
		get_glob/1,
		set_root/1,
		get_root/1,
		set_url/1,
		get_url/1]).

:- use_module(library(registry)).

set_key(Key, Value) :-
	registry_set_key(current_user/software/'JohnAJ'/'EpisodeBrowser'/'Settings', Key, Value).
get_key(Key, Value) :-
	catch(registry_get_key(current_user/software/'JohnAJ'/'EpisodeBrowser'/'Settings', Key, Value),
	      _,
	      fail).

set_root(V) :- set_key('EpisodeRoot', V).
get_root(V) :-
	get_key('EpisodeRoot', V0),
	re_replace('\\\\', '/', V0, V1),
	atom_string(V, V1).

set_glob(V) :- set_key('EpisodeGlob', V).
get_glob(V) :-
	(   get_key('EpisodeGlob', V), !
	;   V = '*/*.*'
	).

set_url(V) :- set_key('UrlPrefix', V).
get_url(V) :-
	(   get_key('UrlPrefix', V), !
	;   V = 'https://gogoanime.fi/detective-conan-episode-'
	).

set_view_watched(V) :- set_key('ViewWatched', V).
get_view_watched(V) :-
	(   get_key('ViewWatched', V),
	    integer(V), !
	;   V = 1
	).

set_view_tv_original(V) :- set_key('ViewTVOriginal', V).
get_view_tv_original(V) :-
	(   get_key('ViewTVOriginal', V),
	    integer(V), !
	;   V = 1
	).

set_sort(V) :- W is V + 2147483647, set_key('Sort', W).
get_sort(V) :-
	(   get_key('Sort', W),
	    integer(W), !,
	    V is W - 2147483647
	;   V = 1
	).