legendario 0.1.12 → 0.1.13

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: 98628539a957070b5797122c28b6ddc98e2fa53e
4
- data.tar.gz: 667b815ddb282b93d50d73d32588ffad6b72f666
3
+ metadata.gz: 05fbddeb39118ac0ab96fc059318cf59d1088728
4
+ data.tar.gz: 7922a1ce6ce3b142a172eaa855e457d3cd8dc837
5
5
  SHA512:
6
- metadata.gz: 5be8ae7e37e7323bce0e5dc88a227bc59d15561bc7e9a43c09fc4b2d48feda8cceb376005ad5f2ff2bfb4b9494277e21dc0e7e00b54ccd5e4c4a3497cf731ab3
7
- data.tar.gz: e4768f95f6d07eaaa4015518e2ac2812c7ac6a9139a10c7c0e4df52baa6f740ebd427c7a8999f6acca81d2eb3883ed1f3e5b17771d196e383438c339899e874d
6
+ metadata.gz: 12ef0f26390feab1ea890a75ff4157202640fae370f038446a842254ee22cf0bdfe2fae4c80fdae0704d443415c21618ed5e30e54e757e7aeb9b82fe54bcdd44
7
+ data.tar.gz: e32502b1a9dc6d8a4ace62fe6cf0316387b53769a6110b6c63332681caeb909f26724e974d3df6e6f1d5101752d32336e3dc673d2285de65156a68b64dcf95c7
data/.gitignore CHANGED
@@ -7,5 +7,4 @@
7
7
  /pkg/
8
8
  /spec/reports/
9
9
  /tmp/
