legendario 0.1.7 → 0.1.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/bin/legendario +4 -3
- data/legendario.gemspec +1 -8
- data/legendario.rb +1 -3
- data/lib/legendario.rb +32 -15
- data/lib/legendario/version.rb +1 -1
- metadata +15 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 00c38d041d0d2f9e8f263404b7382584fcdd0f61
|
4
|
+
data.tar.gz: 937bb89b6953cc4d208eec425f873a59315a3256
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3c5377380ff20658f6fdb821ae03aa3be0963dfd5366e6b320652c8e709b640f49baa8865812e1049397196864540266df7106643a1a82ab7989f395504e15b6
|
7
|
+
data.tar.gz: 43438d99d45161a69eaaee5ee850a91abaa3594d0382ab6a5fb32198f28fb1134fddcad9bab5ec31b7202beb0c46bef8b03c9be6437f15f1d40777d0a530514a
|
data/.gitignore
CHANGED
data/bin/legendario
CHANGED
data/legendario.gemspec
CHANGED
@@ -21,21 +21,14 @@ Gem::Specification.new do |spec|
|
|
21
21
|
raise "RubyGems 2.0 or newer is required to protect against public gem pushes."
|
22
22
|
end
|
23
23
|
|
24
|
-
|
25
|
-
|
26
24
|
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
27
|
-
# spec.bindir = "exe"
|
28
25
|
spec.bindir = "bin"
|
29
|
-
|
30
|
-
|
31
|
-
# spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
32
26
|
spec.executables = ["legendario"]
|
33
27
|
spec.require_paths = ["lib"]
|
34
|
-
|
35
28
|
spec.add_development_dependency "bundler", "~> 1.10"
|
36
29
|
spec.add_development_dependency "rake", "~> 10.0"
|
37
30
|
spec.add_runtime_dependency "file-monitor", "~> 0.1"
|
38
31
|
spec.add_runtime_dependency "osdb", "~> 0.2"
|
39
32
|
spec.add_runtime_dependency "awesome_print", "~> 1.6"
|
40
|
-
|
33
|
+
spec.add_runtime_dependency "logging", "~> 2.0"
|
41
34
|
end
|
data/legendario.rb
CHANGED
@@ -10,11 +10,9 @@ lib_dir = File.join File.dirname(__FILE__), '../lib'
|
|
10
10
|
$:.unshift lib_dir unless $:.include? lib_dir
|
11
11
|
|
12
12
|
class Legendario
|
13
|
-
@dir = "
|
13
|
+
@dir = ""
|
14
14
|
def lang
|
15
|
-
[]
|
16
15
|
["eng", "por", "spa", "ger"]
|
17
|
-
# ["eng"]
|
18
16
|
end
|
19
17
|
|
20
18
|
def self.watch
|
data/lib/legendario.rb
CHANGED
@@ -2,21 +2,36 @@
|
|
2
2
|
require "legendario/version"
|
3
3
|
require 'file-monitor'
|
4
4
|
require 'find'
|
5
|
+
require 'logging'
|
5
6
|
|
6
7
|
module Legendario
|
7
8
|
|
8
9
|
lib_dir = File.join File.dirname(__FILE__), '../lib'
|
9
10
|
$:.unshift lib_dir unless $:.include? lib_dir
|
10
11
|
|
12
|
+
|
11
13
|
class Legendario
|
14
|
+
@@logger = Logging.logger['log/legendario.log']
|
15
|
+
@@logger.level = :debug
|
16
|
+
@@logger.add_appenders \
|
17
|
+
Logging.appenders.stdout,
|
18
|
+
Logging.appenders.file('log/legendario.log')
|
12
19
|
|
13
20
|
if ARGV.size == 0
|
14
|
-
|
15
|
-
puts '
|
16
|
-
|
21
|
+
@@logger.error 'A folder must be defined for watching'
|
22
|
+
puts ''
|
23
|
+
puts 'Please, try: '
|
24
|
+
puts ''
|
25
|
+
puts 'legendario "folder-name" eng por '
|
26
|
+
puts ''
|
27
|
+
puts 'for example.'
|
28
|
+
puts ''
|
29
|
+
puts 'Default languages are: eng por spa ger on this sequence of priority'
|
30
|
+
exit 1
|
17
31
|
end
|
18
32
|
|
19
33
|
@dir = ARGV[0]
|
34
|
+
@@lang = ["eng", "por", "spa", "ger"]
|
20
35
|
|
21
36
|
def self.lang
|
22
37
|
langs = ["eng", "por", "spa", "ger"]
|
@@ -28,11 +43,13 @@ module Legendario
|
|
28
43
|
c+=1
|
29
44
|
end
|
30
45
|
end
|
31
|
-
|
32
|
-
|
46
|
+
@@logger.info "Will look for subtitles on these languages: "
|
47
|
+
@@logger.info langs.inspect
|
33
48
|
langs
|
49
|
+
@@lang = langs
|
34
50
|
end
|
35
51
|
|
52
|
+
|
36
53
|
def self.watch
|
37
54
|
Legendario.new.watch_dirs(@dir)
|
38
55
|
end
|
@@ -41,13 +58,13 @@ module Legendario
|
|
41
58
|
puts command
|
42
59
|
o = `#{command}`
|
43
60
|
r = $?.to_i
|
44
|
-
|
61
|
+
@@logger.debug "#{o} #{r}"
|
45
62
|
r
|
46
63
|
end
|
47
64
|
|
48
65
|
def download_subs(file)
|
49
|
-
lang
|
50
|
-
|
66
|
+
@@lang.each do |l|
|
67
|
+
@@logger.info "Language: #{l}"
|
51
68
|
se("getsub -aLl #{l} \"#{file}\"")
|
52
69
|
end
|
53
70
|
symlink(File.dirname(file))
|
@@ -66,11 +83,11 @@ module Legendario
|
|
66
83
|
se("rm \"#{path}\"")
|
67
84
|
end
|
68
85
|
symlinked = false
|
69
|
-
|
86
|
+
@@lang.each do |l|
|
70
87
|
if /\.#{l}\.srt$/i =~ File.basename(path) and !symlinked
|
71
|
-
|
88
|
+
@@logger.debug path
|
72
89
|
link = path.sub(/\.#{l}\.srt$/i, '.srt')
|
73
|
-
|
90
|
+
@@logger.debug link
|
74
91
|
symlinked = true
|
75
92
|
se("ln -s \"#{path}\" \"#{link}\"")
|
76
93
|
break #this break is not working so using !symlinked
|
@@ -94,15 +111,15 @@ module Legendario
|
|
94
111
|
exec do |events|
|
95
112
|
events.each do |ev|
|
96
113
|
file = File.join(ev.watcher.path(), ev.name())
|
97
|
-
|
114
|
+
@@logger.info file
|
98
115
|
Legendario.new.download_subs(file)
|
99
116
|
end
|
100
117
|
end
|
101
118
|
#Avoids breaking after a directory been deleted
|
102
|
-
|
103
|
-
|
119
|
+
rescue => error
|
120
|
+
@@logger.error error.inspect
|
104
121
|
Legendario.watch
|
105
|
-
|
122
|
+
end
|
106
123
|
end
|
107
124
|
end
|
108
125
|
end
|
data/lib/legendario/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: legendario
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Evandro Junior
|
@@ -80,6 +80,20 @@ dependencies:
|
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '1.6'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: logging
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '2.0'
|
90
|
+
type: :runtime
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '2.0'
|
83
97
|
description: The script downloads subtitles when a new movie is put to a defined folder.
|
84
98
|
email:
|
85
99
|
- evandrojr@gmail.com
|