Sha256: 7a5551ea391da57bb754022def0497ad3b4cc2c556eea111fde26864d962c6cf

Contents?: true

Size: 1.07 KB

Versions: 1

Compression:

Stored size: 1.07 KB

Contents

#!/usr/bin/env ruby

$LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__) + '/../lib')

require 'rest_client'
require 'mime/types'
require 'tempfile'
filename = ARGV[1]
basename =  File.basename(filename)

types = MIME::Types.type_for(filename)
valido = false
for i in types
    if i.content_type.include? "wav" or i.content_type.include? "x-wav"
        valido = true
    end
end

t = Tempfile.new(basename)

if !valido
    puts "convirtiendo a wav antes de subir"
    `rm -f "#{t.path}"`
    `ffmpeg -i "#{filename}" -vn -acodec pcm_s16le -ar 16000 -ac 1 -f wav "#{t.path}"`
    filename = t.path
end


file = File.new(ARGV[1])
public = false
if ARGV.size >= 3
    public = ARGV[2]
end

puts "uploading..."


begin
    RestClient.post('http://cluster.metaforas.cl/audios',
      "audio[audio_original]" => File.new(filename),
      :api => ARGV[0], "audio[public]" => public )
rescue
    RestClient.post('http://cluster.metaforas.cl:8000/audios',
          "audio[audio_original]" => File.new(filename),
          :api => ARGV[0], "audio[public]" => public)

end


t.close


puts "ready"

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
fonemas-0.4.12 bin/audioupload