miyuki 0.5.7 → 0.5.10

Sign up to get free protection for your applications and to get access to all the features.
@@ -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}}]
@@ -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
- Cucumber.wants_to_quit = true if s.failed?
19
- end
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
- refreshEvery: 5s
3
- notifications:
4
- enabled: true
5
-
6
- series:
7
- - name: Mekakucity
8
- fansub: Commie
9
- episodes:
10
- from: 9
11
- skipIfNotSure: true
12
-
13
- - name: Nisekoi
14
- fansub: Commie
15
- res: 1080p
16
- pattern: "[$fansub] $name - Volume [BD $res AAC]"
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
@@ -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
@@ -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
- And I have the episodes 11, 12 of "Danna"
17
- And I have not the episode 10 of "Danna"
18
- And there are some torrent files by "Task-Force"
19
-
20
- Scenario: Episodes already downloaded are ignored
21
- When I set the configuration file path to "features/support/miyuki.conf"
22
- And I invoke "track!"
23
- And I wait 5 seconds to let Miyuki to find and download the episodes
24
- And I consider the currently downloaded torrent files
25
- And I wait 6 seconds in order to have a new check of the new anime episodes
26
- And I wait 5 seconds in case this scenario would fail
27
- Then I expect 0 torrent files have been overwritten by their duplicates
28
-
29
- Scenario: There is a notification for every episode downloaded if enabled
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
- require 'fileutils'
16
- require 'yaml'
17
- require 'rufus-scheduler'
18
- require 'yamazaki'
19
- require 'filewatcher'
20
- require 'deep_clone'
21
-
22
- require 'miyuki/notifier'
23
- require 'miyuki/parser'
24
- require 'miyuki/tracker'
25
- require 'miyuki/miyuki'
26
- require 'miyuki/version'
27
-
28
- case RUBY_PLATFORM
29
- when /darwin/ then require 'miyuki/notifiers/terminal-notifier.rb'
30
- when /linux/ then require 'miyuki/notifiers/libnotify.rb'
31
- when /mswin|msys|mingw|cygwin/ then require 'miyuki/notifiers/notifu.rb'
32
- 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
+ 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
- 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
- config = DeepClone.clone(@config)
38
- @tracker = Tracker.new(watch_dir, config['series']) do |torrent|
39
- notify_torrents(torrent)
40
- end
41
-
42
- @tracker.refresh! && run_scheduler!
43
- end
44
-
45
- private
46
-
47
- def refresh_config
48
- new_config = load_config
49
-
50
- if @config != new_config
51
- notify_configuration
52
-
53
- @config = new_config
54
- track!
55
- end
56
- end
57
-
58
- def load_config
59
- YAML.load(File.read(@config_file))
60
- end
61
-
62
- def run_scheduler!
63
- @scheduled_job.kill if @scheduled_job
64
-
65
- scheduler = Rufus::Scheduler.new
66
- @scheduled_job = scheduler.schedule_every @config['refreshEvery'] { @tracker.refresh! }
67
- scheduler.join if @join_scheduler != false
68
- end
69
-
70
- def notify_torrents(torrent)
71
- if @config['notifications']['enabled']
72
- @notifier.notify(torrent.title, 'New episode released')
73
- sleep 1.1
74
- end
75
- end
76
-
77
- def notify_configuration
78
- if @config['notifications']['enabled']
79
- @notifier.notify('New configuration loaded in Miyuki', 'Changes detected in configuration file')
80
- end
81
- end
82
- end
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
@@ -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