aniview 1.3.0 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- 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,18 +1,19 @@
|
|
1
1
|
require_relative '../item'
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
3
|
+
module Aniview
|
4
|
+
module Interface
|
5
|
+
class PrefItem < Item
|
6
|
+
def initialize(title, value, path_ = [])
|
7
|
+
@path = path_
|
8
|
+
@attr = {
|
9
|
+
"t" => title,
|
10
|
+
"v" => value,
|
11
|
+
}
|
12
|
+
end
|
11
13
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
end
|
14
|
+
def path
|
15
|
+
return @path
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -1,94 +1,100 @@
|
|
1
1
|
require 'fileutils'
|
2
2
|
|
3
3
|
require_relative 'scheduleitem'
|
4
|
-
require_relative '../../util/
|
4
|
+
require_relative '../../util/util'
|
5
5
|
|
6
|
-
|
6
|
+
module Aniview
|
7
|
+
module Interface
|
8
|
+
class Schedule
|
7
9
|
|
8
|
-
|
9
|
-
@pref = pref
|
10
|
-
load
|
11
|
-
end
|
12
|
-
|
13
|
-
def empty?
|
14
|
-
if @schedule == nil or @schedule.length == 0
|
15
|
-
@schedule = [ScheduleItem.new("no schedule", "")]
|
16
|
-
save
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
def getAll
|
21
|
-
empty?
|
22
|
-
return @schedule
|
23
|
-
end
|
24
|
-
|
25
|
-
def getAllCereal
|
26
|
-
r=""
|
27
|
-
getAll.each { |si| r+=si.cereal }
|
28
|
-
return r
|
29
|
-
end
|
10
|
+
include Aniview::Util
|
30
11
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
12
|
+
def initialize pref
|
13
|
+
@pref = pref
|
14
|
+
load
|
15
|
+
end
|
16
|
+
|
17
|
+
def empty?
|
18
|
+
if @schedule == nil or @schedule.length == 0
|
19
|
+
@schedule = [ScheduleItem.new("no schedule", "")]
|
20
|
+
save
|
39
21
|
end
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
22
|
+
end
|
23
|
+
|
24
|
+
def getAll
|
25
|
+
empty?
|
26
|
+
return @schedule
|
27
|
+
end
|
28
|
+
|
29
|
+
def getAllCereal
|
30
|
+
r=""
|
31
|
+
getAll.each { |si| r+=si.cereal }
|
32
|
+
return r
|
33
|
+
end
|
34
|
+
|
35
|
+
def mergeItems items
|
36
|
+
items.each { |item|
|
37
|
+
@schedule.each { |schedule_item|
|
38
|
+
if item.id == schedule_item.id
|
39
|
+
m = [schedule_item.attributes["m"], item.attributes["m"]]
|
40
|
+
if m[0] != m[1]
|
41
|
+
schedule_item.setmatched m[1]
|
42
|
+
end
|
43
|
+
end
|
44
|
+
}
|
45
|
+
}
|
46
|
+
save
|
47
|
+
end
|
48
|
+
|
49
|
+
def addItem item
|
50
|
+
@schedule.delete_at 0 if @schedule[0].attributes["t"] == "no schedule"
|
51
|
+
|
52
|
+
new_item = ScheduleItem.new(item, @pref.get("airing_dir"))
|
53
|
+
|
54
|
+
FileUtils.mkdir_p @pref.parseDir new_item.attributes["p"]
|
55
|
+
|
56
|
+
@schedule << new_item
|
57
|
+
|
58
|
+
save
|
59
|
+
end
|
60
|
+
|
61
|
+
def editItem loc, val
|
62
|
+
old_dir = @pref.parseDir @schedule[loc].attributes["p"]
|
63
|
+
@schedule[loc].setTitle val
|
64
|
+
new_dir = @pref.parseDir @schedule[loc].attributes["p"]
|
65
|
+
|
66
|
+
FileUtils.mv old_dir, new_dir unless old_dir == new_dir
|
67
|
+
|
68
|
+
save
|
69
|
+
end
|
70
|
+
|
71
|
+
def removeItem loc
|
72
|
+
@schedule.delete_at loc
|
73
|
+
save
|
74
|
+
end
|
75
|
+
|
76
|
+
def save
|
77
|
+
@pref.set "schedule", (Util.encode_object @schedule)
|
78
|
+
end
|
79
|
+
|
80
|
+
def load
|
81
|
+
@pref.load
|
82
|
+
raw = @pref.get "schedule"
|
83
|
+
if not raw == nil and raw.class == String
|
84
|
+
@schedule = Util.decode_object raw
|
85
|
+
else
|
86
|
+
empty?
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
def makeHash(arr)
|
91
|
+
ret = {}
|
92
|
+
arr.each{ |t|
|
93
|
+
ret.merge!(t => t)
|
94
|
+
}
|
95
|
+
return ret
|
96
|
+
end
|
47
97
|
|
48
|
-
new_item = ScheduleItem.new(item, @pref.get("airing_dir"))
|
49
|
-
|
50
|
-
FileUtils.mkdir_p @pref.parseDir new_item.attributes["p"]
|
51
|
-
|
52
|
-
@schedule << new_item
|
53
|
-
|
54
|
-
save
|
55
|
-
end
|
56
|
-
|
57
|
-
def editItem loc, val
|
58
|
-
old_dir = @pref.parseDir @schedule[loc].attributes["p"]
|
59
|
-
@schedule[loc].setTitle val
|
60
|
-
new_dir = @pref.parseDir @schedule[loc].attributes["p"]
|
61
|
-
|
62
|
-
FileUtils.mv old_dir, new_dir unless old_dir == new_dir
|
63
|
-
|
64
|
-
save
|
65
|
-
end
|
66
|
-
|
67
|
-
def removeItem loc
|
68
|
-
@schedule.delete_at loc
|
69
|
-
save
|
70
|
-
end
|
71
|
-
|
72
|
-
def save
|
73
|
-
@pref.set "schedule", (Serializer.e @schedule)
|
74
|
-
end
|
75
|
-
|
76
|
-
def load
|
77
|
-
@pref.load
|
78
|
-
raw = @pref.get "schedule"
|
79
|
-
if not raw == nil and raw.class == String
|
80
|
-
@schedule = Serializer.d raw
|
81
|
-
else
|
82
|
-
empty?
|
83
98
|
end
|
84
99
|
end
|
85
|
-
|
86
|
-
def makeHash(arr)
|
87
|
-
ret = {}
|
88
|
-
arr.each{ |t|
|
89
|
-
ret.merge!(t => t)
|
90
|
-
}
|
91
|
-
return ret
|
92
|
-
end
|
93
|
-
|
94
100
|
end
|
@@ -1,56 +1,59 @@
|
|
1
1
|
require_relative '../item'
|
2
2
|
require 'securerandom'
|
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
|
-
|
4
|
+
module Aniview
|
5
|
+
module Interface
|
6
|
+
class ScheduleItem < Item
|
7
|
+
def initialize(title, dir)
|
8
|
+
@dirpath = dir
|
9
|
+
@basepath = escapePath title
|
10
|
+
|
11
|
+
@attr = {
|
12
|
+
"t" => title,
|
13
|
+
"f" => title[0..4] + "…",
|
14
|
+
"r" => title,
|
15
|
+
"p" => @dirpath + @basepath,
|
16
|
+
"m" => "never"
|
17
|
+
}
|
18
|
+
|
19
|
+
@lastseen = 0
|
20
|
+
@id = SecureRandom.uuid
|
21
|
+
end
|
22
|
+
|
23
|
+
def updataDir nd
|
24
|
+
@dirpath = nd
|
25
|
+
@attr["p"] = nd + @basepath
|
26
|
+
end
|
27
|
+
|
28
|
+
def escapePath path
|
29
|
+
path_ = path.gsub(":", "_")
|
30
|
+
path_.gsub("/", ":")
|
31
|
+
end
|
32
|
+
|
33
|
+
def setTitle newtitle
|
34
|
+
@attr["t"] = newtitle
|
35
|
+
@attr["f"] = newtitle[0..4] + "…"
|
36
|
+
@attr["p"] = @dirpath + escapePath(newtitle)
|
37
|
+
end
|
38
|
+
|
39
|
+
def setRegexp regexp
|
40
|
+
@attr["r"] = regexp
|
41
|
+
end
|
42
|
+
|
43
|
+
def setSeen
|
44
|
+
@lastseen = Time.now.to_s
|
45
|
+
@attr["m"] = @lastseen
|
46
|
+
end
|
47
|
+
|
48
|
+
def setmatched date
|
49
|
+
@attr["m"] = date
|
50
|
+
end
|
51
|
+
|
52
|
+
def id
|
53
|
+
id = SecureRandom.uuid if @id == nil
|
54
|
+
@id
|
55
|
+
end
|
56
|
+
|
57
|
+
end
|
54
58
|
end
|
55
|
-
|
56
59
|
end
|
@@ -1,118 +1,121 @@
|
|
1
1
|
require 'simple-rss'
|
2
2
|
require 'open-uri'
|
3
3
|
|
4
|
-
require_relative "../../util/stringhelp"
|
5
4
|
require_relative "../schedule/scheduleitem"
|
6
5
|
|
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
|
-
|
6
|
+
module Aniview
|
7
|
+
module Interface
|
8
|
+
class Subscription
|
9
|
+
def initialize pref, schedule, delugec, client
|
10
|
+
@c = client
|
11
|
+
@pref = pref
|
12
|
+
@schedule = schedule
|
13
|
+
@delugec = delugec
|
14
|
+
end
|
15
|
+
|
16
|
+
def log s
|
17
|
+
puts "#{Time.now.to_s} [subscription] " + s
|
18
|
+
end
|
19
|
+
|
20
|
+
def checkDaemon
|
21
|
+
if @c.server?
|
22
|
+
"daemon up"
|
23
|
+
else
|
24
|
+
"daemon down"
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def getLastChecked
|
29
|
+
@c.lastchecked
|
30
|
+
end
|
31
|
+
|
32
|
+
def syncMatches
|
33
|
+
@schedule.mergeItems @c.getItems
|
34
|
+
end
|
35
|
+
|
36
|
+
def updateFeed
|
37
|
+
begin
|
38
|
+
@rss = SimpleRSS.parse open(@pref.get("rss_feed")["url"])
|
39
|
+
|
40
|
+
rescue SocketError
|
41
|
+
@rss = nil
|
42
|
+
|
43
|
+
#rescue
|
44
|
+
# @rss = nil
|
45
|
+
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
def feed
|
50
|
+
@rss
|
51
|
+
end
|
52
|
+
|
53
|
+
def match regexp, verbose=false
|
54
|
+
re = Regexp.new regexp
|
55
|
+
matches = []
|
56
|
+
@rss.items.each{ |item|
|
57
|
+
#log "-> checking against #{item[:title]}" if verbose
|
58
|
+
re.match item[:title] { matches << item }
|
59
|
+
}
|
60
|
+
return matches
|
61
|
+
end
|
62
|
+
|
63
|
+
def matchAll (verbose: false)
|
64
|
+
updateFeed if @rss == nil
|
65
|
+
return [] if @rss == nil
|
66
|
+
|
67
|
+
log "matching all" if verbose
|
68
|
+
|
69
|
+
total_matches = 0
|
70
|
+
getAll.each { |subs|
|
71
|
+
log "matching #{subs.attributes["r"]}" if verbose
|
72
|
+
matches = match subs.attributes["r"], verbose
|
73
|
+
log "found #{matches.length} matches" if verbose
|
74
|
+
log "#{matches}" if verbose
|
75
|
+
|
76
|
+
if matches.length >= 1
|
77
|
+
|
78
|
+
downloaddir = @pref.parseDir(subs.attributes["p"]) + "/"
|
79
|
+
newfile = downloaddir + matches[0][:title]
|
80
|
+
|
81
|
+
next if File.exist? newfile
|
82
|
+
log "set download dir to #{newfile}" if verbose
|
83
|
+
s = @delugec.addTorrent matches[0][:link], @pref.parseDir(subs.attributes["p"]), verbose: true
|
84
|
+
log "adding torrent, status #{s}" if verbose
|
85
|
+
subs.setSeen if s
|
86
|
+
@schedule.save
|
87
|
+
total_matches+=1
|
88
|
+
end
|
89
|
+
}
|
90
|
+
log "match complete, #{total_matches} found" if verbose
|
91
|
+
return total_matches
|
92
|
+
end
|
93
|
+
|
94
|
+
def forceMatch
|
95
|
+
@mthread = Thread.new do
|
96
|
+
updateFeed
|
97
|
+
matchAll
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
def getAll
|
102
|
+
@schedule.getAll
|
103
|
+
end
|
104
|
+
|
105
|
+
def editItem loc, newval
|
106
|
+
@schedule.getAll[loc].setRegexp newval
|
86
107
|
@schedule.save
|
87
|
-
total_matches+=1
|
88
108
|
end
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
109
|
+
|
110
|
+
def makeHash(arr)
|
111
|
+
ret = {}
|
112
|
+
arr.each{ |subs|
|
113
|
+
ret.merge!(subs => subs)
|
114
|
+
}
|
115
|
+
return ret
|
116
|
+
end
|
117
|
+
|
98
118
|
end
|
99
119
|
end
|
100
|
-
|
101
|
-
def getAll
|
102
|
-
@schedule.getAll
|
103
|
-
end
|
104
|
-
|
105
|
-
def editItem loc, newval
|
106
|
-
@schedule.getAll[loc].setRegexp newval
|
107
|
-
@schedule.save
|
108
|
-
end
|
109
|
-
|
110
|
-
def makeHash(arr)
|
111
|
-
ret = {}
|
112
|
-
arr.each{ |subs|
|
113
|
-
ret.merge!(subs => subs)
|
114
|
-
}
|
115
|
-
return ret
|
116
|
-
end
|
117
|
-
|
118
120
|
end
|
121
|
+
|