miyuki 0.4 → 0.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0e1f6766c6de32f19ca19a15b0d50c4aac6462cd
4
- data.tar.gz: 71406609632d18bcded6d20be2ffb1f3d1d9f867
3
+ metadata.gz: 0d1d62e953d637ca08c623be1773c1fe6e9d96ec
4
+ data.tar.gz: cae2deff7388f7bfc4d8f6f28f751eb03aa476fe
5
5
  SHA512:
6
- metadata.gz: 4251deb61c0d65ce5a88fc2667a8904a64ce665c1817b5a87e0437e478e0ebeea1d5b7070e2a0ec054d29c2af230630b995db0d98c29a45dcdc686fc7372b442
7
- data.tar.gz: 2d5ce0c653fd560c64f2d7ad13ec5382dcf89c1064727696748818db7c73a453cddde89bac4e51bab8bb020066eda6853ff6c28a8835189387dc63dfedbf85b6
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
@@ -4,8 +4,11 @@ notifications:
4
4
  enabled: true
5
5
 
6
6
  series:
7
- - name: Mekakucity
8
- fansub: Commie
7
+ - name: Mekakucity
8
+ fansub: Commie
9
+ episodes:
10
+ from: 9
11
+ skipIfNotSure: true # default: false (download anyway)
9
12
 
10
13
  - name: Nisekoi
11
14
  fansub: Commie
@@ -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 "(.*?)"/) do |count, string|
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.include?(string) }
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 "(.*?)"/) do |count, string|
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.include?(string) }
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(/there are (\d+) torrent files? containing "(.*?)"/) do |count, string|
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.include?(string) }
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 "(.*?)"/) do |count, string|
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.include?(string) }
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
@@ -2,6 +2,13 @@ require 'miyuki'
2
2
  require 'rspec'
3
3
  require 'fileutils'
4
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
+
5
12
  Miyuki.join_scheduler = false
6
13
 
7
14
  After do |s|
@@ -4,8 +4,11 @@ notifications:
4
4
  enabled: true
5
5
 
6
6
  series:
7
- - name: Mekakucity
8
- fansub: Commie
7
+ - name: Mekakucity
8
+ fansub: Commie
9
+ episodes:
10
+ from: 9
11
+ skipIfNotSure: true
9
12
 
10
13
  - name: Nisekoi
11
14
  fansub: Commie
@@ -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 torrent file that do not contain "BD"
12
- And there are 0 torrent files containing "BD 720p"
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
@@ -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
- pattern = pattern_of(series)
64
- torrents = search(pattern)
63
+ query = URI.encode_www_form_component(Parser.parse(series)) # TODO: move encode to yamazaki?
64
+ torrents = search(query)
65
65
 
66
- @torrents.concat(torrents.reverse)
67
- end
68
- end
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
- pattern.scan(/\$[a-zA-Z_]*/).each do |var|
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
@@ -13,5 +13,5 @@
13
13
  ##
14
14
 
15
15
  module Miyuki
16
- VERSION = '0.4'
16
+ VERSION = '0.5'
17
17
  end
data/lib/miyuki.rb CHANGED
@@ -20,6 +20,7 @@ require 'filewatcher'
20
20
  require 'deep_clone'
21
21
 
22
22
  require 'miyuki/notifier'
23
+ require 'miyuki/parser'
23
24
  require 'miyuki/tracker'
24
25
  require 'miyuki/miyuki'
25
26
  require 'miyuki/version'
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'
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-14 00:00:00.000000000 Z
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.2.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