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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6c84207a9b086465749785214770a3adfab90aef
4
- data.tar.gz: 92d62a94cf0e845e6a3c418b25e285fde5a9bfc6
3
+ metadata.gz: 00c38d041d0d2f9e8f263404b7382584fcdd0f61
4
+ data.tar.gz: 937bb89b6953cc4d208eec425f873a59315a3256
5
5
  SHA512:
6
- metadata.gz: 8897645760604f812350a3291f7ea0905ba3249c8074c619f036bdf03b2036b37200e26138818ebc36f1f497ff5aa1ac3ee9df06e2e25553dfbb96482fc2d23d
7
- data.tar.gz: 1feaaf69dc00e8a958e320407c02908392e5a40656dcdabe40bc8c0535de42834142b48877a6e7d86cff60ad5cda35bce4d7feee9e578a8d39ed5f1573fb8fa7
6
+ metadata.gz: 3c5377380ff20658f6fdb821ae03aa3be0963dfd5366e6b320652c8e709b640f49baa8865812e1049397196864540266df7106643a1a82ab7989f395504e15b6
7
+ data.tar.gz: 43438d99d45161a69eaaee5ee850a91abaa3594d0382ab6a5fb32198f28fb1134fddcad9bab5ec31b7202beb0c46bef8b03c9be6437f15f1d40777d0a530514a
data/.gitignore CHANGED
@@ -7,3 +7,4 @@
7
7
  /pkg/
8
8
  /spec/reports/
9
9
  /tmp/
10
+ /log/
data/bin/legendario CHANGED
@@ -1,5 +1,6 @@
1
1
  #!/usr/bin/env ruby
2
- require "legendario"
2
+ require_relative "../lib/legendario"
3
+ require_relative "../lib/legendario/version"
3
4
 
4
- Legendario.lang
5
- Legendario.watch
5
+ Legendario::Legendario.lang
6
+ Legendario::Legendario.watch
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 = "/home/j/Downloads"
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
- puts 'Error no folder defined. Try legendario.rb "folder-name" eng por for example'
15
- puts 'default languages are: eng por spa ger '
16
- exit 0
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
- puts "Will look for subtitles on these languages: "
32
- puts langs.inspect
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
- puts "#{o} #{r}"
61
+ @@logger.debug "#{o} #{r}"
45
62
  r
46
63
  end
47
64
 
48
65
  def download_subs(file)
49
- lang().each do |l|
50
- puts "Language: #{l}"
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
- self.lang().each do |l|
86
+ @@lang.each do |l|
70
87
  if /\.#{l}\.srt$/i =~ File.basename(path) and !symlinked
71
- puts path
88
+ @@logger.debug path
72
89
  link = path.sub(/\.#{l}\.srt$/i, '.srt')
73
- puts link
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
- puts file
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
- rescue => error
103
- puts("#{error.class} and #{error.message}")
119
+ rescue => error
120
+ @@logger.error error.inspect
104
121
  Legendario.watch
105
- end
122
+ end
106
123
  end
107
124
  end
108
125
  end
@@ -1,3 +1,3 @@
1
1
  module Legendario
2
- VERSION = "0.1.7"
2
+ VERSION = "0.1.8"
3
3
  end
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.7
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