aniview 2.1.2 → 3.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/aniview +4 -4
- data/lib/aniview.rb +1 -1
- data/lib/aniview/interface/animeio/animefile.rb +4 -2
- data/lib/aniview/interface/animeio/animeio.rb +226 -175
- data/lib/aniview/interface/animeio/animeseries.rb +29 -45
- data/lib/aniview/interface/bridge.rb +11 -0
- data/lib/aniview/interface/deluge/delugec.rb +16 -10
- data/lib/aniview/interface/item.rb +3 -0
- data/lib/aniview/interface/mpv/mpvbridge.rb +38 -8
- data/lib/aniview/interface/pref/defaults.json +6 -5
- data/lib/aniview/interface/pref/pref.rb +40 -16
- data/lib/aniview/interface/pref/validate.json +2 -1
- data/lib/aniview/interface/schedule/schedule.rb +17 -18
- data/lib/aniview/interface/subscription/subscription.rb +22 -16
- data/lib/aniview/util/util.rb +1 -1
- data/lib/aniview/view/aiomenu.rb +15 -23
- data/lib/aniview/view/delugemenu.rb +12 -21
- data/lib/aniview/view/menu.rb +123 -91
- data/lib/aniview/view/prefmenu.rb +11 -27
- data/lib/aniview/view/schedulemenu.rb +0 -11
- data/lib/aniview/view/statusline.rb +42 -5
- data/lib/aniview/view/subscriptionmenu.rb +16 -20
- data/lib/application.rb +89 -68
- data/lib/daemon.rb +20 -6
- metadata +3 -2
@@ -7,52 +7,36 @@ module Aniview
|
|
7
7
|
module Interface
|
8
8
|
class AnimeSeries < Item
|
9
9
|
include Aniview::Util
|
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
|
-
@children.each{ |child|
|
37
|
-
size += child.attributes["s"]
|
38
|
-
}
|
39
|
-
return size
|
40
|
-
end
|
41
|
-
|
42
|
-
def oldestChild
|
43
|
-
oldest = DateTime.now.strftime('%Q')
|
44
|
-
@children.each{ |child|
|
45
|
-
|
46
|
-
}
|
47
|
-
end
|
48
|
-
|
49
|
-
def title
|
50
|
-
return @path
|
51
|
-
end
|
10
|
+
|
11
|
+
def initialize(path, children = [])
|
12
|
+
@path = path
|
13
|
+
|
14
|
+
@attr = {
|
15
|
+
"t" => String(@path),
|
16
|
+
"c" => 0,
|
17
|
+
"d" => 0,
|
18
|
+
"s" => 0,
|
19
|
+
}
|
20
|
+
|
21
|
+
@children = children
|
22
|
+
@children.each { |c| self + c }
|
23
|
+
end
|
24
|
+
|
25
|
+
def + af
|
26
|
+
@attr["d"] += af.attr["d"]
|
27
|
+
@attr["D"] = Util.format_duration @attr["d"]
|
28
|
+
@attr["s"] += af.attr["s"]
|
29
|
+
@attr["S"] = Util.format_size @attr["s"]
|
30
|
+
@attr["c"] += 1
|
31
|
+
end
|
32
|
+
|
33
|
+
def title
|
34
|
+
return @path
|
35
|
+
end
|
52
36
|
|
53
|
-
|
54
|
-
|
55
|
-
|
37
|
+
def attributes
|
38
|
+
return @attr
|
39
|
+
end
|
56
40
|
end
|
57
41
|
end
|
58
42
|
end
|
@@ -3,11 +3,11 @@ require_relative 'torrentitem'
|
|
3
3
|
|
4
4
|
module Aniview
|
5
5
|
module Interface
|
6
|
-
|
7
|
-
|
6
|
+
|
7
|
+
class DelugeC < Bridge
|
8
|
+
|
8
9
|
def initialize pref
|
9
10
|
@pref = pref
|
10
|
-
|
11
11
|
host = @pref.get("deluge_config")["host"]
|
12
12
|
login = @pref.get("deluge_config")["login"]
|
13
13
|
password = @pref.get("deluge_config")["password"]
|
@@ -32,7 +32,7 @@ module Aniview
|
|
32
32
|
connect
|
33
33
|
|
34
34
|
end
|
35
|
-
|
35
|
+
|
36
36
|
def getStatus
|
37
37
|
@status
|
38
38
|
end
|
@@ -62,7 +62,7 @@ module Aniview
|
|
62
62
|
File.open(Dir.home + "/.config/deluge/auth") { |f| f.read }.split(":")
|
63
63
|
end
|
64
64
|
|
65
|
-
def
|
65
|
+
def items
|
66
66
|
connect unless @connected
|
67
67
|
return {} unless @connected
|
68
68
|
|
@@ -108,7 +108,7 @@ module Aniview
|
|
108
108
|
#"tracker_host"
|
109
109
|
]
|
110
110
|
|
111
|
-
|
111
|
+
makeHash @client.core.get_torrents_status({}, tkeys)
|
112
112
|
end
|
113
113
|
|
114
114
|
def toggleTorrent torrentItem
|
@@ -132,16 +132,22 @@ module Aniview
|
|
132
132
|
begin
|
133
133
|
tid = @client.core.add_torrent_magnet(mag, {"download_location": loc})
|
134
134
|
rescue Deluge::Rpc::Connection::InvokeTimeoutError
|
135
|
-
puts "[delugec] Error: timeout error" if verbose
|
135
|
+
#puts "[delugec] Error: timeout error" if verbose
|
136
136
|
tid = nil
|
137
137
|
rescue Errno::EPIPE
|
138
|
-
puts "[delugec] Error: Errno::EPIPE" if verbose
|
138
|
+
#puts "[delugec] Error: Errno::EPIPE" if verbose
|
139
139
|
tid = nil
|
140
140
|
end
|
141
|
-
p tid
|
142
141
|
return true if tid.class == String and tid.length > 1
|
142
|
+
addTorrentCli mag, loc
|
143
143
|
return false
|
144
144
|
end
|
145
|
+
|
146
|
+
def addTorrentCli mag, loc
|
147
|
+
cli_tool = @pref.get("deluge_config")["cli_executable"]
|
148
|
+
command = "add #{mag} -p #{Shellwords.escape loc}"
|
149
|
+
result = %x(#{cli_tool} '#{command}')
|
150
|
+
end
|
145
151
|
|
146
152
|
def makeHash(arr)
|
147
153
|
ret = {}
|
@@ -157,7 +163,7 @@ module Aniview
|
|
157
163
|
)
|
158
164
|
ret.merge!(torrent => torrent)
|
159
165
|
}
|
160
|
-
|
166
|
+
ret
|
161
167
|
end
|
162
168
|
|
163
169
|
end
|
@@ -1,20 +1,47 @@
|
|
1
1
|
require 'mpv'
|
2
2
|
require_relative '../../util/util'
|
3
|
+
require 'logger'
|
3
4
|
|
4
5
|
module Aniview
|
5
6
|
module Interface
|
6
7
|
class MPVBridge
|
8
|
+
|
7
9
|
include Aniview::Util
|
10
|
+
|
11
|
+
include Observable
|
12
|
+
|
13
|
+
attr_accessor :playing
|
14
|
+
attr_accessor :what_changed
|
15
|
+
|
8
16
|
def initialize pref
|
9
17
|
@pref = pref
|
10
18
|
@mpv_enabled = true
|
19
|
+
@logger = Logger.new('mpv.log')
|
20
|
+
@logger.level = Logger::DEBUG
|
11
21
|
connect
|
22
|
+
@what_changed = ""
|
23
|
+
@playing = false
|
12
24
|
end
|
13
|
-
|
25
|
+
|
26
|
+
def event_handler event
|
27
|
+
case event
|
28
|
+
when "start-file"
|
29
|
+
@playing = true
|
30
|
+
@what_changed = "playing_status"
|
31
|
+
changed
|
32
|
+
notify_observers
|
33
|
+
when "end-file"
|
34
|
+
@playing = false
|
35
|
+
@what_changed = "playing_status"
|
36
|
+
changed
|
37
|
+
notify_observers
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
14
41
|
def quit!
|
15
42
|
@mpv.quit! unless @mpv == nil
|
16
43
|
end
|
17
|
-
|
44
|
+
|
18
45
|
def connect
|
19
46
|
return unless @mpv_enabled
|
20
47
|
return unless @mpv == nil or @mpv.client.get_property("idle-active") == nil
|
@@ -22,6 +49,7 @@ module Aniview
|
|
22
49
|
@mpv_enabled = false
|
23
50
|
begin
|
24
51
|
@mpv = MPV::Session.new(user_args: @pref.get("mpv_args").split(" "))
|
52
|
+
@mpv.callbacks << MPV::Callback.new(self, :event_handler)
|
25
53
|
rescue MPV::MPVNotAvailableError
|
26
54
|
rescue MPV::MPVUnsupportedFlagError
|
27
55
|
else
|
@@ -34,11 +62,11 @@ module Aniview
|
|
34
62
|
connect
|
35
63
|
@playing_file = file
|
36
64
|
@mpv.client.command "loadfile", file.path
|
65
|
+
@playing = true
|
37
66
|
end
|
38
67
|
|
39
68
|
def playing?
|
40
|
-
|
41
|
-
@mpv.client.get_property("time-pos") != nil
|
69
|
+
@playing
|
42
70
|
end
|
43
71
|
|
44
72
|
def checkSetWatched percentage
|
@@ -47,13 +75,15 @@ module Aniview
|
|
47
75
|
pct = Float(percentage)
|
48
76
|
if pct >= swp and not @playing_file.seen?
|
49
77
|
@playing_file.watch
|
78
|
+
@what_changed = "local_anime"
|
79
|
+
changed
|
80
|
+
notify_observers
|
50
81
|
end
|
51
82
|
end
|
52
83
|
end
|
53
84
|
|
54
85
|
def attributes
|
55
86
|
if playing?
|
56
|
-
|
57
87
|
r = {}
|
58
88
|
props = [
|
59
89
|
"time-pos",
|
@@ -80,14 +110,14 @@ module Aniview
|
|
80
110
|
"t" => Util.format_duration(r["t"]),
|
81
111
|
"p" => Util.format_progress(r["p"]),
|
82
112
|
"d" => Util.format_duration(r["d"]),
|
83
|
-
"n" => r["n"]
|
113
|
+
"n" => r["n"],
|
84
114
|
}
|
85
115
|
else
|
86
116
|
{
|
87
|
-
"t" => "
|
117
|
+
"t" => "-",
|
88
118
|
"p" => "0",
|
89
119
|
"d" => "0:00",
|
90
|
-
"n" => "."
|
120
|
+
"n" => ".",
|
91
121
|
}
|
92
122
|
end
|
93
123
|
end
|
@@ -71,24 +71,25 @@
|
|
71
71
|
"title" : " %t",
|
72
72
|
"parent" : " %t@ %v "
|
73
73
|
},
|
74
|
-
"format_status" : " %n - %t/%d@ %p ",
|
74
|
+
"format_status" : " %n - %t/%d@ %p\\% ",
|
75
75
|
"deluge_config" :
|
76
76
|
{
|
77
77
|
"host" : "localhost",
|
78
78
|
"port" : "58846",
|
79
79
|
"login" : "",
|
80
|
-
"password" : ""
|
80
|
+
"password" : "",
|
81
|
+
"cli_executable" : "/Applications/Deluge.app/Contents/MacOS/deluge-console"
|
81
82
|
},
|
82
83
|
"rss_feed" :
|
83
84
|
{
|
84
|
-
"url" : "https://
|
85
|
-
"refresh_interval" : "
|
85
|
+
"url" : "https://www.tokyotosho.info/rss.php?filter=1&minMB=100&maxMB=500&reversepolarity=1&entries=300",
|
86
|
+
"refresh_interval" : "300"
|
86
87
|
},
|
87
88
|
"daemon" :
|
88
89
|
{
|
89
90
|
"port" : "21312"
|
90
91
|
},
|
91
|
-
"set_watched_percentage"
|
92
|
+
"set_watched_percentage" : "80",
|
92
93
|
"log_file" : "$conf_dir/aw.log",
|
93
94
|
"daemon_log_file" : "$conf_dir/server.log",
|
94
95
|
"watch_log" : "$conf_dir/watchlog",
|
@@ -3,12 +3,15 @@ require 'json'
|
|
3
3
|
|
4
4
|
require_relative 'prefitem'
|
5
5
|
require_relative '../../view/color'
|
6
|
+
require_relative '../bridge'
|
6
7
|
|
7
8
|
module Aniview
|
8
9
|
module Interface
|
9
|
-
class Pref
|
10
|
+
class Pref < Bridge
|
11
|
+
|
12
|
+
include Observable
|
13
|
+
|
10
14
|
def initialize
|
11
|
-
|
12
15
|
@home = Dir.home
|
13
16
|
@conf = @home + "/.config/aniview"
|
14
17
|
|
@@ -17,11 +20,13 @@ module Aniview
|
|
17
20
|
}
|
18
21
|
|
19
22
|
FileUtils.mkdir_p(@conf) unless File.directory?(@conf)
|
20
|
-
|
23
|
+
|
21
24
|
@pref_file = @conf + "/aniview.json"
|
25
|
+
|
26
|
+
@saving = false
|
22
27
|
|
23
|
-
|
24
|
-
|
28
|
+
defaults should_save: true if not File.exist?(@pref_file)
|
29
|
+
load
|
25
30
|
end
|
26
31
|
|
27
32
|
def parseDir path
|
@@ -32,9 +37,9 @@ module Aniview
|
|
32
37
|
return path
|
33
38
|
end
|
34
39
|
|
35
|
-
def defaults(should_save:
|
40
|
+
def defaults(should_save:false)
|
36
41
|
File.open(File.join(File.dirname(__FILE__), "/defaults.json"), "r") {|f| @pref = JSON.parse(f.read)}
|
37
|
-
|
42
|
+
save if should_save
|
38
43
|
end
|
39
44
|
|
40
45
|
def set(s, val)
|
@@ -42,9 +47,10 @@ module Aniview
|
|
42
47
|
trail = s if s.class == Array
|
43
48
|
if valpref(trail, val, @validate)
|
44
49
|
@pref = setpref(trail, val, @pref)
|
50
|
+
save
|
51
|
+
changed
|
52
|
+
notify_observers
|
45
53
|
end
|
46
|
-
|
47
|
-
save
|
48
54
|
end
|
49
55
|
|
50
56
|
def setpref(trail, destination, map)
|
@@ -103,13 +109,13 @@ module Aniview
|
|
103
109
|
def get s
|
104
110
|
return @pref[s] if @pref.key?(s)
|
105
111
|
end
|
106
|
-
|
107
|
-
def
|
112
|
+
|
113
|
+
def items
|
108
114
|
ignore = {
|
109
115
|
"local_anime" => true,
|
110
116
|
"schedule" => true,
|
111
117
|
}
|
112
|
-
|
118
|
+
|
113
119
|
r = {}
|
114
120
|
@pref.each{ |item|
|
115
121
|
next if ignore.key? item[0]
|
@@ -130,17 +136,35 @@ module Aniview
|
|
130
136
|
}
|
131
137
|
return r
|
132
138
|
end
|
133
|
-
|
139
|
+
|
134
140
|
def save
|
141
|
+
@saving = true
|
135
142
|
File.open(@pref_file, "w") { |f| f.write(JSON.pretty_generate(@pref)) }
|
143
|
+
@saving = false
|
144
|
+
end
|
145
|
+
|
146
|
+
def saving?
|
147
|
+
@saving
|
136
148
|
end
|
137
149
|
|
138
150
|
def load
|
139
151
|
begin
|
140
|
-
|
141
|
-
|
142
|
-
#
|
152
|
+
#json = ""
|
153
|
+
json = File.open(@pref_file, "r") {|f| f.read}
|
154
|
+
#puts json
|
155
|
+
if json == ""
|
156
|
+
#puts "going to defaults"
|
157
|
+
defaults
|
158
|
+
return
|
159
|
+
end
|
160
|
+
@pref = JSON.parse json
|
161
|
+
rescue JSON::ParserError
|
162
|
+
puts "severe! your preference file #{@pref_file} is corrupted,"
|
163
|
+
puts "please fix the file or delete it to restore defaults"
|
164
|
+
exit
|
143
165
|
end
|
166
|
+
changed
|
167
|
+
notify_observers
|
144
168
|
end
|
145
169
|
end
|
146
170
|
end
|
@@ -2,13 +2,18 @@ require 'fileutils'
|
|
2
2
|
|
3
3
|
require_relative 'scheduleitem'
|
4
4
|
require_relative '../../util/util'
|
5
|
+
require_relative '../bridge'
|
5
6
|
|
6
7
|
module Aniview
|
7
8
|
module Interface
|
8
|
-
class Schedule
|
9
|
+
class Schedule < Bridge
|
9
10
|
|
10
11
|
include Aniview::Util
|
11
12
|
|
13
|
+
include Observable
|
14
|
+
|
15
|
+
attr_accessor :schedule
|
16
|
+
|
12
17
|
def initialize pref
|
13
18
|
@pref = pref
|
14
19
|
load
|
@@ -21,20 +26,20 @@ module Aniview
|
|
21
26
|
end
|
22
27
|
end
|
23
28
|
|
24
|
-
def
|
29
|
+
def items
|
25
30
|
empty?
|
26
|
-
|
31
|
+
@schedule.map{ |t| [t,t] }.to_h
|
27
32
|
end
|
28
33
|
|
29
34
|
def getAllCereal
|
30
35
|
r=""
|
31
36
|
getAll.each { |si| r+=si.cereal }
|
32
|
-
|
37
|
+
r
|
33
38
|
end
|
34
39
|
|
35
|
-
def mergeItems
|
36
|
-
|
37
|
-
@schedule.each { |schedule_item|
|
40
|
+
def mergeItems _items
|
41
|
+
_items.each { |item|
|
42
|
+
@schedule.each { |schedule_item|
|
38
43
|
if item.id == schedule_item.id
|
39
44
|
m = [schedule_item.attributes["m"], item.attributes["m"]]
|
40
45
|
if m[0] != m[1]
|
@@ -63,7 +68,7 @@ module Aniview
|
|
63
68
|
@schedule[loc].setTitle val
|
64
69
|
new_dir = @pref.parseDir @schedule[loc].attributes["p"]
|
65
70
|
|
66
|
-
FileUtils.mv old_dir, new_dir unless old_dir == new_dir
|
71
|
+
FileUtils.mv old_dir, new_dir unless old_dir.downcase == new_dir.downcase
|
67
72
|
|
68
73
|
save
|
69
74
|
end
|
@@ -75,10 +80,12 @@ module Aniview
|
|
75
80
|
|
76
81
|
def save
|
77
82
|
@pref.set "schedule", (Util.encode_object @schedule)
|
83
|
+
changed
|
84
|
+
notify_observers
|
78
85
|
end
|
79
86
|
|
80
87
|
def load
|
81
|
-
|
88
|
+
#@pref.load
|
82
89
|
raw = @pref.get "schedule"
|
83
90
|
if not raw == nil and raw.class == String
|
84
91
|
@schedule = Util.decode_object raw
|
@@ -86,15 +93,7 @@ module Aniview
|
|
86
93
|
empty?
|
87
94
|
end
|
88
95
|
end
|
89
|
-
|
90
|
-
def makeHash(arr)
|
91
|
-
ret = {}
|
92
|
-
arr.each{ |t|
|
93
|
-
ret.merge!(t => t)
|
94
|
-
}
|
95
|
-
return ret
|
96
|
-
end
|
97
|
-
|
96
|
+
|
98
97
|
end
|
99
98
|
end
|
100
99
|
end
|