lib/happyscribe.rb in happyscribe-1.0.0 vs lib/happyscribe.rb in happyscribe-1.0.1
- old
+ new
@@ -1,7 +1,8 @@
require "happyscribe/version"
require 'net/http'
+require "open-uri"
require 'uri'
require 'json'
require "securerandom"
module Happyscribe
class Error < StandardError; end
@@ -64,11 +65,11 @@
response = Net::HTTP.start(uri.hostname, uri.port, req_options) do |http|
http.request(request)
end
return JSON.parse(response.body)
end
- def create_export(id,format="html",timestamps=false,speakers=false,comments=false,highlights=false)
+ def create_export(id,format="txt",timestamps=false,speakers=false,comments=false,highlights=false)
uri = URI.parse("#{@base}/exports")
request = Net::HTTP::Post.new(uri)
request.content_type = "application/json"
request["Authorization"] = @auth
request.body = JSON.dump({
@@ -105,8 +106,23 @@
response = Net::HTTP.start(uri.hostname, uri.port, req_options) do |http|
http.request(request)
end
return JSON.parse response.body
+ end
+ def export_in_txt(export_id)
+ export = create_export(export_id,"txt")["id"]
+ sleep(5)
+ while true
+ retrieved = retrieve_export(export)
+ if(retrieved["state"]=="ready")
+ break
+ else
+ sleep(2)
+ end
+ end
+ txt = URI.parse(retrieved["download_link"]).open.read.force_encoding("utf-8")
+ return txt
+
end
end
end