YoutubeTools 0.0.2 → 0.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.2
1
+ 0.0.3
data/YoutubeTools.gemspec CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{YoutubeTools}
8
- s.version = "0.0.2"
8
+ s.version = "0.0.3"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Maykon Luis Capellari"]
@@ -1,18 +1,30 @@
1
1
  module YoutubeTools
2
2
  class Converter
3
- attr_accessor :file, :folder, :file_name
3
+ attr_accessor :file, :folder, :file_name, :format
4
4
 
5
- def initialize(file, path=nil)
6
- @folder = path.nil? ? FOLDER_PATH : path
5
+ def initialize(file, options={})
6
+ @folder = options[:path].nil? ? FOLDER_PATH : options[:path]
7
+ @format = options[:format].nil? ? :mp3 : options[:format]
7
8
 
8
9
  @file = "#{@folder}/#{file}"
9
- converter_to
10
+
11
+ converter_to(@format)
10
12
  end
11
13
 
12
14
  protected
13
15
  def converter_to(format=:mp3)
14
- @file_name = "#{@file}.#{format}"
15
- system "ffmpeg -i #{@file} -ab 128k -ac 2 -acodec libmp3lame -vn -y #{@file_name}"
16
+ @file_name = "#{@file}.#{format}"
17
+
18
+ case format
19
+ when :avi
20
+ system "ffmpeg -i #{@file} -ab 56 -ar 22050 -b 500 -s 320x240 -vcodec xvid -acodec mp3 #{@file_name}"
21
+ when :mp4
22
+ system "ffmpeg -i #{@file} -ar 22050 #{@file_name}"
23
+ when :mpg
24
+ system "ffmpeg -i #{@file} -ab 56 -ar 22050 -b 500 -s 320x240 #{@file_name}"
25
+ else
26
+ system "ffmpeg -i #{@file} -ab 128k -ac 2 -acodec libmp3lame -vn -y #{@file_name}"
27
+ end
16
28
  system "rm -Rf #{@file}" if File.exist? @file
17
29
  end
18
30
  end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 0
8
- - 2
9
- version: 0.0.2
8
+ - 3
9
+ version: 0.0.3
10
10
  platform: ruby
11
11
  authors:
12
12
  - Maykon Luis Capellari