aniview 1.3.0 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/bin/aniview +2 -3
- data/lib/aniview.rb +50 -243
- data/lib/aniview/client/aniclient.rb +111 -53
- data/lib/aniview/interface/animeio/animefile.rb +73 -64
- data/lib/aniview/interface/animeio/animeio.rb +184 -181
- data/lib/aniview/interface/animeio/animeseries.rb +53 -48
- data/lib/aniview/interface/deluge/delugec.rb +158 -153
- data/lib/aniview/interface/deluge/torrentitem.rb +21 -16
- data/lib/aniview/interface/item.rb +21 -17
- data/lib/aniview/interface/mpv/mpvbridge.rb +78 -73
- data/lib/aniview/interface/pref/pref.rb +135 -132
- data/lib/aniview/interface/pref/prefitem.rb +16 -15
- data/lib/aniview/interface/schedule/schedule.rb +89 -83
- data/lib/aniview/interface/schedule/scheduleitem.rb +54 -51
- data/lib/aniview/interface/subscription/subscription.rb +111 -108
- data/lib/aniview/util/term.rb +39 -36
- data/lib/aniview/util/util.rb +149 -0
- data/lib/aniview/view/aiomenu.rb +68 -63
- data/lib/aniview/view/color.rb +69 -67
- data/lib/aniview/view/delugemenu.rb +44 -40
- data/lib/aniview/view/menu.rb +281 -286
- data/lib/aniview/view/prefmenu.rb +36 -34
- data/lib/aniview/view/schedulemenu.rb +32 -29
- data/lib/aniview/view/statusline.rb +19 -14
- data/lib/aniview/view/subscriptionmenu.rb +35 -32
- data/lib/application.rb +260 -0
- data/lib/daemon.rb +174 -0
- metadata +5 -12
- data/bin/aniviewd +0 -20
- data/lib/aniview/util/alogger.rb +0 -18
- data/lib/aniview/util/command.rb +0 -25
- data/lib/aniview/util/format.rb +0 -123
- data/lib/aniview/util/online.rb +0 -12
- data/lib/aniview/util/serializer.rb +0 -19
- data/lib/aniview/util/stringhelp.rb +0 -50
- data/lib/aniview/view/emote.rb +0 -345
- data/lib/aniviewd.rb +0 -179
data/lib/aniview/util/term.rb
CHANGED
@@ -1,37 +1,40 @@
|
|
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
|
-
|
1
|
+
module Aniview
|
2
|
+
module Util
|
3
|
+
class Term
|
4
|
+
def initialize
|
5
|
+
@tput=Hash[
|
6
|
+
"smcup" => %x(tput smcup),
|
7
|
+
"rmcup" => %x(tput rmcup),
|
8
|
+
"civis" => %x(tput civis),
|
9
|
+
"cnorm" => %x(tput cnorm),
|
10
|
+
"el1" => "\e[2K",
|
11
|
+
"bold" => %x(tput bold),
|
12
|
+
"nobold" => %x(tput sgr0),
|
13
|
+
]
|
14
|
+
end
|
15
|
+
|
16
|
+
def save; print @tput["smcup"]; return self; end
|
17
|
+
def restore; print @tput["rmcup"]; return self; end
|
18
|
+
def hide_cursor; print @tput["civis"]; return self; end
|
19
|
+
def show_cursor; print @tput["cnorm"]; return self; end
|
20
|
+
def clear_line; print @tput["el1"]; return self; end
|
21
|
+
def echo_off; %x(stty -echo); return self; end
|
22
|
+
def echo_on; %x(stty echo); return self; end
|
23
|
+
def clear; print "\033[2J"; return self; end
|
24
|
+
def bold; print @tput["bold"]; return self; end
|
25
|
+
def nobold; print @tput["nobold"]; return self; end
|
26
|
+
|
27
|
+
def cols; return HighLine::SystemExtensions.terminal_size[0]; end
|
28
|
+
def rows; return HighLine::SystemExtensions.terminal_size[1]; end
|
29
|
+
|
30
|
+
def getKey
|
31
|
+
return STDIN.getch.gsub("\r", "enter").gsub(" ", "space").gsub("A", "up").gsub("B", "down").gsub("C", "right").gsub("D", "left").gsub("\e", "skip").gsub("[", "skip")
|
32
|
+
end
|
33
|
+
|
34
|
+
def reset
|
35
|
+
self.restore.show_cursor.echo_on
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
39
|
+
end
|
37
40
|
end
|
@@ -0,0 +1,149 @@
|
|
1
|
+
require 'base64'
|
2
|
+
require 'readline'
|
3
|
+
|
4
|
+
module Aniview
|
5
|
+
module Util
|
6
|
+
def self.readline(term, prompt = "", default = "")
|
7
|
+
term.bold.echo_on
|
8
|
+
print "\033[" + String(term.rows) + ";1H" + Aniview::View::Color.white
|
9
|
+
term.show_cursor
|
10
|
+
Readline.completion_append_character = ""
|
11
|
+
Readline.pre_input_hook = -> do
|
12
|
+
Readline.insert_text default
|
13
|
+
Readline.redisplay
|
14
|
+
Readline.pre_input_hook = nil
|
15
|
+
end
|
16
|
+
input = Readline.readline(prompt, false)
|
17
|
+
term.hide_cursor.nobold.echo_off.clear
|
18
|
+
return input
|
19
|
+
end
|
20
|
+
|
21
|
+
def self.format_duration v
|
22
|
+
hours = Integer((v-(v%3600))/3600)
|
23
|
+
minutes = Integer( ((v-(v%60))/60) - (hours * 60))
|
24
|
+
seconds = Integer(v%60)
|
25
|
+
seconds = "0" + String(seconds) if seconds < 10
|
26
|
+
if hours < 1 and minutes < 1
|
27
|
+
"0:#{seconds}"
|
28
|
+
else
|
29
|
+
if hours < 1
|
30
|
+
return "#{String(minutes)}:#{String(seconds)}"
|
31
|
+
else
|
32
|
+
minutes = "0" + String(minutes) if minutes < 10
|
33
|
+
return "#{String(hours)}:#{String(minutes)}:#{String(seconds)}"
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
def self.format_size s
|
39
|
+
fs = Float(s)
|
40
|
+
|
41
|
+
bytecount = {
|
42
|
+
"TB" => 1000000000000.0,
|
43
|
+
"GB" => 1000000000.0,
|
44
|
+
"MB" => 1000000.0,
|
45
|
+
"KB" => 1000.0,
|
46
|
+
"B" => 1.0,
|
47
|
+
}
|
48
|
+
r = "TB"
|
49
|
+
r = "GB" if s < bytecount["TB"]
|
50
|
+
r = "MB" if s < bytecount["GB"]
|
51
|
+
r = "KB" if s < bytecount["KB"]
|
52
|
+
|
53
|
+
return String( Float(fs/bytecount[r] * 10.0 ).round / 10.0 ) + r
|
54
|
+
end
|
55
|
+
|
56
|
+
def self.format_progress p
|
57
|
+
return "#{Integer(p)}.#{Integer(p * 10.0) % 10}"
|
58
|
+
end
|
59
|
+
|
60
|
+
def self.parse_format string, d, cols
|
61
|
+
le = "\e[K\n"
|
62
|
+
|
63
|
+
pstr = []
|
64
|
+
add_to = ""
|
65
|
+
buffer_char = []
|
66
|
+
|
67
|
+
mode = "char"
|
68
|
+
|
69
|
+
padding_collected = 0
|
70
|
+
|
71
|
+
string.split('').each { |c|
|
72
|
+
|
73
|
+
if mode == "e"
|
74
|
+
add_to += String(c)
|
75
|
+
mode = "char"
|
76
|
+
|
77
|
+
elsif c == '%'
|
78
|
+
mode = "%"
|
79
|
+
|
80
|
+
elsif c == '$'
|
81
|
+
mode = "$"
|
82
|
+
|
83
|
+
elsif c == '@'
|
84
|
+
pstr << add_to
|
85
|
+
add_to = ""
|
86
|
+
mode = "@"
|
87
|
+
|
88
|
+
elsif c == "#"
|
89
|
+
padding_collected += 1
|
90
|
+
|
91
|
+
elsif c == "\\"
|
92
|
+
mode = "e"
|
93
|
+
|
94
|
+
elsif mode == "@"
|
95
|
+
buffer_char << c
|
96
|
+
mode = "char"
|
97
|
+
|
98
|
+
elsif mode == "%"
|
99
|
+
addstr = ""
|
100
|
+
addstr = String(d[c]) if d.key?(c)
|
101
|
+
ol = addstr.length
|
102
|
+
addstr = " " + addstr while addstr.length < (ol + padding_collected)
|
103
|
+
add_to += addstr
|
104
|
+
mode = "char"
|
105
|
+
|
106
|
+
else
|
107
|
+
add_to += c
|
108
|
+
|
109
|
+
end
|
110
|
+
}
|
111
|
+
pstr << add_to
|
112
|
+
|
113
|
+
buffer_char << " " if buffer_char.length == 0
|
114
|
+
|
115
|
+
midstr = ""
|
116
|
+
tl = 0
|
117
|
+
pstr.each{ |s| tl += s.length }
|
118
|
+
buffer_space = 0
|
119
|
+
buffer_space = (cols - tl) / (pstr.length - 1) if pstr.length > 1
|
120
|
+
|
121
|
+
addl_space = (cols - tl) % pstr.length
|
122
|
+
|
123
|
+
pstr.each_with_index{ |str, i|
|
124
|
+
break if i == pstr.length - 1
|
125
|
+
buffer_ = ""
|
126
|
+
buffer_ = buffer_char[i] * buffer_space if buffer_space >= 0
|
127
|
+
|
128
|
+
midstr += str + buffer_
|
129
|
+
}
|
130
|
+
midstr += pstr[pstr.length - 1]
|
131
|
+
|
132
|
+
return midstr[0..cols-1]
|
133
|
+
end
|
134
|
+
|
135
|
+
def self.encode_object d
|
136
|
+
Base64.strict_encode64(Marshal.dump d)
|
137
|
+
end
|
138
|
+
|
139
|
+
def self.decode_object e
|
140
|
+
begin
|
141
|
+
Marshal.load(Base64.decode64(e))
|
142
|
+
rescue ArgumentError
|
143
|
+
{}
|
144
|
+
rescue TypeError
|
145
|
+
{}
|
146
|
+
end
|
147
|
+
end
|
148
|
+
end
|
149
|
+
end
|
data/lib/aniview/view/aiomenu.rb
CHANGED
@@ -1,66 +1,71 @@
|
|
1
1
|
require_relative 'menu'
|
2
|
-
require_relative '../util/
|
2
|
+
require_relative '../util/util'
|
3
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
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
4
|
+
module Aniview
|
5
|
+
module View
|
6
|
+
class AioMenu < Menu
|
7
|
+
include Aniview::Util
|
8
|
+
def setmal malanime
|
9
|
+
@malanime = malanime
|
10
|
+
end
|
11
|
+
|
12
|
+
def refresh
|
13
|
+
@items = @interface.makeHash @interface.send(@refresh_function)
|
14
|
+
|
15
|
+
@attributes = {
|
16
|
+
"t" => @attributes["t"],
|
17
|
+
"D" => Util.format_duration(getDuration),
|
18
|
+
"S" => Util.format_size(getSize)
|
19
|
+
}
|
20
|
+
|
21
|
+
@expanded = -1 if @items.values[@expanded] == nil
|
22
|
+
fixCursor
|
23
|
+
end
|
24
|
+
|
25
|
+
def getDuration
|
26
|
+
dur = 0
|
27
|
+
@items.each{ |child|
|
28
|
+
dur += child[0].attributes["d"]
|
29
|
+
}
|
30
|
+
return dur
|
31
|
+
end
|
32
|
+
|
33
|
+
def getSize
|
34
|
+
size = 0
|
35
|
+
@items.each{ |child|
|
36
|
+
size += child[0].attributes["s"]
|
37
|
+
}
|
38
|
+
return size
|
39
|
+
end
|
40
|
+
|
41
|
+
def customControl(key, sel)
|
42
|
+
path = @items.values[sel["out"]][sel["in"]].path
|
43
|
+
|
44
|
+
if key == @pref.get("keybindings")["menu_nav_expand"]
|
45
|
+
expand(sel["out"])
|
46
|
+
elsif key == "r"
|
47
|
+
refresh
|
48
|
+
elsif key == "enter"
|
49
|
+
|
50
|
+
@interface.watch(@items.values[sel["out"]][sel["in"]])
|
51
|
+
#@interface.addWatched(path)
|
52
|
+
@interface.logWatched(path)
|
53
|
+
|
54
|
+
#@malanime.update(path)
|
55
|
+
|
56
|
+
refresh
|
57
|
+
elsif key == @pref.get("keybindings")["anime_set_watched"]
|
58
|
+
@interface.addWatched(path)
|
59
|
+
refresh
|
60
|
+
elsif key == @pref.get("keybindings")["anime_undo_set_watched"]
|
61
|
+
@interface.rmWatched()
|
62
|
+
refresh
|
63
|
+
elsif key == @pref.get("keybindings")["anime_set_unwatched"]
|
64
|
+
@interface.rmWatched(path)
|
65
|
+
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
66
70
|
end
|
71
|
+
|
data/lib/aniview/view/color.rb
CHANGED
@@ -1,67 +1,69 @@
|
|
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
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
end
|
1
|
+
module Aniview
|
2
|
+
module View
|
3
|
+
module Color
|
4
|
+
def self.black
|
5
|
+
"\e[30m"
|
6
|
+
end
|
7
|
+
|
8
|
+
def self.red
|
9
|
+
"\e[31m"
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.green
|
13
|
+
"\e[32m"
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.yellow
|
17
|
+
"\e[33m"
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.blue
|
21
|
+
"\e[34m"
|
22
|
+
end
|
23
|
+
|
24
|
+
def self.magenta
|
25
|
+
"\e[35m"
|
26
|
+
end
|
27
|
+
|
28
|
+
def self.cyan
|
29
|
+
"\e[36m"
|
30
|
+
end
|
31
|
+
|
32
|
+
def self.white
|
33
|
+
"\e[37m"
|
34
|
+
end
|
35
|
+
|
36
|
+
def self.bright_black
|
37
|
+
"\e[37m"
|
38
|
+
end
|
39
|
+
|
40
|
+
def self.bright_red
|
41
|
+
"\e[38m"
|
42
|
+
end
|
43
|
+
|
44
|
+
def self.bright_green
|
45
|
+
"\e[39m"
|
46
|
+
end
|
47
|
+
|
48
|
+
def self.bright_yellow
|
49
|
+
"\e[40m"
|
50
|
+
end
|
51
|
+
|
52
|
+
def self.bright_blue
|
53
|
+
"\e[41m"
|
54
|
+
end
|
55
|
+
|
56
|
+
def self.bright_magenta
|
57
|
+
"\e[42m"
|
58
|
+
end
|
59
|
+
|
60
|
+
def self.bright_cyan
|
61
|
+
"\e[43m"
|
62
|
+
end
|
63
|
+
|
64
|
+
def self.bright_white
|
65
|
+
"\e[44m"
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|