10
- .log
11
- /log/.log
10
+ legendario.log
File without changes
@@ -0,0 +1,82 @@
1
+ #!/usr/bin/env ruby
2
+ require 'find'
3
+ require_relative '../lib/sl'
4
+
5
+ if ARGV.size == 0
6
+ Sl.error 'The parent folder that will have the language changed'
7
+ puts ''
8
+ puts 'Please, try something like: '
9
+ puts ''
10
+ puts 'change_sub_lang "folder-name" eng por '
11
+ puts ''
12
+ puts 'for example.'
13
+ puts ''
14
+ puts 'Default languages are: eng por spa ger on this sequence of priority'
15
+ exit 1
16
+ end
17
+
18
+ def se(command)
19
+ o = `#{command}`
20
+ r = $?.to_i
21
+ Sl.debug "#{o} #{r}"
22
+ r
23
+ end
24
+
25
+ dir = ARGV[0]
26
+ lang = ["eng", "por", "spa", "ger"]
27
+ if ARGV.size > 1
28
+ lang = []
29
+ c = 0
30
+ ARGV.each do|l|
31
+ lang << l if c > 0
32
+ c+=1
33
+ end
34
+ end
35
+
36
+ Sl.info "Language priority:"
37
+ Sl.info lang.inspect
38
+ Sl.info "The first language found will be soft linked to the subtitle file"
39
+
40
+ total_files = 0
41
+
42
+ Find.find(dir) do |path|
43
+ puts "path: #{path}"
44
+ if FileTest.directory?(path)
45
+ if File.basename(path)[0] == ?.
46
+ Find.prune # Don't look any further into this directory.
47
+ else
48
+ next
49
+ end
50
+ else
51
+ if FileTest.symlink?(path) and /\.srt$/i =~ File.basename(path)
52
+ Sl.info "Deleting: #{path}"
53
+ File.delete(path)
54
+ end
55
+ end
56
+ end
57
+
58
+ Find.find(dir) do |path|
59
+ leave = false
60
+ if FileTest.directory?(path)
61
+ if File.basename(path)[0] == ?.
62
+ Find.prune # Don't look any further into this directory.
63
+ else
64
+ next
65
+ end
66
+ else
67
+ lang.each do |l|
68
+ if /\.#{l}\.srt$/i =~ File.basename(path) and !FileTest.symlink?(path)
69
+ link = path.sub(/\.#{l}\.srt$/i, '.srt')
70
+ se "ln -s \"#{path}\" \"#{link}\""
71
+ Sl.info "Linking sub lang #{l} to #{link}"
72
+ total_files +=1
73
+ # leave = true
74
+ break
75
+ end
76
+ # break if leave
77
+ end
78
+ end
79
+ end
80
+
81
+
82
+ Sl.info "Total of files linked: #{total_files}"
data/legendario.gemspec CHANGED
@@ -23,7 +23,7 @@ Gem::Specification.new do |spec|
23
23
 
24
24
  spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
25
25
  spec.bindir = "bin"
26
- spec.executables = ["legendario", "get_all_subtitles"]
26
+ spec.executables = ["legendario", "crawl4subtitles", "subtitle_language_switch"]
27
27
  spec.require_paths = ["lib"]
28
28
  spec.add_development_dependency "bundler", "~> 1.10"
29
29
  spec.add_development_dependency "rake", "~> 10.0"
data/lib/legendario.rb CHANGED
@@ -2,25 +2,19 @@
2
2
  require "legendario/version"
3
3
  require 'file-monitor'
4
4
  require 'find'
5
- require 'logging'
5
+ require_relative 'sl'
6
6
 
7
7
  module Legendario
8
8
 
9
9
  lib_dir = File.join File.dirname(__FILE__), '../lib'
10
10
  $:.unshift lib_dir unless $:.include? lib_dir
11
11
 
12
-
13
12
  class Legendario
14
- @@logger = Logging.logger['legendario.log']
15
- @@logger.level = :debug
16
- @@logger.add_appenders \
17
- Logging.appenders.stdout,
18
- Logging.appenders.file('legendario.log')
19
13
 
20
14
  if ARGV.size == 0
21
- @@logger.error 'A folder must be defined for watching'
15
+ Sl.error 'The folder that will be watched for new movies should be defined'
22
16
  puts ''
23
- puts 'Please, try: '
17
+ puts 'Please, try something like: '
24
18
  puts ''
25
19
  puts 'legendario "folder-name" eng por '
26
20
  puts ''
@@ -43,28 +37,26 @@ module Legendario
43
37
  c+=1
44
38
  end
45
39
  end
46
- @@logger.info "Will look for subtitles on these languages: "
47
- @@logger.info langs.inspect
40
+ Sl.info "Will look for subtitles on these languages: "
41
+ Sl.info langs.inspect
48
42
  langs
49
43
  @@lang = langs
50
44
  end
51
45
 
52
-
53
46
  def self.watch
54
47
  Legendario.new.watch_dirs(@dir)
55
48
  end
56
49
 
57
50
  def se(command)
58
- puts command
59
51
  o = `#{command}`
60
52
  r = $?.to_i
61
- @@logger.debug "#{o} #{r}"
53
+ Sl.debug "#{o} #{r}"
62
54
  r
63
55
  end
64
56
 
65
57
  def download_subs(file)
66
58
  @@lang.each do |l|
67
- @@logger.info "Language: #{l}"
59
+ Sl.info "Language: #{l}"
68
60
  se("getsub -aLl #{l} \"#{file}\"")
69
61
  end
70
62
  symlink(File.dirname(file))
@@ -85,9 +77,9 @@ module Legendario
85
77
  symlinked = false
86
78
  @@lang.each do |l|
87
79
  if /\.#{l}\.srt$/i =~ File.basename(path) and !symlinked
88
- @@logger.debug path
80
+ Sl.debug path
89
81
  link = path.sub(/\.#{l}\.srt$/i, '.srt')
90
- @@logger.debug link
82
+ Sl.debug link
91
83
  symlinked = true
92
84
  se("ln -s \"#{path}\" \"#{link}\"")
93
85
  break #this break is not working so using !symlinked
@@ -111,13 +103,13 @@ module Legendario
111
103
  exec do |events|
112
104
  events.each do |ev|
113
105
  file = File.join(ev.watcher.path(), ev.name())
114
- @@logger.info file
106
+ Sl.info file
115
107
  Legendario.new.download_subs(file)
116
108
  end
117
109
  end
118
110
  #Avoids breaking after a directory been deleted
119
111
  rescue => error
120
- @@logger.error error.inspect
112
+ Sl.error error.inspect
121
113
  Legendario.watch
122
114
  end
123
115
  end
@@ -1,3 +1,3 @@
1
1
  module Legendario
2
- VERSION = "0.1.12"
2
+ VERSION = "0.1.13"
3
3
  end
data/lib/sl.rb ADDED
@@ -0,0 +1,23 @@
1
+ require 'logging'
2
+
3
+ class Sl
4
+
5
+ @@l = Logging.logger['legendario.log']
6
+ @@l.level = :debug
7
+ @@l.add_appenders \
8
+ Logging.appenders.stdout,
9
+ Logging.appenders.file('legendario.log')
10
+
11
+ def self.error(m)
12
+ @@l.error m
13
+ end
14
+
15
+ def self.info m
16
+ @@l.info m
17
+ end
18
+
19
+ def self.debug m
20
+ @@l.debug m
21
+ end
22
+
23
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: legendario
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.12
4
+ version: 0.1.13
5
5
  platform: ruby
6
6
  authors:
7
7
  - Evandro Junior
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-11-29 00:00:00.000000000 Z
11
+ date: 2015-12-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -99,7 +99,8 @@ email:
99
99
  - evandrojr@gmail.com
100
100
  executables:
101
101
  - legendario
102
- - get_all_subtitles
102
+ - crawl4subtitles
103
+ - subtitle_language_switch
103
104
  extensions: []
104
105
  extra_rdoc_files: []
105
106
  files:
@@ -113,12 +114,14 @@ files:
113
114
  - README.md
114
115
  - Rakefile
115
116
  - bin/console
116
- - bin/get_all_subtitles
117
+ - bin/crawl4subtitles
117
118
  - bin/legendario
118
119
  - bin/setup
120
+ - bin/subtitle_language_switch
119
121
  - legendario.gemspec
120
122
  - lib/legendario.rb
121
123
  - lib/legendario/version.rb
124
+ - lib/sl.rb
122
125
  homepage: https://github.com/evandrojr/legendario
123
126
  licenses:
124
127
  - MIT
@@ -140,8 +143,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
140
143
  version: '0'
141
144
  requirements: []
142
145
  rubyforge_project:
143
- rubygems_version: 2.4.8
146
+ rubygems_version: 2.2.2
144
147
  signing_key:
145
148
  specification_version: 4
146
149
  summary: Subtitles downloader on demand.
147
150
  test_files: []
151
+ has_rdoc: