mpeghelper 1.2.1 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (5) hide show
  1. data/Rakefile +20 -49
  2. data/lib/mpeghelper.rb +109 -4
  3. data/mpeghelper.gemspec +1 -6
  4. data/version.yml +2 -2
  5. metadata +1 -1
data/Rakefile CHANGED
@@ -1,56 +1,27 @@
1
1
  require 'rubygems'
2
- require 'rake'
2
+ require 'rake/gempackagetask'
3
3
 
4
- begin
5
- require 'jeweler'
6
- Jeweler::Tasks.new do |gem|
7
- gem.name = "mpeghelper"
8
- gem.summary = "RubyGem for converting, editing and striping mp3's and mp4's"
9
- gem.description = "RubyGem for converting, editing and striping mp3's and mp4's"
10
- gem.email = "alexbarlowis@me.com"
11
- gem.homepage = "http://github.com/arbarlow/mpeghelper"
12
- gem.authors = ["Alex Barlow"]
13
- #gem.add_development_dependency "thoughtbot-shoulda"
14
- # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
15
- end
16
- rescue LoadError
17
- puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
18
- end
4
+ Gem::Manage_gems
19
5
 
20
- require 'rake/testtask'
21
- Rake::TestTask.new(:test) do |test|
22
- test.libs << 'lib' << 'test'
23
- test.pattern = 'test/**/*_test.rb'
24
- test.verbose = true
6
+ spec = Gem::Specification.new do |s|
7
+ s.platform = Gem::Platform::RUBY
8
+ s.name = "MpegHelper"
9
+ s.version = "1.0.0"
10
+ s.author = "Alex Barlow"
11
+ s.email = "alexbarlowis@me.com"
12
+ s.summary = "RubyGem for converting, editing and striping mp3's and mp4's"
13
+ s.files = FileList['lib/*.rb', 'test/*'].to_a
14
+ s.require_path = "lib"
15
+ s.autorequire = "mpeghelper"
16
+ s.test_files = Dir.glob('tests/*.rb')
17
+ s.has_rdoc = true
18
+ s.extra_rdoc_files = ["README"]
25
19
  end
26
20
 
27
- begin
28
- require 'rcov/rcovtask'
29
- Rcov::RcovTask.new do |test|
30
- test.libs << 'test'
31
- test.pattern = 'test/**/*_test.rb'
32
- test.verbose = true
33
- end
34
- rescue LoadError
35
- task :rcov do
36
- abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
37
- end
21
+ Rake::GemPackageTask.new(spec) do |pkg|
22
+ pkg.need_tar = true
38
23
  end
39
24
 
40
- task :test => :check_dependencies
41
-
42
- task :default => :test
43
-
44
- require 'rake/rdoctask'
45
- Rake::RDocTask.new do |rdoc|
46
- if File.exist?('VERSION')
47
- version = File.read('VERSION')
48
- else
49
- version = ""
50
- end
51
-
52
- rdoc.rdoc_dir = 'rdoc'
53
- rdoc.title = "mpeghelper #{version}"
54
- rdoc.rdoc_files.include('README*')
55
- rdoc.rdoc_files.include('lib/**/*.rb')
56
- end
25
+ task :default => "pkg/#{spec.name}-#{spec.version}.gem" do
26
+ puts "generated latest version"
27
+ end
data/lib/mpeghelper.rb CHANGED
@@ -71,7 +71,112 @@ class MpegHelper
71
71
  end
72
72
  end
73
73
  end
74
+
75
+ def self.mp3_artwork_output(file, output, bitrate, covername, sizes)
74
76
 
77
+ Mp3Info.open(file) do |mp3|
78
+
79
+ if mp3.bitrate == bitrate.to_i
80
+
81
+ song = {}
82
+ song['artist'] = mp3.tag.artist
83
+ song['album'] = mp3.tag.album
84
+ song['title'] = mp3.tag.title
85
+ song['track_no'] = mp3.tag.tracknum
86
+ song['audio_bitrate'] = mp3.bitrate
87
+ song['audio_length'] = mp3.length
88
+ song['audio_file_name'] = file
89
+ song['audio_file_size'] = File.size(file)
90
+ song['audio_content_type'] = "audio/mpeg"
91
+
92
+ `eyeD3 -i ./ #{file}`
93
+
94
+ Dir.foreach("./") do |cover|
95
+ if cover =~ /.*\.jpeg$/
96
+ @covername = cover
97
+ elsif cover =~ /.*\.png$/
98
+ @covername = cover
99
+ elsif cover =~ /.*\.gif$/
100
+ @covername = cover
101
+ elsif cover =~ /.*\.jpg$/
102
+ @covername = cover
103
+ end
104
+ end
105
+
106
+ cover = Magick::ImageList.new(@covername)
107
+ cover.resize_to_fill!(500, 500)
108
+ cover.write(@covername)
109
+
110
+ count = 0
111
+ song['covers'] = []
112
+
113
+ sizes.each do |width, height|
114
+ cover = Magick::ImageList.new(@covername)
115
+ cover.resize_to_fill!(width, height)
116
+ cover.write("#{width}x#{height}-#{covername}")
117
+ song['covers'] << "#{width}x#{height}-#{covername}"
118
+ end
119
+
120
+ return song
121
+
122
+ else
123
+
124
+ `eyeD3 -i ./ #{file}`
125
+
126
+ Dir.foreach("./") do |cover|
127
+ if cover =~ /.*\.jpeg$/
128
+ @covername = cover
129
+ elsif cover =~ /.*\.png$/
130
+ @covername = cover
131
+ elsif cover =~ /.*\.gif$/
132
+ @covername = cover
133
+ elsif cover =~ /.*\.jpg$/
134
+ @covername = cover
135
+ end
136
+ end
137
+
138
+ cover = Magick::ImageList.new(@covername)
139
+ cover.resize_to_fill!(500, 500)
140
+ cover.write(@covername)
141
+
142
+ `lame -b #{bitrate} #{file} #{output} --ti #{@covername}`
143
+
144
+ FileUtils.mv @covername, covername
145
+
146
+ song = {}
147
+ song['artist'] = mp3.tag.artist
148
+ song['album'] = mp3.tag.album
149
+ song['title'] = mp3.tag.title
150
+ song['track_no'] = mp3.tag.tracknum
151
+ song['audio_bitrate'] = bitrate
152
+ song['audio_length'] = mp3.length
153
+ song['audio_file_name'] = output
154
+ song['audio_file_size'] = File.size(output)
155
+ song['audio_content_type'] = "audio/mpeg"
156
+
157
+ FileUtils.remove_file file
158
+
159
+ Mp3Info.open(output) do |mp3|
160
+ mp3.tag.artist = song['artist']
161
+ mp3.tag.album = song['album']
162
+ mp3.tag.title = song['title']
163
+ mp3.tag.tracknum = song['track_no']
164
+ end
165
+
166
+ count = 0
167
+ @song['covers'] = []
168
+
169
+ sizes.each do |width, height|
170
+ cover = Magick::ImageList.new(covername)
171
+ cover.resize_to_fill!(width, height)
172
+ cover.write("#{width}x#{height}-#{covername}")
173
+ @song['covers'] << "#{width}x#{height}-#{covername}"
174
+ end
175
+
176
+ FileUtils.remove_file covername
177
+
178
+ return song
179
+ end
75
180
 
76
181
  def self.mp4_to_mp3(file, output, bitrate)
77
182
 
@@ -180,7 +285,7 @@ class MpegHelper
180
285
  return @song
181
286
  end
182
287
 
183
- end
184
-
185
-
186
-
288
+ def self.crop(input, output, fromtime, totime)
289
+ `mp3splt #{input} #{input} #{output} -o #{output}`
290
+ end
291
+ end
data/mpeghelper.gemspec CHANGED
@@ -1,11 +1,6 @@
1
- # Generated by jeweler
2
- # DO NOT EDIT THIS FILE
3
- # Instead, edit Jeweler::Tasks in Rakefile, and run `rake gemspec`
4
- # -*- encoding: utf-8 -*-
5
-
6
1
  Gem::Specification.new do |s|
7
2
  s.name = %q{mpeghelper}
8
- s.version = "1.2.1"
3
+ s.version = "1.3.0"
9
4
 
10
5
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
6
  s.authors = ["Alex Barlow"]
data/version.yml CHANGED
@@ -1,4 +1,4 @@
1
1
  ---
2
- :patch: 1
3
2
  :major: 1
4
- :minor: 2
3
+ :minor: 3
4
+ :patch: 0
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mpeghelper
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.1
4
+ version: 1.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alex Barlow