cielo24 0.0.4 → 0.0.5

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.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 5b09cd26328c50d779c3a5ad4bcdab2a0c0d7d93
4
+ data.tar.gz: 2527d71d3ba675dc9e42e4a2e4e8d96dfd944d8b
5
+ SHA512:
6
+ metadata.gz: 7491fc76d01f2e77bd739a2db280630f3f8c1b66aa07f6c7b6338dbd25b0b677829d22433fe6db99030aa83c88898e6fa49f1ad75a701f9528b883ad0357ae5e
7
+ data.tar.gz: 71b71029d04d55cb73491240ce81e1bcb69d9d4c0f4f092cf3055206bab5403277c2efc4f6e8380efab42f14e57b2e53f8209eafaec7c83ee3fcc650d287e256
data/lib/cielo24.rb ADDED
@@ -0,0 +1,11 @@
1
+ require 'cielo24/version'
2
+ require 'cielo24/actions'
3
+ require 'cielo24/enums'
4
+ require 'cielo24/options'
5
+ require 'cielo24/web_utils'
6
+
7
+ require 'hashie'
8
+ require 'httpclient'
9
+
10
+ module Cielo24
11
+ end
@@ -0,0 +1,258 @@
1
+ module Cielo24
2
+ class Actions
3
+
4
+ require 'uri'
5
+ require 'hashie'
6
+ require_relative 'web_utils'
7
+ require_relative 'enums'
8
+ include Errno
9
+ include Hashie
10
+ include Cielo24
11
+
12
+ attr_accessor :base_url
13
+
14
+ VERSION = 1
15
+
16
+ LOGIN_PATH = "/api/account/login"
17
+ LOGOUT_PATH = "/api/account/logout"
18
+ UPDATE_PASSWORD_PATH = "/api/account/update_password"
19
+ GENERATE_API_KEY_PATH = "/api/account/generate_api_key"
20
+ REMOVE_API_KEY_PATH = "/api/account/remove_api_key"
21
+ CREATE_JOB_PATH = "/api/job/new"
22
+ AUTHORIZE_JOB_PATH = "/api/job/authorize"
23
+ DELETE_JOB_PATH = "/api/job/del"
24
+ GET_JOB_INFO_PATH = "/api/job/info"
25
+ GET_JOB_LIST_PATH = "/api/job/list"
26
+ ADD_MEDIA_TO_JOB_PATH = "/api/job/add_media"
27
+ ADD_EMBEDDED_MEDIA_TO_JOB_PATH = "/api/job/add_media_url"
28
+ GET_MEDIA_PATH = "/api/job/media"
29
+ PERFORM_TRANSCRIPTION = "/api/job/perform_transcription"
30
+ GET_TRANSCRIPTION_PATH = "/api/job/get_transcript"
31
+ GET_CAPTION_PATH = "/api/job/get_caption"
32
+ GET_ELEMENT_LIST_PATH = "/api/job/get_elementlist"
33
+ GET_LIST_OF_ELEMENT_LISTS_PATH = "/api/job/list_elementlists"
34
+
35
+ def initialize(base_url="https://sandbox-dev.cielo24.com")
36
+ @base_url = base_url
37
+ end
38
+
39
+ ### ACCESS CONTROL ###
40
+
41
+ def login(username, password=nil, api_securekey=nil, use_headers=false)
42
+ assert_argument(username, "Username")
43
+ # Password or API Secure Key must be supplied but not both
44
+ raise ArgumentError.new("Only password or API secure must be supplied for login.") if (!password.nil? and !api_securekey.nil?)
45
+ raise ArgumentError.new("Password or API secure must be supplied for login.") if (password.nil? and api_securekey.nil?)
46
+
47
+ query_hash = init_version_dict
48
+ headers = Hash.new
49
+
50
+ if use_headers
51
+ query_hash[:username] = username
52
+ query_hash[:password] = password if (!password.nil?)
53
+ query_hash[:securekey] = api_securekey if (!api_securekey.nil?)
54
+ else
55
+ headers[:'x-auth-user'] = username
56
+ headers[:'x-auth-key'] = password if (!password.nil?)
57
+ headers[:'x-auth-securekey'] = api_securekey if (!api_securekey.nil?)
58
+ end
59
+
60
+ json = WebUtils.get_json(@base_url + LOGIN_PATH, 'GET', WebUtils::BASIC_TIMEOUT, query_hash, headers)
61
+ return json["ApiToken"]
62
+ end
63
+
64
+ def logout(api_token)
65
+ query_hash = init_access_req_dict(api_token)
66
+
67
+ # Nothing returned
68
+ WebUtils.http_request(@base_url + LOGOUT_PATH, 'GET', WebUtils::BASIC_TIMEOUT, query_hash)
69
+ end
70
+
71
+ def update_password(api_token, new_password)
72
+ assert_argument(new_password, "New Password")
73
+ query_hash = init_access_req_dict(api_token)
74
+ query_hash[:new_password] = new_password
75
+
76
+ # Nothing returned
77
+ WebUtils.http_request(@base_url + UPDATE_PASSWORD_PATH, 'POST', WebUtils::BASIC_TIMEOUT, nil, nil, query_hash)
78
+ end
79
+
80
+ def generate_api_key(api_token, username, force_new = false)
81
+ assert_argument(username, "Username")
82
+ assert_argument(api_token, "API Token")
83
+ query_hash = init_access_req_dict(api_token)
84
+ query_hash[:account_id] = username
85
+ query_hash[:force_new] = force_new
86
+
87
+ json = WebUtils.get_json(@base_url + GENERATE_API_KEY_PATH, 'GET', WebUtils::BASIC_TIMEOUT, query_hash)
88
+ return json["ApiKey"]
89
+ end
90
+
91
+ def remove_api_key(api_token, api_securekey)
92
+ query_hash = init_access_req_dict(api_token)
93
+ query_hash[:api_securekey] = api_securekey
94
+
95
+ # Nothing returned
96
+ WebUtils.http_request(@base_url + REMOVE_API_KEY_PATH, 'GET', WebUtils::BASIC_TIMEOUT, query_hash)
97
+ end
98
+
99
+ ### JOB CONTROL ###
100
+
101
+ def create_job(api_token, job_name = nil, source_language = "en")
102
+ query_hash = init_access_req_dict(api_token)
103
+ query_hash[:job_name] = job_name if !(job_name.nil?)
104
+ query_hash[:source_language] = source_language
105
+
106
+ json = WebUtils.get_json(@base_url + CREATE_JOB_PATH, 'GET', WebUtils::BASIC_TIMEOUT, query_hash)
107
+ # Return a hash with JobId and TaskId
108
+ return Mash.new(json)
109
+ end
110
+
111
+ def authorize_job(api_token, job_id)
112
+ query_hash = init_job_req_dict(api_token, job_id)
113
+
114
+ # Nothing returned
115
+ WebUtils.http_request(@base_url + AUTHORIZE_JOB_PATH, 'GET', WebUtils::BASIC_TIMEOUT, query_hash)
116
+ end
117
+
118
+ def delete_job(api_token, job_id)
119
+ query_hash = init_job_req_dict(api_token, job_id)
120
+
121
+ json = WebUtils.get_json(@base_url + DELETE_JOB_PATH, 'GET', WebUtils::BASIC_TIMEOUT, query_hash)
122
+ return json["TaskId"]
123
+ end
124
+
125
+ def get_job_info(api_token, job_id)
126
+ query_hash = init_job_req_dict(api_token, job_id)
127
+
128
+ json = WebUtils.get_json(@base_url + GET_JOB_INFO_PATH, 'GET', WebUtils::BASIC_TIMEOUT, query_hash)
129
+ # TODO: JobInfo
130
+ return Mash.new(json)
131
+ end
132
+
133
+ def get_job_list(api_token)
134
+ query_hash = init_access_req_dict(api_token)
135
+
136
+ json = WebUtils.get_json(@base_url + GET_JOB_LIST_PATH, 'GET', WebUtils::BASIC_TIMEOUT, query_hash)
137
+ # TODO: JobList
138
+ return Mash.new(json)
139
+ end
140
+
141
+ def add_media_to_job_file(api_token, job_id, media_file)
142
+ assert_argument(media_file, "Media File")
143
+ query_hash = init_job_req_dict(api_token, job_id)
144
+
145
+ json = WebUtils.get_json(@base_url + ADD_MEDIA_TO_JOB_PATH, 'POST', nil, query_hash, {"Content-Type" => "video/mp4"}, {"upload" => media_file})
146
+ return json["TaskId"]
147
+ end
148
+
149
+ def add_media_to_job_url(api_token, job_id, media_url)
150
+ return send_media_url(api_token, job_id, media_url, ADD_MEDIA_TO_JOB_PATH);
151
+ end
152
+
153
+ def add_media_to_job_embedded(api_token, job_id, media_url)
154
+ return send_media_url(api_token, job_id, media_url, ADD_EMBEDDED_MEDIA_TO_JOB_PATH);
155
+ end
156
+
157
+ def send_media_url(api_token, job_id, media_url, path)
158
+ assert_argument(media_url, "Media URL")
159
+ query_hash = init_job_req_dict(api_token, job_id)
160
+ query_hash[:media_url] = URI.escape(media_url)
161
+
162
+ json = WebUtils.get_json(@base_url + path, 'GET', WebUtils::BASIC_TIMEOUT, query_hash)
163
+ return json["TaskId"]
164
+ end
165
+ private :send_media_url
166
+
167
+ def get_media(api_token, job_id)
168
+ query_hash = init_job_req_dict(api_token, job_id)
169
+
170
+ json = WebUtils.get_json(@base_url + GET_MEDIA_PATH, 'GET', WebUtils::BASIC_TIMEOUT, query_hash)
171
+
172
+ return json["MediaUrl"]
173
+ end
174
+
175
+ def perform_transcription(api_token,
176
+ job_id,
177
+ fidelity,
178
+ priority,
179
+ callback_uri = nil,
180
+ turnaround_hours = nil,
181
+ target_language = nil,
182
+ options = nil)
183
+ assert_argument(fidelity, "Fidelity")
184
+ assert_argument(priority, "Priority")
185
+ query_hash = init_job_req_dict(api_token, job_id)
186
+ query_hash[:transcription_fidelity] = fidelity
187
+ query_hash[:priority] = priority
188
+ query_hash[:callback_uri] = URI.escape(callback_uri) if !(callback_uri.nil?)
189
+ query_hash[:turnaround_hours] = turnaround_hours if !(turnaround_hours.nil?)
190
+ query_hash[:target_language] = target_language if !(target_language.nil?)
191
+ query_hash.merge(options.get_hash) if !(options.nil?)
192
+
193
+ json = WebUtils.get_json(@base_url + PERFORM_TRANSCRIPTION, 'GET', WebUtils::BASIC_TIMEOUT, query_hash)
194
+ return json["TaskId"]
195
+ end
196
+
197
+ def get_transcript(api_token, job_id, transcript_options = nil)
198
+ query_hash = init_job_req_dict(api_token, job_id)
199
+ query_hash.merge(transcript_options.get_hash) if !(transcript_options.nil?)
200
+
201
+ # Return raw transcript text
202
+ return WebUtils.http_request(@base_url + GET_TRANSCRIPTION_PATH, 'GET', WebUtils::DOWNLOAD_TIMEOUT, query_hash)
203
+ end
204
+
205
+ def get_caption(api_token, job_id, caption_format, caption_options = nil)
206
+ query_hash = init_job_req_dict(api_token, job_id)
207
+ query_hash[:caption_format] = caption_format
208
+ query_hash.merge(caption_options.get_hash) if !(caption_options.nil?)
209
+
210
+ response = WebUtils.http_request(@base_url + GET_CAPTION_PATH, 'GET', WebUtils::DOWNLOAD_TIMEOUT, query_hash)
211
+ if(!caption_options.nil? and caption_options[:build_url]) # If build_url is true
212
+ return JSON.parse(response)["CaptionUrl"]
213
+ else
214
+ return response # Else return raw caption text
215
+ end
216
+ end
217
+
218
+ def get_element_list(api_token, job_id)
219
+ query_hash = init_job_req_dict(api_token, job_id)
220
+
221
+ json = WebUtils.get_json(@base_url + GET_ELEMENT_LIST_PATH, 'GET', WebUtils::BASIC_TIMEOUT, query_hash)
222
+ # TODO: ElementList
223
+ return Mash.new(json)
224
+ end
225
+
226
+ def get_list_of_element_lists(api_token, job_id)
227
+ query_hash = init_job_req_dict(api_token, job_id)
228
+
229
+ response = WebUtils.http_request(@base_url + GET_LIST_OF_ELEMENT_LISTS_PATH, 'GET', WebUtils::BASIC_TIMEOUT, query_hash)
230
+ array = JSON.parse(response)
231
+ # TODO: List<ElementListVersion>
232
+ return array
233
+ end
234
+
235
+ ### PRIVATE HELPER METHODS ###
236
+ private
237
+
238
+ def init_job_req_dict(api_token, job_id)
239
+ assert_argument(job_id, "Job ID")
240
+ init_access_req_dict(api_token).merge({job_id: job_id})
241
+ end
242
+
243
+ def init_access_req_dict(api_token)
244
+ assert_argument(api_token, "API Token")
245
+ init_version_dict().merge({api_token: api_token})
246
+ end
247
+
248
+ def init_version_dict()
249
+ {v: VERSION}
250
+ end
251
+
252
+ def assert_argument(arg, arg_name)
253
+ if (arg.nil?)
254
+ raise ArgumentError.new("Invalid argument - " + arg_name)
255
+ end
256
+ end
257
+ end
258
+ end
@@ -0,0 +1,139 @@
1
+ module Cielo24
2
+ class TaskType < BasicObject
3
+ def self.JOB_CREATED; "JOB_CREATED"; end
4
+ def self.JOB_DELETED; "JOB_DELETED"; end
5
+ def self.JOB_ADD_MEDIA; "JOB_ADD_MEDIA"; end
6
+ def self.JOB_ADD_TRANSCRIPT; "JOB_ADD_TRANSCRIPT"; end
7
+ def self.JOB_PERFORM_TRANSCRIPTION; "JOB_PERFORM_TRANSCRIPTION"; end
8
+ def self.JOB_PERFORM_PREMIUM_SYNC; "JOB_PERFORM_PREMIUM_SYNC"; end
9
+ def self.JOB_REQUEST_TRANSCRIPT; "JOB_REQUEST_TRANSCRIPT"; end
10
+ def self.JOB_REQUEST_CAPTION; "JOB_REQUEST_CAPTION"; end
11
+ def self.JOB_REQUEST_ELEMENTLIST; "JOB_REQUEST_ELEMENTLIST"; end
12
+ end
13
+
14
+ class ErrorType < BasicObject
15
+ def self.LOGIN_INVALID; "LOGIN_INVALID"; end
16
+ def self.ACCOUNT_EXISTS; "ACCOUNT_EXISTS"; end
17
+ def self.ACCOUNT_UNPRIVILEGED; "ACCOUNT_UNPRIVILEGED"; end
18
+ def self.BAD_API_TOKEN; "BAD_API_TOKEN"; end
19
+ def self.INVALID_QUERY; "INVALID_QUERY"; end
20
+ def self.INVALID_OPTION; "INVALID_OPTION"; end
21
+ def self.MISSING_PARAMETER; "MISSING_PARAMETER"; end
22
+ def self.INVALID_URL; "INVALID_URL"; end
23
+ def self.ITEM_NOT_FOUND; "ITEM_NOT_FOUND"; end
24
+ end
25
+
26
+ class JobStatus < BasicObject
27
+ def self.Authorizing; "SRT"; end
28
+ def self.Pending; "SRT"; end
29
+ def self.In_Process; "In Process"; end
30
+ def self.Complete; "Complete"; end
31
+ end
32
+
33
+ class TaskStatus < BasicObject
34
+ def self.COMPLETE; "COMPLETE"; end
35
+ def self.INPROGRESS; "INPROGRESS"; end
36
+ def self.ABORTED; "ABORTED"; end
37
+ def self.FAILED; "FAILED"; end
38
+ end
39
+
40
+ class Priority < BasicObject
41
+ def self.ECONOMY; "ECONOMY"; end
42
+ def self.STANDARD; "STANDARD"; end
43
+ def self.PRIORITY; "PRIORITY"; end
44
+ def self.CRITICAL; "CRITICAL"; end
45
+ def self.all; "[ ECONOMY, STANDARD, PRIORITY, CRITICAL ]"; end
46
+ end
47
+
48
+ class Fidelity < BasicObject
49
+ def self.MECHANICAL; "MECHANICAL"; end
50
+ def self.PREMIUM; "PREMIUM"; end
51
+ def self.PROFESSIONAL; "PROFESSIONAL"; end
52
+ def self.INTERIM_PROFESSIONAL; "INTERIM_PROFESSIONAL"; end
53
+ def self.FINAL; "FINAL"; end
54
+ def self.all; "[ MECHANICAL, PREMIUM, PROFESSIONAL, INTERIM_PROFESSIONAL, FINAL ]"; end
55
+ end
56
+
57
+ class CaptionFormat < BasicObject
58
+ def self.SRT; "SRT"; end
59
+ def self.SBV; "SBV"; end
60
+ def self.DFXP; "DFXP"; end
61
+ def self.QT; "QT"; end
62
+ def self.all; "[ SRT, SBV, DFXP, QT ]"; end
63
+ end
64
+
65
+ class TokenType < BasicObject
66
+ def self.word; "word"; end
67
+ def self.punctuation; "punctuation"; end
68
+ def self.sound; "sound"; end
69
+ end
70
+
71
+ class Tag < BasicObject
72
+ def self.ENDS_SENTENCE; "ENDS_SENTENCE"; end
73
+ def self.UNKNOWN; "UNKNOWN"; end
74
+ def self.INAUDIBLE; "INAUDIBLE"; end
75
+ def self.CROSSTALK; "CROSSTALK"; end
76
+ def self.MUSIC; "MUSIC"; end
77
+ def self.NOISE; "NOISE"; end
78
+ def self.LAUGH; "LAUGH"; end
79
+ def self.COUGH; "COUGH"; end
80
+ def self.FOREIGN; "FOREIGN"; end
81
+ def self.GUESSED; "GUESSED"; end
82
+ def self.BLANK_AUDIO; "BLANK_AUDIO"; end
83
+ def self.APPLAUSE; "APPLAUSE"; end
84
+ def self.BLEEP; "BLEEP"; end
85
+ end
86
+
87
+ class SpeakerId < BasicObject
88
+ def self.no; "no"; end
89
+ def self.number; "number"; end
90
+ def self.name; "name"; end
91
+ end
92
+
93
+ class SpeakerGender < BasicObject
94
+ def self.UNKNOWN; "UNKNOWN"; end
95
+ def self.MALE; "MALE"; end
96
+ def self.FEMALE; "FEMALE"; end
97
+ end
98
+
99
+ class Case < BasicObject
100
+ def self.upper; "upper"; end
101
+ def self.lower; "lower"; end
102
+ def self.unchanged; ""; end
103
+ end
104
+
105
+ class LineEnding < BasicObject
106
+ def self.UNIX; "UNIX"; end
107
+ def self.WINDOWS; "WINDOWS"; end
108
+ def self.OSX; "OSX"; end
109
+ end
110
+
111
+ class CustomerApprovalSteps < BasicObject
112
+ def self.TRANSLATION; "TRANSLATION"; end
113
+ def self.RETURN; "RETURN"; end
114
+ end
115
+
116
+ class CustomerApprovalTools < BasicObject
117
+ def self.AMARA; "AMARA"; end
118
+ def self.CIELO24; "CIELO24"; end
119
+ end
120
+
121
+ class Language < BasicObject
122
+ def self.English; "en"; end
123
+ def self.French; "fr"; end
124
+ def self.Spanish; "es"; end
125
+ def self.German; "de"; end
126
+ def self.Mandarin_Chinese; "cmn"; end
127
+ def self.Portuguese; "pt"; end
128
+ def self.Japanese; "jp"; end
129
+ def self.Arabic; "ar"; end
130
+ def self.Korean; "ko"; end
131
+ def self.Traditional_Chinese; "zh"; end
132
+ def self.Hindi; "hi"; end
133
+ def self.Italian; "it"; end
134
+ def self.Russian; "ru"; end
135
+ def self.Turkish; "tr"; end
136
+ def self.Hebrew; "he"; end
137
+ def self.all; "[ en, fr, es, de, cmn, pt, jp, ar, ko, zh, hi, it, ru, tr, he ]"; end
138
+ end
139
+ end
@@ -0,0 +1,161 @@
1
+ module Cielo24
2
+ class Options
3
+ def get_hash
4
+ hash = {}
5
+ self.instance_variables.each{ |var|
6
+ value = self.instance_variable_get(var)
7
+ if !value.nil?
8
+ hash[var.to_s.delete("@")] = self.instance_variable_get(var)
9
+ end
10
+ }
11
+ return hash
12
+ end
13
+
14
+ def to_query
15
+ hash = get_hash
16
+ array = Array.new(hash.length)
17
+ counter = 0
18
+ hash.each do |key, value|
19
+ array[counter] = key + '=' + value.to_s
20
+ counter += 1
21
+ end
22
+ return array.join("&")
23
+ end
24
+
25
+ def populate_from_key_value_pair
26
+
27
+ end
28
+ end
29
+
30
+ class CommonOptions < Options
31
+
32
+ attr_accessor :characters_per_caption_line
33
+ attr_accessor :elementlist_version
34
+ attr_accessor :emit_speaker_change_token_as
35
+ attr_accessor :mask_profanity
36
+ attr_accessor :remove_sounds_list
37
+ attr_accessor :remove_sound_references
38
+ attr_accessor :replace_slang
39
+ attr_accessor :sound_boundaries
40
+
41
+ def initialize
42
+ @characters_per_caption_line = nil
43
+ @elementlist_version = nil
44
+ @emit_speaker_change_token_as = nil
45
+ @mask_profanity = nil
46
+ @remove_sounds_list = nil
47
+ @remove_sound_references = nil
48
+ @replace_slang = nil
49
+ @sound_boundaries = nil
50
+ end
51
+ end
52
+
53
+ class TranscriptionOptions < CommonOptions
54
+
55
+ attr_accessor :create_paragraphs
56
+ attr_accessor :newlines_after_paragraph
57
+ attr_accessor :newlines_after_sentence
58
+ attr_accessor :timecode_every_paragraph
59
+ attr_accessor :timecode_format
60
+ attr_accessor :time_code_interval
61
+ attr_accessor :timecode_offset
62
+
63
+ def initialize
64
+ @create_paragraphs = nil
65
+ @newlines_after_paragraph = nil
66
+ @newlines_after_sentence = nil
67
+ @timecode_every_paragraph = nil
68
+ @timecode_format = nil
69
+ @time_code_interval = nil
70
+ @timecode_offset = nil
71
+ end
72
+ end
73
+
74
+ class CaptionOptions < CommonOptions
75
+
76
+ attr_accessor :build_url
77
+ attr_accessor :caption_words_min
78
+ attr_accessor :caption_by_sentence
79
+ attr_accessor :dfxp_header
80
+ attr_accessor :disallow_dangling
81
+ attr_accessor :display_effects_speaker_as
82
+ attr_accessor :display_speaker_id
83
+ attr_accessor :force_case
84
+ attr_accessor :include_dfxp_metadata
85
+ attr_accessor :layout_target_caption_length_ms
86
+ attr_accessor :line_break_on_sentence
87
+ attr_accessor :line_ending_format
88
+ attr_accessor :lines_per_caption
89
+ attr_accessor :maximum_caption_duration
90
+ attr_accessor :merge_gap_interval
91
+ attr_accessor :minimum_caption_length_ms
92
+ attr_accessor :minimum_gap_between_captions_ms
93
+ attr_accessor :minimum_merge_gap_interval
94
+ attr_accessor :qt_seamless
95
+ attr_accessor :silence_max_ms
96
+ attr_accessor :single_speaker_per_caption
97
+ attr_accessor :sound_threshold
98
+ attr_accessor :sound_tokens_by_caption
99
+ attr_accessor :sound_tokens_by_line
100
+ attr_accessor :sound_tokens_by_caption_list
101
+ attr_accessor :sound_tokens_by_line_list
102
+ attr_accessor :speaker_on_new_line
103
+ attr_accessor :srt_format
104
+ attr_accessor :srt_print
105
+ attr_accessor :strip_square_brackets
106
+ attr_accessor :utf8_mark
107
+
108
+ def initialize
109
+ @build_url = nil
110
+ @caption_words_min = nil
111
+ @caption_by_sentence = nil
112
+ @dfxp_header = nil
113
+ @disallow_dangling = nil
114
+ @display_effects_speaker_as = nil
115
+ @display_speaker_id = nil
116
+ @force_case = nil
117
+ @include_dfxp_metadata = nil
118
+ @layout_target_caption_length_ms = nil
119
+ @line_break_on_sentence = nil
120
+ @line_ending_format = nil
121
+ @lines_per_caption = nil
122
+ @maximum_caption_duration = nil
123
+ @merge_gap_interval = nil
124
+ @minimum_caption_length_ms = nil
125
+ @minimum_gap_between_captions_ms = nil
126
+ @minimum_merge_gap_interval = nil
127
+ @qt_seamless = nil
128
+ @silence_max_ms = nil
129
+ @single_speaker_per_caption = nil
130
+ @sound_threshold = nil
131
+ @sound_tokens_by_caption = nil
132
+ @sound_tokens_by_line = nil
133
+ @sound_tokens_by_caption_list = nil
134
+ @sound_tokens_by_line_list = nil
135
+ @speaker_on_new_line = nil
136
+ @srt_format = nil
137
+ @srt_print = nil
138
+ @strip_square_brackets = nil
139
+ @utf8_mark = nil
140
+ end
141
+ end
142
+
143
+ class PerformTranscriptionOptions < Options
144
+
145
+ attr_accessor :customer_approval_steps
146
+ attr_accessor :customer_approval_tool
147
+ attr_accessor :custom_metadata
148
+ attr_accessor :notes
149
+ attr_accessor :return_iwp
150
+ attr_accessor :speaker_id
151
+
152
+ def initialize
153
+ @customer_approval_steps = nil
154
+ @customer_approval_tool = nil
155
+ @custom_metadata = nil
156
+ @notes = nil
157
+ @return_iwp = nil
158
+ @speaker_id = nil
159
+ end
160
+ end
161
+ end
@@ -0,0 +1,3 @@
1
+ module Cielo24
2
+ VERSION = "0.0.5"
3
+ end
@@ -0,0 +1,45 @@
1
+ module Cielo24
2
+ class WebUtils
3
+
4
+ require 'json'
5
+ require 'httpclient'
6
+ include JSON
7
+
8
+ VERIFY_MODE = nil
9
+ BASIC_TIMEOUT = 60
10
+ DOWNLOAD_TIMEOUT = 300
11
+
12
+ def self.get_json(uri, method, timeout, query=nil, headers=nil, body=nil)
13
+ response = http_request(uri, method, timeout, query, headers, body)
14
+ return JSON.parse(response)
15
+ end
16
+
17
+ def self.http_request(uri, method, timeout, query=nil, headers = nil, body = nil)
18
+ http_client = HTTPClient.new
19
+ http_client.cookie_manager = nil
20
+ # TODO: timeout
21
+
22
+ response = http_client.request(method, uri, query, body, headers, nil)
23
+
24
+ # Handle web errors
25
+ if response.status_code == 200 or response.status_code == 204
26
+ return response.body
27
+ else
28
+ json = JSON.parse(response.body)
29
+ raise WebError.new(json["ErrorType"], json["ErrorComment"])
30
+ end
31
+ end
32
+ end
33
+
34
+ class WebError < StandardError
35
+ attr_reader :type
36
+ def initialize(type, comment)
37
+ super comment
38
+ @type = type
39
+ end
40
+
41
+ def to_s
42
+ return @type + " - " + super.to_s
43
+ end
44
+ end
45
+ end
metadata CHANGED
@@ -1,126 +1,106 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cielo24
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
5
- prerelease:
4
+ version: 0.0.5
6
5
  platform: ruby
7
6
  authors:
8
7
  - Evgeny Chistyakov
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2014-07-21 00:00:00.000000000 Z
11
+ date: 2014-07-22 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: bundler
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ! '>='
17
+ - - ~>
20
18
  - !ruby/object:Gem::Version
21
- version: '0'
19
+ version: '1.6'
22
20
  type: :development
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ! '>='
24
+ - - ~>
28
25
  - !ruby/object:Gem::Version
29
- version: '0'
26
+ version: '1.6'
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: rake
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
- - - ! '>='
31
+ - - ~>
36
32
  - !ruby/object:Gem::Version
37
- version: '0'
33
+ version: '10.0'
38
34
  type: :development
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
- requirements:
43
- - - ! '>='
44
- - !ruby/object:Gem::Version
45
- version: '0'
46
- - !ruby/object:Gem::Dependency
47
- name: rspec
48
- requirement: !ruby/object:Gem::Requirement
49
- none: false
50
37
  requirements:
51
- - - ! '>='
38
+ - - ~>
52
39
  - !ruby/object:Gem::Version
53
- version: '0'
54
- type: :development
55
- prerelease: false
56
- version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
- requirements:
59
- - - ! '>='
60
- - !ruby/object:Gem::Version
61
- version: '0'
40
+ version: '10.0'
62
41
  - !ruby/object:Gem::Dependency
