trackduration 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. data/lib/trackduration.rb +12 -4
  2. metadata +1 -1
data/lib/trackduration.rb CHANGED
@@ -1,8 +1,16 @@
1
1
  class Trackduration
2
2
  def self.get_duration(inputfile)
3
- system("ffmpeg -i '#{inputfile}' 2>&1 | grep Duration > duration")
4
- duration = File.open("duration","r").read.split(" ")[1].gsub(",",'')
5
- File.delete("duration")
6
- duration
3
+ if File.exists?(inputfile)
4
+ begin
5
+ system("ffmpeg -i '#{inputfile}' 2>&1 | grep Duration > duration")
6
+ duration = File.open("duration","r").read.split(" ")[1].gsub(",",'')
7
+ File.delete("duration")
8
+ duration
9
+ rescue Exception=>e
10
+ puts "#{e.massage}"
11
+ end
12
+ else
13
+ puts "#{inputfile} doesn't exist."
14
+ end
7
15
  end
8
16
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: trackduration
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: