suby 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/lib/suby.rb +15 -5
  2. data/suby.gemspec +2 -1
  3. metadata +18 -2
@@ -1,5 +1,6 @@
1
1
  require 'path'
2
2
  require 'zip/zip'
3
+ require 'mime/types'
3
4
 
4
5
  Path.require_tree 'suby', except: %w[downloader/]
5
6
 
@@ -16,14 +17,23 @@ module Suby
16
17
  def download_subtitles(files, options = {})
17
18
  files.each { |file|
18
19
  file = Path(file)
19
- next if file.directory? or SUB_EXTENSIONS.include?(file.ext)
20
- next puts "Skipping: #{file}" if SUB_EXTENSIONS.any? { |ext|
21
- f = file.sub_ext(ext) and f.exist? and !f.empty?
22
- }
23
- download_subtitles_for_file(file, options)
20
+ if file.dir?
21
+ download_subtitles(file.children, options)
22
+ elsif SUB_EXTENSIONS.include?(file.ext)
23
+ # ignore already downloaded subtitles
24
+ elsif SUB_EXTENSIONS.any? { |ext| f = file.sub_ext(ext) and f.exist? and !f.empty? }
25
+ puts "Skipping: #{file}"
26
+ elsif !file.exist? or video?(file)
27
+ download_subtitles_for_file(file, options)
28
+ end
24
29
  }
25
30
  end
26
31
 
32
+ def video?(file)
33
+ type = MIME::Types.type_for(file.path).first
34
+ type and type.media_type == "video"
35
+ end
36
+
27
37
  def download_subtitles_for_file(file, options)
28
38
  begin
29
39
  show, season, episode = FilenameParser.parse(file)
@@ -14,6 +14,7 @@ Gem::Specification.new do |s|
14
14
  s.add_dependency 'nokogiri'
15
15
  s.add_dependency 'rubyzip'
16
16
  s.add_dependency 'term-ansicolor'
17
+ s.add_dependency 'mime-types', '>= 1.19'
17
18
 
18
- s.version = '0.2.0'
19
+ s.version = '0.3.0'
19
20
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: suby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-07-19 00:00:00.000000000 Z
12
+ date: 2012-08-02 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: path
@@ -75,6 +75,22 @@ dependencies:
75
75
  - - ! '>='
76
76
  - !ruby/object:Gem::Version
77
77
  version: '0'
78
+ - !ruby/object:Gem::Dependency
79
+ name: mime-types
80
+ requirement: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ! '>='
84
+ - !ruby/object:Gem::Version
85
+ version: '1.19'
86
+ type: :runtime
87
+ prerelease: false
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ! '>='
92
+ - !ruby/object:Gem::Version
93
+ version: '1.19'
78
94
  description: Find and download subtitles
79
95
  email: eregontp@gmail.com
80
96
  executables: