trackduration 0.0.1 → 0.0.2

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.
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: