legendario 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: fc5c519ead869736aade060df4e05fcf95aa1911
4
+ data.tar.gz: 01567e7366ed7014f6cd30ba2e8e3e25e91432bd
5
+ SHA512:
6
+ metadata.gz: ad74600bdd1fc7b55f5894408d3dd813def3f9ad3284e4ea495934cf25fba756df38d2b5fd0cd8f0536ed06285d856df290e676edf0fed687729aeefa8420a58
7
+ data.tar.gz: 0fe9a970a7b9c46a870c50dd7a57cfa92b5f1194684e2d53122b957cf01ebf68743e7c310065abe43d0ab568afd40d45783ab2cbc49072318f4258c48baebed1
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
@@ -0,0 +1,4 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.1.5
4
+ before_install: gem install bundler -v 1.10.6
@@ -0,0 +1,13 @@
1
+ # Contributor Code of Conduct
2
+
3
+ As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
4
+
5
+ We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, ethnicity, age, or religion.
6
+
7
+ Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.
8
+
9
+ Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team.
10
+
11
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
12
+
13
+ This Code of Conduct is adapted from the [Contributor Covenant](http://contributor-covenant.org), version 1.0.0, available at [http://contributor-covenant.org/version/1/0/0/](http://contributor-covenant.org/version/1/0/0/)
data/Gemfile ADDED
@@ -0,0 +1,7 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gem 'file-monitor'
4
+ gem 'osdb'
5
+ gem 'awesome_print'
6
+ # Specify your gem's dependencies in legendario.gemspec
7
+ gemspec
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 Evandro Junior
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,41 @@
1
+ # Legendario
2
+
3
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/legendario`. To experiment with that code, run `bin/console` for an interactive prompt.
4
+
5
+ TODO: Delete this and the text above, and describe your gem
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'legendario'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install legendario
22
+
23
+ ## Usage
24
+
25
+ TODO: Write usage instructions here
26
+
27
+ ## Development
28
+
29
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
30
+
31
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
32
+
33
+ ## Contributing
34
+
35
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/legendario. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](contributor-covenant.org) code of conduct.
36
+
37
+
38
+ ## License
39
+
40
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
41
+
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "legendario"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
@@ -0,0 +1,7 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+
5
+ bundle install
6
+
7
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,55 @@
1
+ #!/usr/bin/env ruby
2
+ require 'find'
3
+
4
+ d = "/home/j/Downloads"
5
+ lang=[]
6
+ lang=["eng", "por", "spa", "ger"]
7
+ lang.each do |l|
8
+ puts "Language: #{l}"
9
+ c = "getsub -aLl #{l} #{d}"
10
+ puts c
11
+ o = `#{c}`
12
+ puts o
13
+ r = $?.to_i
14
+ puts r
15
+ end
16
+
17
+ total_size = 0
18
+ total_files = 0
19
+
20
+ Find.find(d) do |path|
21
+ if FileTest.directory?(path)
22
+ if File.basename(path)[0] == ?.
23
+ Find.prune # Don't look any further into this directory.
24
+ else
25
+ next
26
+ end
27
+ else
28
+ if FileTest.symlink?(path)
29
+ c = "rm \"#{path}\""
30
+ puts c
31
+ o = `#{c}`
32
+ puts o
33
+ r = $?.to_i
34
+ puts r
35
+ end
36
+ lang.each do |l|
37
+ if /\.#{l}\.srt$/i =~ File.basename(path)
38
+ puts path
39
+ link = path.sub(/\.#{l}\.srt$/i, '.srt')
40
+ puts link
41
+ c = "ln -s \"#{path}\" \"#{link}\""
42
+ puts c
43
+ o = `#{c}`
44
+ puts o
45
+ r = $?.to_i
46
+ puts r
47
+ total_files +=1
48
+ total_size += FileTest.size(path)
49
+ break
50
+ end
51
+ end
52
+ end
53
+ end
54
+
55
+ puts "Total of files linked: #{total_files} Total of file size of linked files: #{total_size}"
@@ -0,0 +1,36 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'legendario/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "legendario"
8
+ spec.version = Legendario::VERSION
9
+ spec.authors = ["Evandro Junior"]
10
+ spec.email = ["evandrojr@gmail.com"]
11
+ spec.summary = %q{Subtitles downloader on demmand.}
12
+ spec.description = %q{The script downloads subtitle when a new movie arrives to a specific folder.}
13
+ spec.homepage = "https://github.com/evandrojr/legendario"
14
+ spec.license = "MIT"
15
+
16
+ # Prevent pushing this gem to RubyGems.org by setting 'allowed_push_host', or
17
+ # delete this section to allow pushing this gem to any host.
18
+ if spec.respond_to?(:metadata)
19
+ spec.metadata['allowed_push_host'] = "https://rubygems.org"
20
+ else
21
+ raise "RubyGems 2.0 or newer is required to protect against public gem pushes."
22
+ end
23
+
24
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
25
+ # spec.bindir = "exe"
26
+ spec.bindir = "lib"
27
+
28
+
29
+ # spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
30
+ spec.executables = ["legendario.rb"]
31
+ spec.require_paths = ["lib"]
32
+
33
+ spec.add_development_dependency "bundler", "~> 1.10"
34
+ spec.add_development_dependency "rake", "~> 10.0"
35
+ spec.add_development_dependency "rspec"
36
+ end
@@ -0,0 +1,94 @@
1
+ #!/usr/bin/env ruby
2
+ # coding: utf-8
3
+
4
+ require 'rubygems'
5
+ require 'awesome_print'
6
+ require 'file-monitor'
7
+ require 'find'
8
+
9
+ lib_dir = File.join File.dirname(__FILE__), '../lib'
10
+ $:.unshift lib_dir unless $:.include? lib_dir
11
+
12
+ class Legendario
13
+ @dir = "/home/j/Downloads"
14
+ def lang
15
+ []
16
+ ["eng", "por", "spa", "ger"]
17
+ # ["eng"]
18
+ end
19
+
20
+ def self.watch
21
+ Legendario.new.watch_dirs(@dir)
22
+ end
23
+
24
+ def se(command)
25
+ puts command
26
+ o = `#{command}`
27
+ r = $?.to_i
28
+ puts "#{o} #{r}"
29
+ r
30
+ end
31
+
32
+ def download_subs(file)
33
+ lang().each do |l|
34
+ puts "Language: #{l}"
35
+ se("getsub -aLl #{l} \"#{file}\"")
36
+ end
37
+ symlink(File.dirname(file))
38
+ end
39
+
40
+ def symlink(dir)
41
+ Find.find(dir) do |path|
42
+ if FileTest.directory?(path)
43
+ if File.basename(path)[0] == ?.
44
+ Find.prune # Don't look any further into this directory.
45
+ else
46
+ next
47
+ end
48
+ else
49
+ if FileTest.symlink?(path)
50
+ se("rm \"#{path}\"")
51
+ end
52
+ symlinked = false
53
+ lang().each do |l|
54
+ if /\.#{l}\.srt$/i =~ File.basename(path) and !symlinked
55
+ puts path
56
+ link = path.sub(/\.#{l}\.srt$/i, '.srt')
57
+ puts link
58
+ symlinked = true
59
+ se("ln -s \"#{path}\" \"#{link}\"")
60
+ break #this break is not working so using !symlinked
61
+ end
62
+ end
63
+ end
64
+ end
65
+ end
66
+
67
+ def watch_dirs(dir)
68
+ FileMonitor.watch dir do
69
+ dirs {
70
+ disallow /\.git$/
71
+ }
72
+
73
+ files {
74
+ disallow /.*/
75
+ allow /\.mkv$|\.mp4$|\.avi$/
76
+ }
77
+ begin
78
+ exec do |events|
79
+ events.each do |ev|
80
+ file = File.join(ev.watcher.path(), ev.name())
81
+ puts file
82
+ Legendario.new.download_subs(file)
83
+ end
84
+ end
85
+ #Avoids breaking after a directory been deleted
86
+ rescue => error
87
+ puts("#{error.class} and #{error.message}")
88
+ Legendario.watch
89
+ end
90
+ end
91
+ end
92
+ end
93
+
94
+ Legendario.watch
@@ -0,0 +1,96 @@
1
+ # coding: utf-8
2
+ require "legendario/version"
3
+ require 'rubygems'
4
+ require 'file-monitor'
5
+ require 'find'
6
+
7
+ module Legendario
8
+
9
+ lib_dir = File.join File.dirname(__FILE__), '../lib'
10
+ $:.unshift lib_dir unless $:.include? lib_dir
11
+
12
+ class Legendario
13
+ @dir = "/home/j/Downloads"
14
+ def lang
15
+ []
16
+ ["eng", "por", "spa", "ger"]
17
+ # ["eng"]
18
+ end
19
+
20
+ def self.watch
21
+ Legendario.new.watch_dirs(@dir)
22
+ end
23
+
24
+ def se(command)
25
+ puts command
26
+ o = `#{command}`
27
+ r = $?.to_i
28
+ puts "#{o} #{r}"
29
+ r
30
+ end
31
+
32
+ def download_subs(file)
33
+ lang().each do |l|
34
+ puts "Language: #{l}"
35
+ se("getsub -aLl #{l} \"#{file}\"")
36
+ end
37
+ symlink(File.dirname(file))
38
+ end
39
+
40
+ def symlink(dir)
41
+ Find.find(dir) do |path|
42
+ if FileTest.directory?(path)
43
+ if File.basename(path)[0] == ?.
44
+ Find.prune # Don't look any further into this directory.
45
+ else
46
+ next
47
+ end
48
+ else
49
+ if FileTest.symlink?(path)
50
+ se("rm \"#{path}\"")
51
+ end
52
+ symlinked = false
53
+ lang().each do |l|
54
+ if /\.#{l}\.srt$/i =~ File.basename(path) and !symlinked
55
+ puts path
56
+ link = path.sub(/\.#{l}\.srt$/i, '.srt')
57
+ puts link
58
+ symlinked = true
59
+ se("ln -s \"#{path}\" \"#{link}\"")
60
+ break #this break is not working so using !symlinked
61
+ end
62
+ end
63
+ end
64
+ end
65
+ end
66
+
67
+ def watch_dirs(dir)
68
+ FileMonitor.watch dir do
69
+ dirs {
70
+ disallow /\.git$/
71
+ }
72
+
73
+ files {
74
+ disallow /.*/
75
+ allow /\.mkv$|\.mp4$|\.avi$/
76
+ }
77
+ begin
78
+ exec do |events|
79
+ events.each do |ev|
80
+ file = File.join(ev.watcher.path(), ev.name())
81
+ puts file
82
+ Legendario.new.download_subs(file)
83
+ end
84
+ end
85
+ #Avoids breaking after a directory been deleted
86
+ rescue => error
87
+ puts("#{error.class} and #{error.message}")
88
+ Legendario.watch
89
+ end
90
+ end
91
+ end
92
+ end
93
+
94
+ Legendario.watch
95
+
96
+ end
@@ -0,0 +1,3 @@
1
+ module Legendario
2
+ VERSION = "0.1.0"
3
+ end
metadata ADDED
@@ -0,0 +1,105 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: legendario
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Evandro Junior
8
+ autorequire:
9
+ bindir: lib
10
+ cert_chain: []
11
+ date: 2015-11-10 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.10'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.10'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ description: The script downloads subtitle when a new movie arrives to a specific
56
+ folder.
57
+ email:
58
+ - evandrojr@gmail.com
59
+ executables:
60
+ - legendario.rb
61
+ extensions: []
62
+ extra_rdoc_files: []
63
+ files:
64
+ - ".gitignore"
65
+ - ".rspec"
66
+ - ".travis.yml"
67
+ - CODE_OF_CONDUCT.md
68
+ - Gemfile
69
+ - LICENSE.txt
70
+ - README.md
71
+ - Rakefile
72
+ - bin/console
73
+ - bin/setup
74
+ - get_all_subtitles.rb
75
+ - legendario.gemspec
76
+ - legendario.rb
77
+ - lib/legendario.rb
78
+ - lib/legendario/version.rb
79
+ homepage: https://github.com/evandrojr/legendario
80
+ licenses:
81
+ - MIT
82
+ metadata:
83
+ allowed_push_host: https://rubygems.org
84
+ post_install_message:
85
+ rdoc_options: []
86
+ require_paths:
87
+ - lib
88
+ required_ruby_version: !ruby/object:Gem::Requirement
89
+ requirements:
90
+ - - ">="
91
+ - !ruby/object:Gem::Version
92
+ version: '0'
93
+ required_rubygems_version: !ruby/object:Gem::Requirement
94
+ requirements:
95
+ - - ">="
96
+ - !ruby/object:Gem::Version
97
+ version: '0'
98
+ requirements: []
99
+ rubyforge_project:
100
+ rubygems_version: 2.2.2
101
+ signing_key:
102
+ specification_version: 4
103
+ summary: Subtitles downloader on demmand.
104
+ test_files: []
105
+ has_rdoc: