miyuki 0.1.1

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 2fdcac097c9d3917dec96b1bb17e8a9b54506ce4
4
+ data.tar.gz: 71339d1b70ee0d22806b32033d92e0c6bd46ed50
5
+ SHA512:
6
+ metadata.gz: 4626c25ba964c18ac3022450ef96f140f28444a9bef94ce052e3d975f74b2be96a7f1512de62f2b25842b899abbe6aaadb04f657c23abb94e953e887fc434ec5
7
+ data.tar.gz: 5e3ea75842fb0627ef7ff6c018f111a9963321ae8f9289e9aa9454d807877c7416b2b7b423f39c353bec2e499b7213e260edc2161e831cc80effccba336a94ac
data/bin/miyuki ADDED
@@ -0,0 +1,22 @@
1
+ #!/usr/bin/env ruby
2
+ ##
3
+ # DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
4
+ # Version 2, December 2004
5
+ #
6
+ # Everyone is permitted to copy and distribute verbatim or modified
7
+ # copies of this license document, and changing it is allowed as long
8
+ # as the name is changed.
9
+ #
10
+ # DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
11
+ # TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
12
+ #
13
+ # 0. You just DO WHAT THE FUCK YOU WANT TO.
14
+ ##
15
+
16
+ require 'miyuki'
17
+
18
+ abort 'Please provide a configuration file.' if ARGV.empty?
19
+ abort 'Given configuration file does not work.' unless File.exists?(ARGV[0])
20
+
21
+ Miyuki.config = File.expand_path(ARGV[0])
22
+ Miyuki.track!
@@ -0,0 +1,64 @@
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
+ def config=(config_file)
18
+ @@config_file = config_file
19
+ @@config = load_config
20
+
21
+ Rufus::Scheduler.singleton.every('10m') { refresh_config! }
22
+ end
23
+
24
+ def track!
25
+ watch_dir = File.expand_path(@@config['configuration']['watchDir'])
26
+ @@tracker = Tracker.new(watch_dir, @@config['series'])
27
+
28
+ run_scheduler
29
+ end
30
+
31
+ private
32
+
33
+ def refresh_config!
34
+ new_config = load_config
35
+
36
+ if @@config != new_config
37
+ @@config = new_config
38
+ @@scheduler.pause if defined?(@@scheduler)
39
+ track!
40
+ end
41
+ end
42
+
43
+ def load_config
44
+ YAML.load(File.read(@@config_file))
45
+ end
46
+
47
+ def run_scheduler
48
+ @@scheduler = Rufus::Scheduler.new
49
+ @@scheduler.every @@config['configuration']['refreshEvery'] do
50
+ old_torrents = @@tracker.torrents
51
+
52
+ @@tracker.refresh
53
+
54
+ new_torrents = @@tracker.torrents - old_torrents
55
+ if new_torrents.any?
56
+ puts 'New torrents:'
57
+ new_torrents.each { |torrent| puts torrent.to_s }
58
+ end
59
+ end
60
+
61
+ @@scheduler.join
62
+ end
63
+ end
64
+ end
@@ -0,0 +1,59 @@
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 Tracker
17
+ include Yamazaki::Core
18
+
19
+ attr_reader :torrents
20
+
21
+ def initialize(watch_dir, series)
22
+ Yamazaki.const_set(:WATCH_DIR, watch_dir)
23
+
24
+ @series = series
25
+
26
+ refresh
27
+ end
28
+
29
+ private
30
+
31
+ def refresh
32
+ @torrents = []
33
+
34
+ fetch_torrents
35
+ @torrents.reverse.each { |torrent| Yamazaki.download_torrent(torrent.title, torrent.link) }
36
+ end
37
+
38
+ def fetch_torrents
39
+ @series.each do |series|
40
+ pattern = pattern_of(series)
41
+ torrents = search(pattern)
42
+
43
+ torrents.each do |torrent|
44
+ @torrents << torrent
45
+ end
46
+ end
47
+ end
48
+
49
+ def pattern_of(series)
50
+ pattern = series.fetch('pattern', '[$fansub] $name')
51
+
52
+ pattern.scan(/\$[a-zA-Z_]*/).each do |var|
53
+ pattern.gsub!(var, series[var[1..-1]]) if series.has_key?(var[1..-1])
54
+ end
55
+
56
+ pattern
57
+ end
58
+ end
59
+ end
@@ -0,0 +1,17 @@
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
+ VERSION = '0.1.1'
17
+ end
data/lib/miyuki.rb ADDED
@@ -0,0 +1,21 @@
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 'yaml'
16
+ require 'rufus-scheduler'
17
+ require 'yamazaki'
18
+
19
+ require 'miyuki/tracker'
20
+ require 'miyuki/miyuki'
21
+ require 'miyuki/version'
metadata ADDED
@@ -0,0 +1,77 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: miyuki
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.1
5
+ platform: ruby
6
+ authors:
7
+ - Roxas Shadow
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-11-22 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: yamazaki
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '0.3'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '0.3'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rufus-scheduler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '3.0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '3.0'
41
+ description: Miyuki downloads automatically every episode of anime you're watching
42
+ email: webmaster@giovannicapuano.net
43
+ executables:
44
+ - miyuki
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - bin/miyuki
49
+ - lib/miyuki.rb
50
+ - lib/miyuki/miyuki.rb
51
+ - lib/miyuki/tracker.rb
52
+ - lib/miyuki/version.rb
53
+ homepage: https://github.com/RoxasShadow
54
+ licenses:
55
+ - WTFPL
56
+ metadata: {}
57
+ post_install_message:
58
+ rdoc_options: []
59
+ require_paths:
60
+ - lib
61
+ required_ruby_version: !ruby/object:Gem::Requirement
62
+ requirements:
63
+ - - ">="
64
+ - !ruby/object:Gem::Version
65
+ version: '0'
66
+ required_rubygems_version: !ruby/object:Gem::Requirement
67
+ requirements:
68
+ - - ">="
69
+ - !ruby/object:Gem::Version
70
+ version: '0'
71
+ requirements: []
72
+ rubyforge_project:
73
+ rubygems_version: 2.2.2
74
+ signing_key:
75
+ specification_version: 4
76
+ summary: Miyuki allows you to not miss any episode of anime you're watching
77
+ test_files: []