miyuki 0.4 → 0.5
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/CHANGELOG.md +16 -0
- data/example/miyuki.conf +5 -2
- data/features/step_definitions/tracker_step.rb +37 -8
- data/features/support/env.rb +7 -0
- data/features/support/miyuki.conf +5 -2
- data/features/tracker.feature +5 -3
- data/lib/miyuki/parser.rb +55 -0
- data/lib/miyuki/tracker.rb +9 -14
- data/lib/miyuki/version.rb +1 -1
- data/lib/miyuki.rb +1 -0
- metadata +5 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 0d1d62e953d637ca08c623be1773c1fe6e9d96ec
|
|
4
|
+
data.tar.gz: cae2deff7388f7bfc4d8f6f28f751eb03aa476fe
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: fa4d58397e07128b437f0e9308e4e36e7c2ed2edffd99db3e922467a86c8c9094d9a042ede7fd5ffdbef4e67f83e1928a0256f43bf1cd2b16280ab6091a7c3c4
|
|
7
|
+
data.tar.gz: 2dc1f9116496dfc6be9a6079ca5808c077a7bb256cffe78d2d2bc19f7c0380135f483e5cb639a0364e9e114ddb79367b4fd8217f3475eea757fbfcef6c7dba5c
|
data/CHANGELOG.md
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# 0.5
|
|
2
|
+
- Add episodes block in the configuration file to download range of episodes
|
|
3
|
+
|
|
4
|
+
# 0.4
|
|
5
|
+
- Add tests
|
|
6
|
+
- Implement file-watcher for configuration file
|
|
7
|
+
- Add system notifier for Windows
|
|
8
|
+
|
|
9
|
+
# 0.3
|
|
10
|
+
- Implement system notifications for OSX and Linux
|
|
11
|
+
|
|
12
|
+
# 0.2
|
|
13
|
+
- Daemonization
|
|
14
|
+
|
|
15
|
+
# 0.1
|
|
16
|
+
- Initial release
|
data/example/miyuki.conf
CHANGED
|
@@ -2,30 +2,59 @@ And(/I wait (\d+) seconds?/) do |seconds|
|
|
|
2
2
|
sleep seconds.to_f
|
|
3
3
|
end
|
|
4
4
|
|
|
5
|
-
Then(/I have almost (\d+) torrent files? containing "(
|
|
5
|
+
Then(/I have almost (\d+) torrent files? containing "(.+)"/) do |count, string|
|
|
6
6
|
watch_dir = Miyuki.config['watchDir']
|
|
7
|
-
torrent_files = Dir["#{watch_dir}/*.torrent"].select { |f| f.
|
|
7
|
+
torrent_files = Dir["#{watch_dir}/*.torrent"].select { |f| f.contains?(string) }
|
|
8
8
|
|
|
9
9
|
expect(torrent_files.count).to be >= count.to_i
|
|
10
10
|
end
|
|
11
11
|
|
|
12
|
-
And(/I have almost (\d+) torrent files? that do not contain "(
|
|
12
|
+
And(/I have almost (\d+) torrent files? that do not contain "(.+)"/) do |count, string|
|
|
13
13
|
watch_dir = Miyuki.config['watchDir']
|
|
14
|
-
torrent_files = Dir["#{watch_dir}/*.torrent"].reject { |f| f.
|
|
14
|
+
torrent_files = Dir["#{watch_dir}/*.torrent"].reject { |f| f.contains?(string) }
|
|
15
15
|
|
|
16
16
|
expect(torrent_files.count).to be >= count.to_i
|
|
17
17
|
end
|
|
18
18
|
|
|
19
|
-
And(/
|
|
19
|
+
And(/I have not the episodes? (.+) of "(.+)"/) do |episodes, string|
|
|
20
20
|
watch_dir = Miyuki.config['watchDir']
|
|
21
|
-
torrent_files = Dir["#{watch_dir}/*.torrent"].select { |f| f.
|
|
21
|
+
torrent_files = Dir["#{watch_dir}/*.torrent"].select { |f| f.contains?(string) }
|
|
22
|
+
|
|
23
|
+
episodes = episodes.split(',').map(&:to_i)
|
|
24
|
+
|
|
25
|
+
torrent_files.select! do |f|
|
|
26
|
+
episode = f.scan(/- [0-9]*\.?[0-9]+/).flatten.last.to_i
|
|
27
|
+
episodes.include?(episode)
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
expect(torrent_files.empty?).to be_truthy
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
And(/I have the episodes? (.+) of "(.+)"/) do |episodes, string|
|
|
34
|
+
watch_dir = Miyuki.config['watchDir']
|
|
35
|
+
torrent_files = Dir["#{watch_dir}/*.torrent"].select { |f| f.contains?(string) }
|
|
36
|
+
torrent_files_count = torrent_files.length
|
|
37
|
+
|
|
38
|
+
episodes = episodes.split(',').map(&:to_i)
|
|
39
|
+
|
|
40
|
+
torrent_files.select! do |f|
|
|
41
|
+
episode = f.scan(/- [0-9]*\.?[0-9]+/).flatten.last.to_i
|
|
42
|
+
episodes.include?(episode)
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
expect(torrent_files.length).to_not be torrent_files_count
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
And(/there are (\d+) torrent files? containing "(.+)"/) do |count, string|
|
|
49
|
+
watch_dir = Miyuki.config['watchDir']
|
|
50
|
+
torrent_files = Dir["#{watch_dir}/*.torrent"].select { |f| f.contains?(string) }
|
|
22
51
|
|
|
23
52
|
expect(torrent_files.count).to be count.to_i
|
|
24
53
|
end
|
|
25
54
|
|
|
26
|
-
And(/there are (\d+) torrent files? that do not contain "(
|
|
55
|
+
And(/there are (\d+) torrent files? that do not contain "(.+)"/) do |count, string|
|
|
27
56
|
watch_dir = Miyuki.config['watchDir']
|
|
28
|
-
torrent_files = Dir["#{watch_dir}/*.torrent"].reject { |f| f.
|
|
57
|
+
torrent_files = Dir["#{watch_dir}/*.torrent"].reject { |f| f.contains?(string) }
|
|
29
58
|
|
|
30
59
|
expect(torrent_files.count).to be count.to_i
|
|
31
60
|
end
|
data/features/support/env.rb
CHANGED
data/features/tracker.feature
CHANGED
|
@@ -7,9 +7,11 @@ Feature: Download new episodes
|
|
|
7
7
|
When I set the configuration file path to "features/support/miyuki.conf"
|
|
8
8
|
And I invoke "track!"
|
|
9
9
|
And I wait 5 seconds to let Miyuki to find and download the episodes
|
|
10
|
-
Then I have almost 2 torrent files containing "BD"
|
|
11
|
-
And I have almost
|
|
12
|
-
And
|
|
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"
|
|
13
15
|
And there are 0 torrent files that do not contain "[Commie]"
|
|
14
16
|
|
|
15
17
|
Scenario: Episodes already downloaded are ignored
|
|
@@ -0,0 +1,55 @@
|
|
|
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
|
+
module Parser
|
|
17
|
+
class << self
|
|
18
|
+
def parse(series)
|
|
19
|
+
pattern = series.fetch('pattern', '[$fansub] $name')
|
|
20
|
+
|
|
21
|
+
pattern.scan(/\$[a-zA-Z_]*/).each do |var|
|
|
22
|
+
pattern.gsub!(var, series[var[1..-1]]) if series.has_key?(var[1..-1])
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
pattern
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def filter_episodes!(torrents, from_episode, skip = false)
|
|
29
|
+
range = from_episode..1.0/0
|
|
30
|
+
|
|
31
|
+
if range
|
|
32
|
+
torrents.select! do |torrent|
|
|
33
|
+
return skip unless torrent.title
|
|
34
|
+
|
|
35
|
+
episode = torrent.title.scan(/- [0-9]*\.?[0-9]+/).last
|
|
36
|
+
episode = episode.scan(/[0-9]*\.?[0-9]+/).last if episode
|
|
37
|
+
episode = episode[1..-1] if episode && episode[0] == '0'
|
|
38
|
+
|
|
39
|
+
if episode
|
|
40
|
+
is_integer?(episode) ? range.include?(episode.to_i) : skip
|
|
41
|
+
else
|
|
42
|
+
skip
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
private
|
|
49
|
+
|
|
50
|
+
def is_integer?(string)
|
|
51
|
+
string.to_i.to_s == string
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
end
|
data/lib/miyuki/tracker.rb
CHANGED
|
@@ -39,7 +39,7 @@ module Miyuki
|
|
|
39
39
|
def refresh
|
|
40
40
|
@torrents = []
|
|
41
41
|
|
|
42
|
-
fetch_torrents
|
|
42
|
+
fetch_torrents!
|
|
43
43
|
|
|
44
44
|
@torrents.each do |torrent|
|
|
45
45
|
downloaded = Yamazaki.download_torrent(torrent.title, torrent.link)
|
|
@@ -58,23 +58,18 @@ module Miyuki
|
|
|
58
58
|
|
|
59
59
|
private
|
|
60
60
|
|
|
61
|
-
def fetch_torrents
|
|
61
|
+
def fetch_torrents!
|
|
62
62
|
@series.each do |series|
|
|
63
|
-
|
|
64
|
-
torrents = search(
|
|
63
|
+
query = URI.encode_www_form_component(Parser.parse(series)) # TODO: move encode to yamazaki?
|
|
64
|
+
torrents = search(query)
|
|
65
65
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
def pattern_of(series)
|
|
71
|
-
pattern = series.fetch('pattern', '[$fansub] $name')
|
|
66
|
+
episodes = series['episodes']
|
|
67
|
+
if episodes && episodes['from']
|
|
68
|
+
Parser.filter_episodes!(torrents, episodes['from'], !!episodes['skipIfNotSure'])
|
|
69
|
+
end
|
|
72
70
|
|
|
73
|
-
|
|
74
|
-
pattern.gsub!(var, series[var[1..-1]]) if series.has_key?(var[1..-1])
|
|
71
|
+
@torrents.concat(torrents.reverse)
|
|
75
72
|
end
|
|
76
|
-
|
|
77
|
-
pattern
|
|
78
73
|
end
|
|
79
74
|
end
|
|
80
75
|
end
|
data/lib/miyuki/version.rb
CHANGED
data/lib/miyuki.rb
CHANGED
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.5'
|
|
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-12-
|
|
11
|
+
date: 2014-12-25 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: yamazaki
|
|
@@ -131,6 +131,7 @@ extra_rdoc_files: []
|
|
|
131
131
|
files:
|
|
132
132
|
- ".gitignore"
|
|
133
133
|
- ".travis.yml"
|
|
134
|
+
- CHANGELOG.md
|
|
134
135
|
- Gemfile
|
|
135
136
|
- Gemfile.lock
|
|
136
137
|
- README.md
|
|
@@ -151,6 +152,7 @@ files:
|
|
|
151
152
|
- lib/miyuki/notifiers/libnotify.rb
|
|
152
153
|
- lib/miyuki/notifiers/notifu.rb
|
|
153
154
|
- lib/miyuki/notifiers/terminal-notifier.rb
|
|
155
|
+
- lib/miyuki/parser.rb
|
|
154
156
|
- lib/miyuki/tracker.rb
|
|
155
157
|
- lib/miyuki/version.rb
|
|
156
158
|
- miyuki.gemspec
|
|
@@ -174,7 +176,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
174
176
|
version: '0'
|
|
175
177
|
requirements: []
|
|
176
178
|
rubyforge_project:
|
|
177
|
-
rubygems_version: 2.
|
|
179
|
+
rubygems_version: 2.4.2
|
|
178
180
|
signing_key:
|
|
179
181
|
specification_version: 4
|
|
180
182
|
summary: Miyuki allows you to not miss any episode of anime you're watching
|