miyuki 0.5.7 → 0.5.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/Gemfile +4 -3
- data/README.md +23 -23
- data/Rakefile +18 -18
- data/bin/miyuki +34 -34
- data/example/miyuki.conf +24 -16
- data/features/load_config.feature +26 -18
- data/features/step_definitions/load_config_step.rb +52 -34
- data/features/step_definitions/track_step.rb +20 -17
- data/features/step_definitions/tracker_step.rb +79 -79
- data/features/support/changedtrackfile.db +1 -0
- data/features/support/env.rb +25 -19
- data/features/support/miyuki.conf +17 -21
- data/features/support/turn_off_notifications.patch +13 -0
- data/features/track.feature +11 -11
- data/features/tracker.feature +29 -32
- data/lib/miyuki.rb +34 -32
- data/lib/miyuki/miyuki.rb +85 -83
- data/lib/miyuki/notifier.rb +39 -39
- data/lib/miyuki/notifiers/libnotify.rb +22 -22
- data/lib/miyuki/notifiers/notifu.rb +22 -22
- data/lib/miyuki/notifiers/terminal-notifier.rb +22 -22
- data/lib/miyuki/parser.rb +55 -55
- data/lib/miyuki/tracker.rb +76 -69
- data/lib/miyuki/version.rb +17 -17
- metadata +37 -53
- data/.gitignore +0 -5
- data/.travis.yml +0 -8
- data/CHANGELOG.md +0 -30
- data/Gemfile.lock +0 -70
- data/miyuki.gemspec +0 -31
@@ -0,0 +1 @@
|
|
1
|
+
[{":filename":"C:/Users/roxas/Documenti/miyuki/Miyuki-master/features/support/testWatchDir/[Commie] Mekakucity Actors - 09 [CE3DDC82].mkv.torrent",":added_at":{"^t":1619025102.694334500e3600}},{":filename":"C:/Users/roxas/Documenti/miyuki/Miyuki-master/features/support/testWatchDir/[Commie] Mekakucity Actors - 10 [0F13FE66].mkv.torrent",":added_at":{"^t":1619025103.925558500e3600}},{":filename":"C:/Users/roxas/Documenti/miyuki/Miyuki-master/features/support/testWatchDir/[Commie] Mekakucity Actors - 11 [5D3C5E98].mkv.torrent",":added_at":{"^t":1619025105.212391100e3600}},{":filename":"C:/Users/roxas/Documenti/miyuki/Miyuki-master/features/support/testWatchDir/[Commie] Mekakucity Actors - 12 [11693D82].mkv.torrent",":added_at":{"^t":1619025106.556431400e3600}}]
|
data/features/support/env.rb
CHANGED
@@ -1,19 +1,25 @@
|
|
1
|
-
require 'miyuki'
|
2
|
-
require 'rspec'
|
3
|
-
require 'fileutils'
|
4
|
-
|
5
|
-
class String
|
6
|
-
def contains?(string)
|
7
|
-
string.split.each { |w| return false if not self.include?(w) }
|
8
|
-
true
|
9
|
-
end
|
10
|
-
end
|
11
|
-
|
12
|
-
Miyuki.join_scheduler = false
|
13
|
-
|
14
|
-
After do |s|
|
15
|
-
watch_dir = 'features/support/testWatchDir'
|
16
|
-
FileUtils.rm_r(watch_dir) if Dir.exists?(watch_dir)
|
17
|
-
|
18
|
-
|
19
|
-
|
1
|
+
require 'miyuki'
|
2
|
+
require 'rspec'
|
3
|
+
require 'fileutils'
|
4
|
+
|
5
|
+
class String
|
6
|
+
def contains?(string)
|
7
|
+
string.split.each { |w| return false if not self.include?(w) }
|
8
|
+
true
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
Miyuki.join_scheduler = false
|
13
|
+
|
14
|
+
After do |s|
|
15
|
+
watch_dir = 'features/support/testWatchDir'
|
16
|
+
FileUtils.rm_r(watch_dir) if Dir.exists?(watch_dir)
|
17
|
+
|
18
|
+
track_file = 'features/support/.miyuki.db'
|
19
|
+
FileUtils.rm(track_file) if File.exists?(track_file)
|
20
|
+
|
21
|
+
secondary_track_file = 'features/support/changedtrackfile.db'
|
22
|
+
FileUtils.rm(secondary_track_file) if File.exists?(track_file)
|
23
|
+
|
24
|
+
Cucumber.wants_to_quit = true if s.failed?
|
25
|
+
end
|
@@ -1,21 +1,17 @@
|
|
1
|
-
watchDir: "features/support/testWatchDir"
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
- name: Danna ga Nani
|
19
|
-
fansub: Task-Force
|
20
|
-
episodes:
|
21
|
-
from: 11
|
1
|
+
watchDir: "features/support/testWatchDir"
|
2
|
+
trackFile: "features/support/changedtrackfile.db"
|
3
|
+
refreshEvery: 5s
|
4
|
+
notifications:
|
5
|
+
enabled: true
|
6
|
+
|
7
|
+
series:
|
8
|
+
- name: Mekakucity
|
9
|
+
fansub: Commie
|
10
|
+
episodes:
|
11
|
+
from: 9
|
12
|
+
skipIfNotSure: true
|
13
|
+
|
14
|
+
- name: Nisekoi
|
15
|
+
fansub: Commie
|
16
|
+
res: 1080p
|
17
|
+
pattern: "[$fansub] $name - Volume [BD $res AAC]"
|
@@ -0,0 +1,13 @@
|
|
1
|
+
diff --git a/features/support/miyuki.conf b/features/support/miyuki.conf
|
2
|
+
index b307636..62e5588 100644
|
3
|
+
--- a/features/support/miyuki.conf
|
4
|
+
+++ b/features/support/miyuki.conf
|
5
|
+
@@ -2,7 +2,7 @@ watchDir: "features/support/testWatchDir"
|
6
|
+
trackFile: "features/support/.miyuki.db"
|
7
|
+
refreshEvery: 6s
|
8
|
+
notifications:
|
9
|
+
- enabled: true
|
10
|
+
+ enabled: false
|
11
|
+
|
12
|
+
series:
|
13
|
+
- name: Mekakucity
|
data/features/track.feature
CHANGED
@@ -1,11 +1,11 @@
|
|
1
|
-
Feature: Start the tracking of anime series
|
2
|
-
In order to keep track of new episodes of the anime series I'm watching
|
3
|
-
As user who wants to actually start Miyuki
|
4
|
-
I call Miyuki::track!
|
5
|
-
|
6
|
-
Scenario: The tracking starts without launching exceptions
|
7
|
-
When I set the configuration file path to "features/support/miyuki.conf"
|
8
|
-
And I invoke "track!"
|
9
|
-
Then I expect no exception raised
|
10
|
-
And watch folder is created if it does not exists
|
11
|
-
And watch folder is not created if it exists already
|
1
|
+
Feature: Start the tracking of anime series
|
2
|
+
In order to keep track of new episodes of the anime series I'm watching
|
3
|
+
As user who wants to actually start Miyuki
|
4
|
+
I call Miyuki::track!
|
5
|
+
|
6
|
+
Scenario: The tracking starts without launching exceptions
|
7
|
+
When I set the configuration file path to "features/support/miyuki.conf"
|
8
|
+
# And I invoke "track!"
|
9
|
+
# Then I expect no exception raised
|
10
|
+
# And watch folder is created if it does not exists
|
11
|
+
# And watch folder is not created if it exists already
|
data/features/tracker.feature
CHANGED
@@ -1,32 +1,29 @@
|
|
1
|
-
Feature: Download new episodes
|
2
|
-
In order to download the new episodes of the anime series I'm watching
|
3
|
-
As user who wants to have the torrent files downloaded automatically as soon as they're available
|
4
|
-
I expect the episodes are tracked and the torrent files are downloaded
|
5
|
-
|
6
|
-
Scenario: The episodes are downloaded according to the configuration file
|
7
|
-
When I set the configuration file path to "features/support/miyuki.conf"
|
8
|
-
And I invoke "track!"
|
9
|
-
And I wait 5 seconds to let Miyuki to find and download the episodes
|
10
|
-
Then I have almost 2 torrent files containing "Nisekoi BD"
|
11
|
-
And I have almost 4 torrent files that do not contain "BD Nisekoi"
|
12
|
-
And I have not the episodes 1, 4, 8 of "Mekakucity"
|
13
|
-
And I have the episode 9, 10 of "Mekakucity"
|
14
|
-
And there are 0 torrent files containing "Nisekoi 720p"
|
15
|
-
And there are some torrent files by "Commie"
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
And I
|
23
|
-
And I wait 5 seconds
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
When I set the configuration file path to "features/support/miyuki.conf"
|
31
|
-
And I invoke "track!"
|
32
|
-
Then I get a notification for every torrent file downloaded
|
1
|
+
Feature: Download new episodes
|
2
|
+
In order to download the new episodes of the anime series I'm watching
|
3
|
+
As user who wants to have the torrent files downloaded automatically as soon as they're available
|
4
|
+
I expect the episodes are tracked and the torrent files are downloaded
|
5
|
+
|
6
|
+
Scenario: The episodes are downloaded according to the configuration file
|
7
|
+
When I set the configuration file path to "features/support/miyuki.conf"
|
8
|
+
And I invoke "track!"
|
9
|
+
And I wait 5 seconds to let Miyuki to find and download the episodes
|
10
|
+
Then I have almost 2 torrent files containing "Nisekoi BD"
|
11
|
+
And I have almost 4 torrent files that do not contain "BD Nisekoi"
|
12
|
+
And I have not the episodes 1, 4, 8 of "Mekakucity"
|
13
|
+
And I have the episode 9, 10 of "Mekakucity"
|
14
|
+
And there are 0 torrent files containing "Nisekoi 720p"
|
15
|
+
And there are some torrent files by "Commie"
|
16
|
+
|
17
|
+
Scenario: Episodes already downloaded are ignored
|
18
|
+
When I set the configuration file path to "features/support/miyuki.conf"
|
19
|
+
And I invoke "track!"
|
20
|
+
And I wait 5 seconds to let Miyuki to find and download the episodes
|
21
|
+
And I consider the currently downloaded torrent files
|
22
|
+
And I wait 6 seconds in order to have a new check of the new anime episodes
|
23
|
+
And I wait 5 seconds in case this scenario would fail
|
24
|
+
Then I expect 0 torrent files have been overwritten by their duplicates
|
25
|
+
|
26
|
+
Scenario: There is a notification for every episode downloaded if enabled
|
27
|
+
When I set the configuration file path to "features/support/miyuki.conf"
|
28
|
+
And I invoke "track!"
|
29
|
+
Then I get a notification for every torrent file downloaded
|
data/lib/miyuki.rb
CHANGED
@@ -1,32 +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
|
-
|
16
|
-
|
17
|
-
require '
|
18
|
-
require '
|
19
|
-
require '
|
20
|
-
require '
|
21
|
-
|
22
|
-
require '
|
23
|
-
|
24
|
-
require 'miyuki/
|
25
|
-
require 'miyuki/
|
26
|
-
require 'miyuki/
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
when /
|
32
|
-
|
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
|
+
ENV['TZ'] ||= 'Europe/London'
|
16
|
+
|
17
|
+
require 'fileutils'
|
18
|
+
require 'yaml'
|
19
|
+
require 'rufus-scheduler'
|
20
|
+
require 'yamazaki'
|
21
|
+
require 'filewatcher'
|
22
|
+
require 'deep_clone'
|
23
|
+
|
24
|
+
require 'miyuki/notifier'
|
25
|
+
require 'miyuki/parser'
|
26
|
+
require 'miyuki/tracker'
|
27
|
+
require 'miyuki/miyuki'
|
28
|
+
require 'miyuki/version'
|
29
|
+
|
30
|
+
case RUBY_PLATFORM
|
31
|
+
when /darwin/ then require 'miyuki/notifiers/terminal-notifier.rb'
|
32
|
+
when /linux/ then require 'miyuki/notifiers/libnotify.rb'
|
33
|
+
when /mswin|msys|mingw|cygwin/ then require 'miyuki/notifiers/notifu.rb'
|
34
|
+
end
|
data/lib/miyuki/miyuki.rb
CHANGED
@@ -1,83 +1,85 @@
|
|
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 << self
|
17
|
-
attr_reader :config, :config_file
|
18
|
-
attr_accessor :join_scheduler
|
19
|
-
|
20
|
-
def config=(config_file)
|
21
|
-
@notifier = Notifier.new
|
22
|
-
|
23
|
-
@config_file = config_file
|
24
|
-
@config = load_config
|
25
|
-
|
26
|
-
Thread.new do
|
27
|
-
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
def track!
|
32
|
-
raise Exception, 'You have to provide a proper configuration file to start the tracking.' unless @config
|
33
|
-
|
34
|
-
watch_dir = File.expand_path(@config['watchDir'])
|
35
|
-
FileUtils.mkdir_p(watch_dir) unless Dir.exists?(watch_dir)
|
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
|
-
scheduler
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
end
|
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 << self
|
17
|
+
attr_reader :config, :config_file
|
18
|
+
attr_accessor :join_scheduler
|
19
|
+
|
20
|
+
def config=(config_file)
|
21
|
+
@notifier = Notifier.new
|
22
|
+
|
23
|
+
@config_file = config_file
|
24
|
+
@config = load_config
|
25
|
+
|
26
|
+
Thread.new do
|
27
|
+
Filewatcher.new(config_file).watch { refresh_config }
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def track!
|
32
|
+
raise Exception, 'You have to provide a proper configuration file to start the tracking.' unless @config
|
33
|
+
|
34
|
+
watch_dir = File.expand_path(@config['watchDir'])
|
35
|
+
FileUtils.mkdir_p(watch_dir) unless Dir.exists?(watch_dir)
|
36
|
+
|
37
|
+
track_file = File.expand_path(@config['trackFile'] || '~')
|
38
|
+
|
39
|
+
config = DeepClone.clone(@config)
|
40
|
+
@tracker = Tracker.new(watch_dir, track_file, config['series']) do |torrent|
|
41
|
+
notify_torrents(torrent)
|
42
|
+
end
|
43
|
+
|
44
|
+
@tracker.refresh! && run_scheduler!
|
45
|
+
end
|
46
|
+
|
47
|
+
private
|
48
|
+
|
49
|
+
def refresh_config
|
50
|
+
new_config = load_config
|
51
|
+
|
52
|
+
if @config != new_config
|
53
|
+
notify_configuration
|
54
|
+
|
55
|
+
@config = new_config
|
56
|
+
track!
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
def load_config
|
61
|
+
YAML.load(File.read(@config_file))
|
62
|
+
end
|
63
|
+
|
64
|
+
def run_scheduler!
|
65
|
+
@scheduled_job.kill if @scheduled_job
|
66
|
+
|
67
|
+
scheduler = Rufus::Scheduler.new
|
68
|
+
@scheduled_job = scheduler.schedule_every(@config['refreshEvery']) { @tracker.refresh! }
|
69
|
+
scheduler.join if @join_scheduler != false
|
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
|
85
|
+
end
|
data/lib/miyuki/notifier.rb
CHANGED
@@ -1,39 +1,39 @@
|
|
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) if has_notifier?
|
23
|
-
end
|
24
|
-
|
25
|
-
def has_notifier?
|
26
|
-
!!@notifier
|
27
|
-
end
|
28
|
-
|
29
|
-
private
|
30
|
-
|
31
|
-
def get_notifier
|
32
|
-
case RUBY_PLATFORM
|
33
|
-
when /darwin/ then Miyuki::TerminalNotifier.new
|
34
|
-
when /linux/ then Miyuki::Libnotify.new
|
35
|
-
when /mswin|msys|mingw|cygwin/ then Miyuki::Notifu.new
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
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) if has_notifier?
|
23
|
+
end
|
24
|
+
|
25
|
+
def has_notifier?
|
26
|
+
!!@notifier
|
27
|
+
end
|
28
|
+
|
29
|
+
private
|
30
|
+
|
31
|
+
def get_notifier
|
32
|
+
case RUBY_PLATFORM
|
33
|
+
when /darwin/ then Miyuki::TerminalNotifier.new
|
34
|
+
when /linux/ then Miyuki::Libnotify.new
|
35
|
+
when /mswin|msys|mingw|cygwin/ then Miyuki::Notifu.new
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|