miyuki 0.2 → 0.3
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/.gitignore +2 -0
- data/Gemfile +2 -0
- data/Gemfile.lock +2 -0
- data/README.md +15 -1
- data/Rakefile +1 -1
- data/example/miyuki.conf +4 -3
- data/lib/miyuki/miyuki.rb +57 -38
- data/lib/miyuki/notifier.rb +34 -0
- data/lib/miyuki/notifiers/libnotify.rb +22 -0
- data/lib/miyuki/notifiers/terminal-notifier.rb +22 -0
- data/lib/miyuki/tracker.rb +24 -5
- data/lib/miyuki/version.rb +1 -1
- data/lib/miyuki.rb +6 -0
- data/miyuki.gemspec +20 -15
- metadata +20 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bfa81dd6b05e2361be6fdd3062edf78a85308fef
|
4
|
+
data.tar.gz: 9c151825a73470dc07d53229209215d1a5997b48
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 566a45cae0d029cbe3bafb3d3db98fa816a50e6f3b42916d32a0f0b821c4358ecc3fdf39b79643f5f88fa546d7fdd8bd2d25d9d9d06299feb596e85085d9b6d2
|
7
|
+
data.tar.gz: d1da7e3a0a15709edaf5b1658eccb0b206da5c1adee17baff7af8c933183f2cbea9c1de632fdaf47a4cbcd7db4e48640e9706ee162d71c765e94741d1faaf802
|
data/.gitignore
ADDED
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -8,6 +8,7 @@ GEM
|
|
8
8
|
thor (>= 0.15.0)
|
9
9
|
rufus-scheduler (3.0.9)
|
10
10
|
tzinfo
|
11
|
+
terminal-notifier (1.6.2)
|
11
12
|
thor (0.19.1)
|
12
13
|
thread_safe (0.3.4)
|
13
14
|
tzinfo (1.2.2)
|
@@ -21,4 +22,5 @@ PLATFORMS
|
|
21
22
|
DEPENDENCIES
|
22
23
|
foreverb
|
23
24
|
rufus-scheduler
|
25
|
+
terminal-notifier
|
24
26
|
yamazaki (>= 0.3)
|
data/README.md
CHANGED
@@ -1,10 +1,15 @@
|
|
1
1
|
Miyuki – Non ti lascia mai solo
|
2
2
|
===============================
|
3
|
-
|
4
3
|
After having configured the `example/miyuki.conf` configuration file, Miyuki lets you to have always the latest episodes of anime you're watching, downloading the episodes whenever they're available on Nyaa.
|
5
4
|
|
6
5
|
Of course, set the watch directory inside the configuration file to the one you've set in your torrent client.
|
7
6
|
|
7
|
+
Features
|
8
|
+
--------
|
9
|
+
- After having launched the daemon, the changes to the configuration file will be always syncronized without having restart Miyuki
|
10
|
+
- Whenever Miyuki finds out a new episode to download, you'll be notified with an alert (compatible with OSX natively and with Linux installing `libnotify`)
|
11
|
+
- Miyuki gives you a powerful way to search anime series through patterns
|
12
|
+
|
8
13
|
How to use
|
9
14
|
----------
|
10
15
|
`$ gem install miyuki`
|
@@ -12,3 +17,12 @@ How to use
|
|
12
17
|
`$ miyuki start example/miyuki.conf`
|
13
18
|
|
14
19
|
`$ miyuki stop` (or `$ miyuki kill`)
|
20
|
+
|
21
|
+
Known bugs
|
22
|
+
----------
|
23
|
+
- Nisekoi BDs in `example/miyuki.conf` are downloaded both in 720p and 1080p
|
24
|
+
|
25
|
+
Contributors
|
26
|
+
------------
|
27
|
+
- [alfateam123](https://github.com/alfateam123) — notifications
|
28
|
+
|
data/Rakefile
CHANGED
data/example/miyuki.conf
CHANGED
data/lib/miyuki/miyuki.rb
CHANGED
@@ -13,54 +13,73 @@
|
|
13
13
|
##
|
14
14
|
|
15
15
|
module Miyuki
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
@config = load_config
|
16
|
+
class << self
|
17
|
+
def config=(config_file)
|
18
|
+
@notifier = Notifier.new
|
20
19
|
|
21
|
-
|
22
|
-
|
20
|
+
@config_file = config_file
|
21
|
+
@config = load_config
|
23
22
|
|
24
|
-
|
25
|
-
|
26
|
-
|
23
|
+
# TODO: Implement file watcher
|
24
|
+
Rufus::Scheduler.singleton.every('1m') { refresh_config }
|
25
|
+
end
|
27
26
|
|
28
|
-
|
27
|
+
def track!
|
28
|
+
watch_dir = File.expand_path(@config['watchDir'])
|
29
|
+
FileUtils.mkdir_p(watch_dir) unless File.directory?(watch_dir)
|
29
30
|
|
30
|
-
|
31
|
-
|
31
|
+
# TODO: #deep_dup instead of using Marshal
|
32
|
+
@tracker = Tracker.new(watch_dir, Marshal.load(Marshal.dump(@config))['series']) do |torrent|
|
33
|
+
notify_torrents(torrent)
|
34
|
+
end
|
32
35
|
|
33
|
-
|
36
|
+
run_scheduler
|
37
|
+
end
|
34
38
|
|
35
|
-
|
36
|
-
new_config = load_config
|
39
|
+
private
|
37
40
|
|
38
|
-
|
39
|
-
|
40
|
-
@scheduler.pause if defined?(@scheduler)
|
41
|
-
track!
|
42
|
-
end
|
43
|
-
end
|
41
|
+
def refresh_config
|
42
|
+
new_config = load_config
|
44
43
|
|
45
|
-
|
46
|
-
|
47
|
-
end
|
44
|
+
if @config != new_config
|
45
|
+
notify_configuration
|
48
46
|
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
47
|
+
@config = new_config
|
48
|
+
@scheduler.pause if defined?(@scheduler)
|
49
|
+
track!
|
50
|
+
end
|
51
|
+
end
|
53
52
|
|
54
|
-
|
53
|
+
def refresh_torrents
|
54
|
+
old_torrents = @tracker.torrents
|
55
55
|
|
56
|
-
|
57
|
-
if new_torrents.any?
|
58
|
-
puts 'New torrents:'
|
59
|
-
new_torrents.each { |torrent| puts torrent.to_s }
|
60
|
-
end
|
61
|
-
end
|
56
|
+
@tracker.refresh
|
62
57
|
|
63
|
-
|
64
|
-
|
65
|
-
|
58
|
+
new_torrents = @tracker.remove_duplicates(old_torrents)
|
59
|
+
new_torrents.each { |torrent| notify_torrents(new_torrents) }
|
60
|
+
end
|
61
|
+
|
62
|
+
def load_config
|
63
|
+
YAML.load(File.read(@config_file))
|
64
|
+
end
|
65
|
+
|
66
|
+
def run_scheduler
|
67
|
+
@scheduler = Rufus::Scheduler.new
|
68
|
+
@scheduler.every @config['refreshEvery'] { refresh_torrents }
|
69
|
+
@scheduler.join
|
70
|
+
end
|
71
|
+
|
72
|
+
def notify_torrents(torrent)
|
73
|
+
if @config['notifications']['enabled']
|
74
|
+
@notifier.notify(torrent.title, 'New episode released')
|
75
|
+
sleep 1.1
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
def notify_configuration
|
80
|
+
if @config['notifications']['enabled']
|
81
|
+
@notifier.notify('New configuration loaded in Miyuki', 'Changes detected in configuration file')
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
66
85
|
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
##
|
2
|
+
# DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
|
3
|
+
# Version 2, December 2004
|
4
|
+
#
|
5
|
+
# Everyone is permitted to copy and distribute verbatim or modified
|
6
|
+
# copies of this license document, and changing it is allowed as long
|
7
|
+
# as the name is changed.
|
8
|
+
#
|
9
|
+
# DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
|
10
|
+
# TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
11
|
+
#
|
12
|
+
# 0. You just DO WHAT THE FUCK YOU WANT TO.
|
13
|
+
##
|
14
|
+
|
15
|
+
module Miyuki
|
16
|
+
class Notifier
|
17
|
+
def initialize(notifier = nil)
|
18
|
+
@notifier = notifier || get_notifier
|
19
|
+
end
|
20
|
+
|
21
|
+
def notify(title, message)
|
22
|
+
@notifier.notify(title, message)
|
23
|
+
end
|
24
|
+
|
25
|
+
private
|
26
|
+
|
27
|
+
def get_notifier
|
28
|
+
case RUBY_PLATFORM
|
29
|
+
when /darwin/ then Miyuki::TerminalNotifier.new
|
30
|
+
when /linux/ then Miyuki::Libnotify.new
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
##
|
2
|
+
# DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
|
3
|
+
# Version 2, December 2004
|
4
|
+
#
|
5
|
+
# Everyone is permitted to copy and distribute verbatim or modified
|
6
|
+
# copies of this license document, and changing it is allowed as long
|
7
|
+
# as the name is changed.
|
8
|
+
#
|
9
|
+
# DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
|
10
|
+
# TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
11
|
+
#
|
12
|
+
# 0. You just DO WHAT THE FUCK YOU WANT TO.
|
13
|
+
##
|
14
|
+
require 'libnotify'
|
15
|
+
|
16
|
+
module Miyuki
|
17
|
+
class Libnotify
|
18
|
+
def notify(title, message)
|
19
|
+
::Libnotify.show(body: message, summary: title)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
##
|
2
|
+
# DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
|
3
|
+
# Version 2, December 2004
|
4
|
+
#
|
5
|
+
# Everyone is permitted to copy and distribute verbatim or modified
|
6
|
+
# copies of this license document, and changing it is allowed as long
|
7
|
+
# as the name is changed.
|
8
|
+
#
|
9
|
+
# DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
|
10
|
+
# TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
11
|
+
#
|
12
|
+
# 0. You just DO WHAT THE FUCK YOU WANT TO.
|
13
|
+
##
|
14
|
+
require 'terminal-notifier'
|
15
|
+
|
16
|
+
module Miyuki
|
17
|
+
class TerminalNotifier
|
18
|
+
def notify(title, message)
|
19
|
+
::TerminalNotifier.notify(message, title: title, sound: 'default')
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
data/lib/miyuki/tracker.rb
CHANGED
@@ -18,10 +18,12 @@ module Miyuki
|
|
18
18
|
|
19
19
|
attr_reader :torrents
|
20
20
|
|
21
|
-
def initialize(watch_dir, series)
|
21
|
+
def initialize(watch_dir, series, &callback)
|
22
|
+
# TODO: This will raise a warning when the class is initializated twice
|
22
23
|
Yamazaki.const_set(:WATCH_DIR, watch_dir)
|
23
24
|
|
24
|
-
@series
|
25
|
+
@series = series || []
|
26
|
+
@callback = callback if block_given?
|
25
27
|
|
26
28
|
refresh
|
27
29
|
end
|
@@ -30,17 +32,34 @@ module Miyuki
|
|
30
32
|
@torrents = []
|
31
33
|
|
32
34
|
fetch_torrents
|
33
|
-
|
35
|
+
|
36
|
+
@torrents.each do |torrent|
|
37
|
+
existed = File.exists?("#{Yamazaki::WATCH_DIR}/#{torrent.title}.torrent")
|
38
|
+
Yamazaki.download_torrent(torrent.title, torrent.link)
|
39
|
+
downloaded = !existed && File.exists?("#{Yamazaki::WATCH_DIR}/#{torrent.title}.torrent")
|
40
|
+
|
41
|
+
# TODO: `downloaded` should be returned by Yamazaki natively
|
42
|
+
@callback.call(torrent) if downloaded && @callback
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
# TODO: Refactor
|
47
|
+
def remove_duplicates(other_torrents)
|
48
|
+
@torrents.delete_if do |torrent|
|
49
|
+
other_torrents.each do |other_torrent|
|
50
|
+
return true if torrent.link == other_torrent.link
|
51
|
+
end
|
52
|
+
end
|
34
53
|
end
|
35
54
|
|
36
55
|
private
|
37
56
|
|
38
57
|
def fetch_torrents
|
39
58
|
@series.each do |series|
|
40
|
-
pattern
|
59
|
+
pattern = pattern_of(series)
|
41
60
|
torrents = search(pattern)
|
42
61
|
|
43
|
-
@torrents.concat(torrents)
|
62
|
+
@torrents.concat(torrents.reverse)
|
44
63
|
end
|
45
64
|
end
|
46
65
|
|
data/lib/miyuki/version.rb
CHANGED
data/lib/miyuki.rb
CHANGED
@@ -17,6 +17,12 @@ require 'yaml'
|
|
17
17
|
require 'rufus-scheduler'
|
18
18
|
require 'yamazaki'
|
19
19
|
|
20
|
+
require 'miyuki/notifier'
|
20
21
|
require 'miyuki/tracker'
|
21
22
|
require 'miyuki/miyuki'
|
22
23
|
require 'miyuki/version'
|
24
|
+
|
25
|
+
case RUBY_PLATFORM
|
26
|
+
when /darwin/ then require 'miyuki/notifiers/terminal-notifier.rb'
|
27
|
+
when /linux/ then require 'miyuki/notifiers/libnotify.rb'
|
28
|
+
end
|
data/miyuki.gemspec
CHANGED
@@ -1,20 +1,25 @@
|
|
1
1
|
Kernel.load 'lib/miyuki/version.rb'
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
4
|
+
s.name = 'miyuki'
|
5
|
+
s.version = Miyuki::VERSION
|
6
|
+
s.author = 'Roxas Shadow'
|
7
|
+
s.email = 'webmaster@giovannicapuano.net'
|
8
|
+
s.homepage = 'https://github.com/RoxasShadow/Miyuki'
|
9
|
+
s.platform = Gem::Platform::RUBY
|
10
|
+
s.summary = 'Miyuki allows you to not miss any episode of anime you\'re watching'
|
11
|
+
s.description = 'Miyuki downloads automatically every episode of anime you\'re watching'
|
12
|
+
s.files = `git ls-files -z`.split("\0")
|
13
|
+
s.require_path = 'lib'
|
14
|
+
s.executables = 'miyuki'
|
15
|
+
s.license = 'WTFPL'
|
16
16
|
|
17
|
-
|
18
|
-
|
19
|
-
|
17
|
+
s.add_dependency 'yamazaki', '~> 0.3'
|
18
|
+
s.add_dependency 'rufus-scheduler', '~> 3.0'
|
19
|
+
s.add_dependency 'foreverb', '~> 0.3'
|
20
|
+
|
21
|
+
case RUBY_PLATFORM
|
22
|
+
when /darwin/ then s.add_dependency 'terminal-notifier', '~> 1.6'
|
23
|
+
when /linux/ then s.add_dependency 'libnotify', '~> 0.8'
|
24
|
+
end
|
20
25
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: miyuki
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: '0.
|
4
|
+
version: '0.3'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Roxas Shadow
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-12-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: yamazaki
|
@@ -52,6 +52,20 @@ dependencies:
|
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0.3'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: terminal-notifier
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '1.6'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '1.6'
|
55
69
|
description: Miyuki downloads automatically every episode of anime you're watching
|
56
70
|
email: webmaster@giovannicapuano.net
|
57
71
|
executables:
|
@@ -59,6 +73,7 @@ executables:
|
|
59
73
|
extensions: []
|
60
74
|
extra_rdoc_files: []
|
61
75
|
files:
|
76
|
+
- ".gitignore"
|
62
77
|
- Gemfile
|
63
78
|
- Gemfile.lock
|
64
79
|
- README.md
|
@@ -67,6 +82,9 @@ files:
|
|
67
82
|
- example/miyuki.conf
|
68
83
|
- lib/miyuki.rb
|
69
84
|
- lib/miyuki/miyuki.rb
|
85
|
+
- lib/miyuki/notifier.rb
|
86
|
+
- lib/miyuki/notifiers/libnotify.rb
|
87
|
+
- lib/miyuki/notifiers/terminal-notifier.rb
|
70
88
|
- lib/miyuki/tracker.rb
|
71
89
|
- lib/miyuki/version.rb
|
72
90
|
- miyuki.gemspec
|