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
@@ -1,17 +1,21 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
1
|
+
module Aniview
|
2
|
+
module Interface
|
3
|
+
class Item
|
4
|
+
def initialize()
|
5
|
+
@attr = {}
|
6
|
+
end
|
7
|
+
|
8
|
+
def attributes
|
9
|
+
return @attr
|
10
|
+
end
|
11
|
+
|
12
|
+
def cereal
|
13
|
+
contents = ""
|
14
|
+
@attr.each{ |a|
|
15
|
+
contents += String(a[1])
|
16
|
+
}
|
17
|
+
return "cereal-"+contents
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -1,80 +1,85 @@
|
|
1
1
|
require 'mpv'
|
2
|
-
require_relative '../../util/
|
2
|
+
require_relative '../../util/util'
|
3
3
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
@mpv.quit!
|
12
|
-
end
|
13
|
-
|
14
|
-
def connect
|
15
|
-
return unless @mpv == nil or @mpv.client.get_property("idle-active") == nil
|
16
|
-
@mpv = MPV::Session.new(user_args: @pref.get("mpv_args").split(" "))
|
17
|
-
end
|
18
|
-
|
19
|
-
def play file
|
20
|
-
connect
|
21
|
-
@playing_file = file
|
22
|
-
@mpv.client.command "loadfile", file.path
|
23
|
-
end
|
24
|
-
|
25
|
-
def playing?
|
26
|
-
@mpv.client.get_property("time-pos") != nil
|
27
|
-
end
|
28
|
-
|
29
|
-
def checkSetWatched percentage
|
30
|
-
if @playing_file != nil
|
31
|
-
swp = Integer(@pref.get "set_watched_percentage")
|
32
|
-
pct = Float(percentage)
|
33
|
-
if pct >= swp and not @playing_file.seen?
|
34
|
-
@playing_file.watch
|
4
|
+
module Aniview
|
5
|
+
module Interface
|
6
|
+
class MPVBridge
|
7
|
+
include Aniview::Util
|
8
|
+
def initialize pref
|
9
|
+
@pref = pref
|
10
|
+
connect
|
35
11
|
end
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
def attributes
|
40
|
-
if playing?
|
41
|
-
|
42
|
-
r = {}
|
43
|
-
props = [
|
44
|
-
"time-pos",
|
45
|
-
"percent-pos",
|
46
|
-
"duration"
|
47
|
-
]
|
48
|
-
props.each { |prop|
|
49
|
-
prop_val = @mpv.client.get_property(prop)
|
50
|
-
prop_val = 0 if prop_val == nil
|
51
|
-
r.merge!(
|
52
|
-
prop[0] => prop_val
|
53
|
-
)
|
54
|
-
}
|
55
|
-
|
56
|
-
if @playing_file != nil
|
57
|
-
r.merge!("n" => @playing_file.attributes["t"])
|
58
|
-
else
|
59
|
-
r.merge!("n" => "loading")
|
12
|
+
|
13
|
+
def quit!
|
14
|
+
@mpv.quit!
|
60
15
|
end
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
"
|
75
|
-
|
76
|
-
|
16
|
+
|
17
|
+
def connect
|
18
|
+
return unless @mpv == nil or @mpv.client.get_property("idle-active") == nil
|
19
|
+
@mpv = MPV::Session.new(user_args: @pref.get("mpv_args").split(" "))
|
20
|
+
end
|
21
|
+
|
22
|
+
def play file
|
23
|
+
connect
|
24
|
+
@playing_file = file
|
25
|
+
@mpv.client.command "loadfile", file.path
|
26
|
+
end
|
27
|
+
|
28
|
+
def playing?
|
29
|
+
@mpv.client.get_property("time-pos") != nil
|
30
|
+
end
|
31
|
+
|
32
|
+
def checkSetWatched percentage
|
33
|
+
if @playing_file != nil
|
34
|
+
swp = Integer(@pref.get "set_watched_percentage")
|
35
|
+
pct = Float(percentage)
|
36
|
+
if pct >= swp and not @playing_file.seen?
|
37
|
+
@playing_file.watch
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
def attributes
|
43
|
+
if playing?
|
44
|
+
|
45
|
+
r = {}
|
46
|
+
props = [
|
47
|
+
"time-pos",
|
48
|
+
"percent-pos",
|
49
|
+
"duration"
|
50
|
+
]
|
51
|
+
props.each { |prop|
|
52
|
+
prop_val = @mpv.client.get_property(prop)
|
53
|
+
prop_val = 0 if prop_val == nil
|
54
|
+
r.merge!(
|
55
|
+
prop[0] => prop_val
|
56
|
+
)
|
57
|
+
}
|
58
|
+
|
59
|
+
if @playing_file != nil
|
60
|
+
r.merge!("n" => @playing_file.attributes["t"])
|
61
|
+
else
|
62
|
+
r.merge!("n" => "loading")
|
63
|
+
end
|
64
|
+
|
65
|
+
checkSetWatched r["p"]
|
66
|
+
|
67
|
+
{
|
68
|
+
"t" => Util.format_duration(r["t"]),
|
69
|
+
"p" => Util.format_progress(r["p"]),
|
70
|
+
"d" => Util.format_duration(r["d"]),
|
71
|
+
"n" => r["n"]
|
72
|
+
}
|
73
|
+
else
|
74
|
+
{
|
75
|
+
"t" => "0:00",
|
76
|
+
"p" => "0",
|
77
|
+
"d" => "0:00",
|
78
|
+
"n" => "."
|
79
|
+
}
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
77
83
|
end
|
78
84
|
end
|
79
|
-
|
80
85
|
end
|
@@ -3,137 +3,140 @@ require 'json'
|
|
3
3
|
|
4
4
|
require_relative 'prefitem'
|
5
5
|
require_relative '../../view/color'
|
6
|
-
require_relative '../../util/alogger'
|
7
6
|
|
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
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
7
|
+
module Aniview
|
8
|
+
module Interface
|
9
|
+
class Pref
|
10
|
+
def initialize
|
11
|
+
|
12
|
+
@home = Dir.home
|
13
|
+
@conf = @home + "/.config/aniview"
|
14
|
+
|
15
|
+
File.open(File.join(File.dirname(__FILE__), "/validate.json"), "r") {
|
16
|
+
|f| @validate = JSON.parse(f.read)
|
17
|
+
}
|
18
|
+
|
19
|
+
FileUtils.mkdir_p(@conf) unless File.directory?(@conf)
|
20
|
+
|
21
|
+
@pref_file = @conf + "/aniview.json"
|
22
|
+
|
23
|
+
self.defaults if not File.exist?(@pref_file)
|
24
|
+
self.load
|
25
|
+
end
|
26
|
+
|
27
|
+
def parseDir path
|
28
|
+
path = path.gsub("$airing_dir", @pref["airing_dir"])
|
29
|
+
path = path.gsub("$conf_dir", @pref["conf_dir"])
|
30
|
+
path = path.gsub("~", Dir.home)
|
31
|
+
return path
|
32
|
+
end
|
33
|
+
|
34
|
+
def defaults
|
35
|
+
File.open(File.join(File.dirname(__FILE__), "/defaults.json"), "r") {|f| @pref = JSON.parse(f.read)}
|
36
|
+
self.save
|
37
|
+
end
|
38
|
+
|
39
|
+
def set(s, val)
|
40
|
+
trail = [s] if s.class == String
|
41
|
+
trail = s if s.class == Array
|
42
|
+
if valpref(trail, val, @validate)
|
43
|
+
@pref = setpref(trail, val, @pref)
|
44
|
+
end
|
45
|
+
|
46
|
+
save
|
47
|
+
end
|
48
|
+
|
49
|
+
def setpref(trail, destination, map)
|
50
|
+
if trail.length == 1
|
51
|
+
map[trail[0]] = destination
|
52
|
+
return map
|
53
|
+
else
|
54
|
+
|
55
|
+
blaze = trail[0]
|
56
|
+
map[blaze] = setpref(trail[1..-1], destination, map[blaze])
|
57
|
+
|
58
|
+
end
|
59
|
+
return map
|
60
|
+
end
|
61
|
+
|
62
|
+
def valpref(trail, destination, map)
|
63
|
+
|
64
|
+
if trail.length == 1
|
65
|
+
skeys = [
|
66
|
+
"space",
|
67
|
+
"up",
|
68
|
+
"down",
|
69
|
+
"left",
|
70
|
+
"right",
|
71
|
+
"enter"
|
72
|
+
]
|
73
|
+
|
74
|
+
case map[trail[0]]
|
75
|
+
when "key"
|
76
|
+
return false if destination.length != 1 and not skeys.include? destination
|
77
|
+
|
78
|
+
when "path"
|
79
|
+
destination.split(":").each { |d|
|
80
|
+
return false if not Dir.exist?(parseDir d)
|
81
|
+
}
|
82
|
+
|
83
|
+
when "color"
|
84
|
+
return false if not Aniview::View::Color.respond_to? destination
|
85
|
+
|
86
|
+
when "int"
|
87
|
+
return false if not destination.scan(/\D/).empty? and destination.length > 1
|
88
|
+
|
89
|
+
when "locked"
|
90
|
+
return false
|
91
|
+
|
92
|
+
end
|
93
|
+
|
94
|
+
return true
|
95
|
+
|
96
|
+
else
|
97
|
+
blaze = trail[0]
|
98
|
+
return valpref(trail[1..-1], destination, map[blaze])
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
def get s
|
103
|
+
return @pref[s] if @pref.key?(s)
|
104
|
+
end
|
105
|
+
|
106
|
+
def getAll
|
107
|
+
ignore = {
|
108
|
+
"local_anime" => true,
|
109
|
+
"schedule" => true,
|
110
|
+
}
|
111
|
+
|
112
|
+
r = {}
|
113
|
+
@pref.each{ |item|
|
114
|
+
next if ignore.key? item[0]
|
115
|
+
title = item[0]
|
116
|
+
if item[1].class == String
|
117
|
+
val = item[1]
|
118
|
+
elsif item[1].class == Array
|
119
|
+
val = item[1].join(":")
|
120
|
+
elsif item[1].class == Hash
|
121
|
+
item[1].each { |subitem|
|
122
|
+
subtitle = title + "_" + subitem[0]
|
123
|
+
subval = subitem[1]
|
124
|
+
r.merge!(PrefItem.new(subtitle, subval, []) => [PrefItem.new("", "", [item[0], subitem[0]])])
|
125
|
+
}
|
126
|
+
next
|
127
|
+
end
|
128
|
+
r.merge!(PrefItem.new(title, val, []) => [ PrefItem.new("", "", [item[0]]) ] )
|
129
|
+
}
|
130
|
+
return r
|
131
|
+
end
|
132
|
+
|
133
|
+
def save
|
134
|
+
File.open(@pref_file, "w") { |f| f.write(JSON.pretty_generate(@pref)) }
|
135
|
+
end
|
136
|
+
|
137
|
+
def load
|
138
|
+
File.open(@pref_file, "r") {|f| @pref = JSON.parse(f.read)}
|
139
|
+
end
|
140
|
+
end
|
141
|
+
end
|
139
142
|
end
|