63
42
  name: httpclient
64
43
  requirement: !ruby/object:Gem::Requirement
65
- none: false
66
44
  requirements:
67
- - - ! '>='
45
+ - - '>='
68
46
  - !ruby/object:Gem::Version
69
47
  version: '0'
70
48
  type: :runtime
71
49
  prerelease: false
72
50
  version_requirements: !ruby/object:Gem::Requirement
73
- none: false
74
51
  requirements:
75
- - - ! '>='
52
+ - - '>='
76
53
  - !ruby/object:Gem::Version
77
54
  version: '0'
78
55
  - !ruby/object:Gem::Dependency
79
56
  name: hashie
80
57
  requirement: !ruby/object:Gem::Requirement
81
- none: false
82
58
  requirements:
83
- - - ! '>='
59
+ - - '>='
84
60
  - !ruby/object:Gem::Version
85
61
  version: '0'
86
62
  type: :runtime
87
63
  prerelease: false
88
64
  version_requirements: !ruby/object:Gem::Requirement
89
- none: false
90
65
  requirements:
91
- - - ! '>='
66
+ - - '>='
92
67
  - !ruby/object:Gem::Version
93
68
  version: '0'
94
- description: Cielo24 API interface gem.
69
+ description: This gem allows you to interact with the cielo24 public web API.
95
70
  email:
96
71
  - support@cielo24.com
97
72
  executables: []
98
73
  extensions: []
99
74
  extra_rdoc_files: []
100
- files: []
101
- homepage: http://www.cielo24.com/
75
+ files:
76
+ - lib/cielo24/actions.rb
77
+ - lib/cielo24/enums.rb
78
+ - lib/cielo24/options.rb
79
+ - lib/cielo24/version.rb
80
+ - lib/cielo24/web_utils.rb
81
+ - lib/cielo24.rb
82
+ homepage: http://cielo24.com
102
83
  licenses:
103
84
  - MIT
85
+ metadata: {}
104
86
  post_install_message:
105
87
  rdoc_options: []
106
88
  require_paths:
107
89
  - lib
108
90
  required_ruby_version: !ruby/object:Gem::Requirement
109
- none: false
110
91
  requirements:
111
- - - ! '>='
92
+ - - '>='
112
93
  - !ruby/object:Gem::Version
113
94
  version: '0'
114
95
  required_rubygems_version: !ruby/object:Gem::Requirement
115
- none: false
116
96
  requirements:
117
- - - ! '>='
97
+ - - '>='
118
98
  - !ruby/object:Gem::Version
119
99
  version: '0'
120
100
  requirements: []
121
101
  rubyforge_project:
122
- rubygems_version: 1.8.28
102
+ rubygems_version: 2.0.14
123
103
  signing_key:
124
- specification_version: 3
125
- summary: Cielo24 API interface gem.
104
+ specification_version: 4
105
+ summary: Cielo24 API gem.
126
106
  test_files: []