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,53 +1,58 @@
|
|
1
1
|
require 'date'
|
2
2
|
|
3
|
-
require_relative '../../util/
|
3
|
+
require_relative '../../util/util'
|
4
4
|
require_relative '../item'
|
5
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
|
-
|
6
|
+
module Aniview
|
7
|
+
module Interface
|
8
|
+
class AnimeSeries < Item
|
9
|
+
include Aniview::Util
|
10
|
+
def initialize(_dir, children)
|
11
|
+
@path = _dir
|
12
|
+
@children = children
|
13
|
+
|
14
|
+
dur = getDuration
|
15
|
+
size = getSize
|
16
|
+
|
17
|
+
@attr = {
|
18
|
+
"t" => String(@path),
|
19
|
+
"c" => String(@children.length),
|
20
|
+
"d" => dur,
|
21
|
+
"D" => Util.format_duration(dur),
|
22
|
+
"s" => size,
|
23
|
+
"S" => Util.format_size(size),
|
24
|
+
}
|
25
|
+
end
|
26
|
+
def getDuration
|
27
|
+
dur = 0
|
28
|
+
@children.each{ |child|
|
29
|
+
dur += child.attributes["d"]
|
30
|
+
}
|
31
|
+
return dur
|
32
|
+
end
|
33
|
+
|
34
|
+
def getSize
|
35
|
+
size = 0
|
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
|
52
|
+
|
53
|
+
def attributes
|
54
|
+
return @attr
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
53
58
|
end
|
@@ -1,159 +1,164 @@
|
|
1
1
|
require 'deluge'
|
2
2
|
require_relative 'torrentitem'
|
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
|
-
|
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
|
-
|
4
|
+
module Aniview
|
5
|
+
module Interface
|
6
|
+
class DelugeC
|
7
|
+
|
8
|
+
def initialize pref
|
9
|
+
@pref = pref
|
10
|
+
|
11
|
+
host = @pref.get("deluge_config")["host"]
|
12
|
+
login = @pref.get("deluge_config")["login"]
|
13
|
+
password = @pref.get("deluge_config")["password"]
|
14
|
+
|
15
|
+
if (login == "" and password == "") and (host == "127.0.0.1" or host == "localhost")
|
16
|
+
la = localAuth
|
17
|
+
login = la[0]
|
18
|
+
password = la[1]
|
19
|
+
@pref.set(["deluge_config", "login"], login)
|
20
|
+
@pref.set(["deluge_config", "password"], password)
|
21
|
+
end
|
22
|
+
|
23
|
+
@client = Deluge::Rpc::Client.new(
|
24
|
+
host: host,
|
25
|
+
port: Integer(@pref.get("deluge_config")["port"]),
|
26
|
+
login: @pref.get("deluge_config")["login"],
|
27
|
+
password: @pref.get("deluge_config")["password"]
|
28
|
+
)
|
29
|
+
|
30
|
+
@status = "not connected"
|
31
|
+
@connected = false
|
32
|
+
connect
|
33
|
+
|
34
|
+
end
|
35
|
+
|
36
|
+
def getStatus
|
37
|
+
@status
|
38
|
+
end
|
39
|
+
|
40
|
+
def connect
|
41
|
+
@connected = false
|
42
|
+
@status = "error connecting"
|
43
|
+
begin
|
44
|
+
@client.connect
|
45
|
+
rescue Deluge::Rpc::Connection::RPCError
|
46
|
+
@client.close
|
47
|
+
rescue RuntimeError
|
48
|
+
@client.close
|
49
|
+
else
|
50
|
+
@status = "connected"
|
51
|
+
@connected = true
|
52
|
+
end
|
53
|
+
|
54
|
+
@client.close unless @connected
|
55
|
+
end
|
56
|
+
|
57
|
+
def localAuth
|
58
|
+
authfile = Dir.home + "/.config/deluge/auth"
|
59
|
+
["", ""] if not File.exist? authfile
|
60
|
+
File.open(Dir.home + "/.config/deluge/auth") { |f| f.read }.split(":")
|
61
|
+
end
|
62
|
+
|
63
|
+
def getTorrents
|
64
|
+
connect unless @connected
|
65
|
+
return {} unless @connected
|
66
|
+
|
67
|
+
tkeys = [
|
68
|
+
"name",
|
69
|
+
"progress",
|
70
|
+
"eta",
|
71
|
+
"paused",
|
72
|
+
"state",
|
73
|
+
"hash",
|
74
|
+
#"active_time",
|
75
|
+
#"is_finished",
|
76
|
+
#"max_connections",
|
77
|
+
#"max_download_speed",
|
78
|
+
#"max_upload_slots",
|
79
|
+
#"max_upload_speed",
|
80
|
+
#"message",
|
81
|
+
#"next_announce",
|
82
|
+
#"num_peers",
|
83
|
+
#"num_seeds",
|
84
|
+
#"remove_at_ratio",
|
85
|
+
#"save_path",
|
86
|
+
#"seeding_time",
|
87
|
+
#"seeds_peers_ratio",
|
88
|
+
#"seed_rank",
|
89
|
+
#"stop_at_ratio",
|
90
|
+
#"stop_ratio",
|
91
|
+
#"time_added",
|
92
|
+
#"upload_payload_rate",
|
93
|
+
#"comment",
|
94
|
+
#"file_priorities",
|
95
|
+
#"file_progress",
|
96
|
+
#"files",
|
97
|
+
#"is_seed",
|
98
|
+
#"num_files",
|
99
|
+
#"num_pieces",
|
100
|
+
#"peers",
|
101
|
+
#"piece_length",
|
102
|
+
#"private",
|
103
|
+
#"queue",
|
104
|
+
#"ratio",
|
105
|
+
#"total_size",
|
106
|
+
#"tracker_host"
|
107
|
+
]
|
108
|
+
|
109
|
+
return @client.core.get_torrents_status({}, tkeys)
|
110
|
+
end
|
111
|
+
|
112
|
+
def toggleTorrent torrentItem
|
113
|
+
id = torrentItem.attributes["h"]
|
114
|
+
if torrentItem.attributes["u"]
|
115
|
+
@client.core.resume_torrent([id])
|
116
|
+
else
|
117
|
+
@client.core.pause_torrent([id])
|
118
|
+
end
|
119
|
+
end
|
120
|
+
|
121
|
+
def removeTorrent torrentItem, withData
|
122
|
+
id = torrentItem.attributes["h"]
|
123
|
+
@client.core.remove_torrent(id, withData)
|
124
|
+
end
|
125
|
+
|
126
|
+
def addTorrent mag, loc, verbose: false
|
127
|
+
connect unless @connected
|
128
|
+
return false unless @connected
|
129
|
+
puts "[delugec] connected!" if verbose
|
130
|
+
begin
|
131
|
+
tid = @client.core.add_torrent_magnet(mag, {"download_location": loc})
|
132
|
+
rescue Deluge::Rpc::Connection::InvokeTimeoutError
|
133
|
+
puts "[delugec] Error: timeout error" if verbose
|
134
|
+
tid = nil
|
135
|
+
rescue Errno::EPIPE
|
136
|
+
puts "[delugec] Error: Errno::EPIPE" if verbose
|
137
|
+
tid = nil
|
138
|
+
end
|
139
|
+
p tid
|
140
|
+
return true if tid.class == String and tid.length > 1
|
141
|
+
return false
|
142
|
+
end
|
143
|
+
|
144
|
+
def makeHash(arr)
|
145
|
+
ret = {}
|
146
|
+
arr.each{ |t|
|
147
|
+
tinfo = t[1]
|
148
|
+
torrent = TorrentItem.new(
|
149
|
+
name: tinfo["name"],
|
150
|
+
progress: tinfo["progress"],
|
151
|
+
eta: tinfo["eta"],
|
152
|
+
paused: tinfo["paused"],
|
153
|
+
state: tinfo["state"],
|
154
|
+
id: tinfo["hash"]
|
155
|
+
)
|
156
|
+
ret.merge!(torrent => torrent)
|
157
|
+
}
|
158
|
+
return ret
|
159
|
+
end
|
160
|
+
|
116
161
|
end
|
117
162
|
end
|
118
|
-
|
119
|
-
def removeTorrent torrentItem, withData
|
120
|
-
id = torrentItem.attributes["h"]
|
121
|
-
@client.core.remove_torrent(id, withData)
|
122
|
-
end
|
123
|
-
|
124
|
-
def addTorrent mag, loc, verbose: false
|
125
|
-
connect unless @connected
|
126
|
-
return false unless @connected
|
127
|
-
puts "[delugec] connected!" if verbose
|
128
|
-
begin
|
129
|
-
tid = @client.core.add_torrent_magnet(mag, {"download_location": loc})
|
130
|
-
rescue Deluge::Rpc::Connection::InvokeTimeoutError
|
131
|
-
puts "[delugec] Error: timeout error" if verbose
|
132
|
-
tid = nil
|
133
|
-
rescue Errno::EPIPE
|
134
|
-
puts "[delugec] Error: Errno::EPIPE" if verbose
|
135
|
-
tid = nil
|
136
|
-
end
|
137
|
-
p tid
|
138
|
-
return true if tid.class == String and tid.length > 1
|
139
|
-
return false
|
140
|
-
end
|
141
|
-
|
142
|
-
def makeHash(arr)
|
143
|
-
ret = {}
|
144
|
-
arr.each{ |t|
|
145
|
-
tinfo = t[1]
|
146
|
-
torrent = TorrentItem.new(
|
147
|
-
name: tinfo["name"],
|
148
|
-
progress: tinfo["progress"],
|
149
|
-
eta: tinfo["eta"],
|
150
|
-
paused: tinfo["paused"],
|
151
|
-
state: tinfo["state"],
|
152
|
-
id: tinfo["hash"]
|
153
|
-
)
|
154
|
-
ret.merge!(torrent => torrent)
|
155
|
-
}
|
156
|
-
return ret
|
157
|
-
end
|
158
|
-
|
159
163
|
end
|
164
|
+
|
@@ -1,19 +1,24 @@
|
|
1
|
-
require_relative '../../util/
|
1
|
+
require_relative '../../util/util'
|
2
2
|
require_relative '../item'
|
3
3
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
4
|
+
module Aniview
|
5
|
+
module Interface
|
6
|
+
class TorrentItem < Item
|
7
|
+
include Aniview::Util
|
8
|
+
def initialize(name:, progress:, eta:, paused:, state:, id:)
|
9
|
+
@attr = {
|
10
|
+
"n" => name,
|
11
|
+
"p" => Util.format_progress(progress),
|
12
|
+
"e" => Util.format_duration(eta),
|
13
|
+
"u" => paused,
|
14
|
+
"s" => state,
|
15
|
+
"h" => id
|
16
|
+
}
|
17
|
+
end
|
18
|
+
|
19
|
+
def attributes
|
20
|
+
return @attr
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
19
24
|
end
|