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.
Files changed (38) hide show
  1. checksums.yaml +4 -4
  2. data/bin/aniview +2 -3
  3. data/lib/aniview.rb +50 -243
  4. data/lib/aniview/client/aniclient.rb +111 -53
  5. data/lib/aniview/interface/animeio/animefile.rb +73 -64
  6. data/lib/aniview/interface/animeio/animeio.rb +184 -181
  7. data/lib/aniview/interface/animeio/animeseries.rb +53 -48
  8. data/lib/aniview/interface/deluge/delugec.rb +158 -153
  9. data/lib/aniview/interface/deluge/torrentitem.rb +21 -16
  10. data/lib/aniview/interface/item.rb +21 -17
  11. data/lib/aniview/interface/mpv/mpvbridge.rb +78 -73
  12. data/lib/aniview/interface/pref/pref.rb +135 -132
  13. data/lib/aniview/interface/pref/prefitem.rb +16 -15
  14. data/lib/aniview/interface/schedule/schedule.rb +89 -83
  15. data/lib/aniview/interface/schedule/scheduleitem.rb +54 -51
  16. data/lib/aniview/interface/subscription/subscription.rb +111 -108
  17. data/lib/aniview/util/term.rb +39 -36
  18. data/lib/aniview/util/util.rb +149 -0
  19. data/lib/aniview/view/aiomenu.rb +68 -63
  20. data/lib/aniview/view/color.rb +69 -67
  21. data/lib/aniview/view/delugemenu.rb +44 -40
  22. data/lib/aniview/view/menu.rb +281 -286
  23. data/lib/aniview/view/prefmenu.rb +36 -34
  24. data/lib/aniview/view/schedulemenu.rb +32 -29
  25. data/lib/aniview/view/statusline.rb +19 -14
  26. data/lib/aniview/view/subscriptionmenu.rb +35 -32
  27. data/lib/application.rb +260 -0
  28. data/lib/daemon.rb +174 -0
  29. metadata +5 -12
  30. data/bin/aniviewd +0 -20
  31. data/lib/aniview/util/alogger.rb +0 -18
  32. data/lib/aniview/util/command.rb +0 -25
  33. data/lib/aniview/util/format.rb +0 -123
  34. data/lib/aniview/util/online.rb +0 -12
  35. data/lib/aniview/util/serializer.rb +0 -19
  36. data/lib/aniview/util/stringhelp.rb +0 -50
  37. data/lib/aniview/view/emote.rb +0 -345
  38. data/lib/aniviewd.rb +0 -179
@@ -1,53 +1,58 @@
1
1
  require 'date'
2
2
 
3
- require_relative '../../util/format'
3
+ require_relative '../../util/util'
4
4
  require_relative '../item'
5
5
 
6
- class AnimeSeries < Item
7
- def initialize(_dir, children)
8
- @path = _dir
9
- @children = children
10
-
11
- dur = getDuration
12
- size = getSize
13
-
14
- @attr = {
15
- "t" => String(@path),
16
- "c" => String(@children.length),
17
- "d" => dur,
18
- "D" => Format.format_duration(dur),
19
- "s" => size,
20
- "S" => Format.format_size(size),
21
- }
22
- end
23
- def getDuration
24
- dur = 0
25
- @children.each{ |child|
26
- dur += child.attributes["d"]
27
- }
28
- return dur
29
- end
30
-
31
- def getSize
32
- size = 0
33
- @children.each{ |child|
34
- size += child.attributes["s"]
35
- }
36
- return size
37
- end
38
-
39
- def oldestChild
40
- oldest = DateTime.now.strftime('%Q')
41
- @children.each{ |child|
42
-
43
- }
44
- end
45
-
46
- def title
47
- return @path
48
- end
49
-
50
- def attributes
51
- return @attr
52
- end
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
- class DelugeC
5
-
6
- def initialize pref
7
- @pref = pref
8
-
9
- host = @pref.get("deluge_config")["host"]
10
- login = @pref.get("deluge_config")["login"]
11
- password = @pref.get("deluge_config")["password"]
12
-
13
- if (login == "" and password == "") and (host == "127.0.0.1" or host == "localhost")
14
- la = localAuth
15
- login = la[0]
16
- password = la[1]
17
- @pref.set(["deluge_config", "login"], login)
18
- @pref.set(["deluge_config", "password"], password)
19
- end
20
-
21
- @client = Deluge::Rpc::Client.new(
22
- host: host,
23
- port: Integer(@pref.get("deluge_config")["port"]),
24
- login: @pref.get("deluge_config")["login"],
25
- password: @pref.get("deluge_config")["password"]
26
- )
27
-
28
- @status = "not connected"
29
- @connected = false
30
- connect
31
-
32
- end
33
-
34
- def getStatus
35
- @status
36
- end
37
-
38
- def connect
39
- @connected = false
40
- @status = "error connecting"
41
- begin
42
- @client.connect
43
- rescue Deluge::Rpc::Connection::RPCError
44
- @client.close
45
- rescue RuntimeError
46
- @client.close
47
- else
48
- @status = "connected"
49
- @connected = true
50
- end
51
-
52
- @client.close unless @connected
53
- end
54
-
55
- def localAuth
56
- authfile = Dir.home + "/.config/deluge/auth"
57
- ["", ""] if not File.exist? authfile
58
- File.open(Dir.home + "/.config/deluge/auth") { |f| f.read }.split(":")
59
- end
60
-
61
- def getTorrents
62
- connect unless @connected
63
- return {} unless @connected
64
-
65
- tkeys = [
66
- "name",
67
- "progress",
68
- "eta",
69
- "paused",
70
- "state",
71
- "hash",
72
- #"active_time",
73
- #"is_finished",
74
- #"max_connections",
75
- #"max_download_speed",
76
- #"max_upload_slots",
77
- #"max_upload_speed",
78
- #"message",
79
- #"next_announce",
80
- #"num_peers",
81
- #"num_seeds",
82
- #"remove_at_ratio",
83
- #"save_path",
84
- #"seeding_time",
85
- #"seeds_peers_ratio",
86
- #"seed_rank",
87
- #"stop_at_ratio",
88
- #"stop_ratio",
89
- #"time_added",
90
- #"upload_payload_rate",
91
- #"comment",
92
- #"file_priorities",
93
- #"file_progress",
94
- #"files",
95
- #"is_seed",
96
- #"num_files",
97
- #"num_pieces",
98
- #"peers",
99
- #"piece_length",
100
- #"private",
101
- #"queue",
102
- #"ratio",
103
- #"total_size",
104
- #"tracker_host"
105
- ]
106
-
107
- return @client.core.get_torrents_status({}, tkeys)
108
- end
109
-
110
- def toggleTorrent torrentItem
111
- id = torrentItem.attributes["h"]
112
- if torrentItem.attributes["u"]
113
- @client.core.resume_torrent([id])
114
- else
115
- @client.core.pause_torrent([id])
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/format'
1
+ require_relative '../../util/util'
2
2
  require_relative '../item'
3
3
 
4
- class TorrentItem < Item
5
- def initialize(name:, progress:, eta:, paused:, state:, id:)
6
- @attr = {
7
- "n" => name,
8
- "p" => Format.format_progress(progress),
9
- "e" => Format.format_duration(eta),
10
- "u" => paused,
11
- "s" => state,
12
- "h" => id
13
- }
14
- end
15
-
16
- def attributes
17
- return @attr
18
- end
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