telestream_cloud 1.1.0 → 2.0.0.1
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 +4 -4
- data/.gitignore +2 -0
- data/README.md +16 -354
- data/flip/.gitignore +39 -0
- data/flip/.rspec +2 -0
- data/flip/.swagger-codegen-ignore +23 -0
- data/flip/.swagger-codegen/VERSION +1 -0
- data/flip/Gemfile +7 -0
- data/flip/README.md +130 -0
- data/flip/Rakefile +8 -0
- data/flip/docs/CanceledResponse.md +8 -0
- data/flip/docs/CloudNotificationSettings.md +11 -0
- data/flip/docs/CloudNotificationSettingsEvents.md +11 -0
- data/flip/docs/CopyProfileBody.md +9 -0
- data/flip/docs/CountResponse.md +8 -0
- data/flip/docs/CreateEncodingBody.md +10 -0
- data/flip/docs/CreateVideoBody.md +12 -0
- data/flip/docs/DeletedResponse.md +8 -0
- data/flip/docs/Encoding.md +38 -0
- data/flip/docs/EncodingSignedUrl.md +8 -0
- data/flip/docs/EncodingSignedUrls.md +8 -0
- data/flip/docs/Error.md +9 -0
- data/flip/docs/ExtraFile.md +10 -0
- data/flip/docs/Factory.md +25 -0
- data/flip/docs/FactoryBody.md +23 -0
- data/flip/docs/FactoryBodyStorageCredentialAttributes.md +11 -0
- data/flip/docs/FactorySync.md +8 -0
- data/flip/docs/FactorySyncBody.md +8 -0
- data/flip/docs/FlipApi.md +2179 -0
- data/flip/docs/PaginatedEncodingsCollection.md +11 -0
- data/flip/docs/PaginatedFactoryCollection.md +11 -0
- data/flip/docs/PaginatedProfilesCollection.md +11 -0
- data/flip/docs/PaginatedVideoCollection.md +11 -0
- data/flip/docs/PaginatedWorkflowsCollection.md +11 -0
- data/flip/docs/Profile.md +135 -0
- data/flip/docs/ProfileBody.md +137 -0
- data/flip/docs/ResubmitVideoBody.md +8 -0
- data/flip/docs/RetriedResponse.md +8 -0
- data/flip/docs/SignedVideoUrl.md +8 -0
- data/flip/docs/UpdateEncodingBody.md +9 -0
- data/flip/docs/UploadSession.md +13 -0
- data/flip/docs/Video.md +31 -0
- data/flip/docs/VideoMetadata.md +7 -0
- data/flip/docs/VideoUploadBody.md +24 -0
- data/flip/git_push.sh +55 -0
- data/flip/lib/telestream_cloud_flip.rb +79 -0
- data/flip/lib/telestream_cloud_flip/api/flip_api.rb +2385 -0
- data/flip/lib/telestream_cloud_flip/api_client.rb +389 -0
- data/flip/lib/telestream_cloud_flip/api_error.rb +38 -0
- data/flip/lib/telestream_cloud_flip/configuration.rb +209 -0
- data/flip/lib/telestream_cloud_flip/models/canceled_response.rb +189 -0
- data/flip/lib/telestream_cloud_flip/models/cloud_notification_settings.rb +237 -0
- data/flip/lib/telestream_cloud_flip/models/cloud_notification_settings_events.rb +239 -0
- data/flip/lib/telestream_cloud_flip/models/copy_profile_body.rb +209 -0
- data/flip/lib/telestream_cloud_flip/models/count_response.rb +189 -0
- data/flip/lib/telestream_cloud_flip/models/create_encoding_body.rb +214 -0
- data/flip/lib/telestream_cloud_flip/models/create_video_body.rb +231 -0
- data/flip/lib/telestream_cloud_flip/models/deleted_response.rb +189 -0
- data/flip/lib/telestream_cloud_flip/models/encoding.rb +486 -0
- data/flip/lib/telestream_cloud_flip/models/encoding_signed_url.rb +189 -0
- data/flip/lib/telestream_cloud_flip/models/encoding_signed_urls.rb +191 -0
- data/flip/lib/telestream_cloud_flip/models/error.rb +199 -0
- data/flip/lib/telestream_cloud_flip/models/extra_file.rb +221 -0
- data/flip/lib/telestream_cloud_flip/models/factory.rb +388 -0
- data/flip/lib/telestream_cloud_flip/models/factory_body.rb +374 -0
- data/flip/lib/telestream_cloud_flip/models/factory_body_storage_credential_attributes.rb +215 -0
- data/flip/lib/telestream_cloud_flip/models/factory_sync.rb +222 -0
- data/flip/lib/telestream_cloud_flip/models/factory_sync_body.rb +227 -0
- data/flip/lib/telestream_cloud_flip/models/paginated_encodings_collection.rb +240 -0
- data/flip/lib/telestream_cloud_flip/models/paginated_factory_collection.rb +220 -0
- data/flip/lib/telestream_cloud_flip/models/paginated_profiles_collection.rb +220 -0
- data/flip/lib/telestream_cloud_flip/models/paginated_video_collection.rb +220 -0
- data/flip/lib/telestream_cloud_flip/models/paginated_workflows_collection.rb +220 -0
- data/flip/lib/telestream_cloud_flip/models/profile.rb +1777 -0
- data/flip/lib/telestream_cloud_flip/models/profile_body.rb +1762 -0
- data/flip/lib/telestream_cloud_flip/models/resubmit_video_body.rb +189 -0
- data/flip/lib/telestream_cloud_flip/models/retried_response.rb +189 -0
- data/flip/lib/telestream_cloud_flip/models/signed_video_url.rb +189 -0
- data/flip/lib/telestream_cloud_flip/models/update_encoding_body.rb +199 -0
- data/flip/lib/telestream_cloud_flip/models/upload_session.rb +249 -0
- data/flip/lib/telestream_cloud_flip/models/video.rb +418 -0
- data/flip/lib/telestream_cloud_flip/models/video_metadata.rb +179 -0
- data/flip/lib/telestream_cloud_flip/models/video_upload_body.rb +362 -0
- data/flip/lib/telestream_cloud_flip/uploader.rb +244 -0
- data/flip/lib/telestream_cloud_flip/version.rb +18 -0
- data/flip/spec/api/flip_api_spec.rb +550 -0
- data/flip/spec/api_client_spec.rb +226 -0
- data/flip/spec/configuration_spec.rb +42 -0
- data/flip/spec/models/canceled_response_spec.rb +42 -0
- data/flip/spec/models/cloud_notification_settings_events_spec.rb +60 -0
- data/flip/spec/models/cloud_notification_settings_spec.rb +60 -0
- data/flip/spec/models/copy_profile_body_spec.rb +48 -0
- data/flip/spec/models/count_response_spec.rb +42 -0
- data/flip/spec/models/create_encoding_body_spec.rb +54 -0
- data/flip/spec/models/create_video_body_spec.rb +66 -0
- data/flip/spec/models/deleted_response_spec.rb +42 -0
- data/flip/spec/models/encoding_signed_url_spec.rb +42 -0
- data/flip/spec/models/encoding_signed_urls_spec.rb +42 -0
- data/flip/spec/models/encoding_spec.rb +222 -0
- data/flip/spec/models/error_spec.rb +48 -0
- data/flip/spec/models/extra_file_spec.rb +54 -0
- data/flip/spec/models/factory_body_spec.rb +136 -0
- data/flip/spec/models/factory_body_storage_credential_attributes_spec.rb +60 -0
- data/flip/spec/models/factory_spec.rb +148 -0
- data/flip/spec/models/factory_sync_body_spec.rb +46 -0
- data/flip/spec/models/factory_sync_spec.rb +46 -0
- data/flip/spec/models/paginated_encodings_collection_spec.rb +60 -0
- data/flip/spec/models/paginated_factory_collection_spec.rb +60 -0
- data/flip/spec/models/paginated_profiles_collection_spec.rb +60 -0
- data/flip/spec/models/paginated_video_collection_spec.rb +60 -0
- data/flip/spec/models/paginated_workflows_collection_spec.rb +60 -0
- data/flip/spec/models/profile_body_spec.rb +916 -0
- data/flip/spec/models/profile_spec.rb +916 -0
- data/flip/spec/models/resubmit_video_body_spec.rb +42 -0
- data/flip/spec/models/retried_response_spec.rb +42 -0
- data/flip/spec/models/signed_video_url_spec.rb +42 -0
- data/flip/spec/models/update_encoding_body_spec.rb +48 -0
- data/flip/spec/models/upload_session_spec.rb +72 -0
- data/flip/spec/models/video_metadata_spec.rb +36 -0
- data/flip/spec/models/video_spec.rb +180 -0
- data/flip/spec/models/video_upload_body_spec.rb +138 -0
- data/flip/spec/spec_helper.rb +111 -0
- data/flip/telestream_cloud_flip.gemspec +47 -0
- data/lib/telestream_cloud.rb +0 -31
- data/lib/telestream_cloud/flip.rb +1 -9
- data/lib/telestream_cloud/qc.rb +1 -0
- data/lib/telestream_cloud/tts.rb +1 -0
- data/lib/telestream_cloud/version.rb +1 -1
- data/qc/.gitignore +39 -0
- data/qc/.rspec +2 -0
- data/qc/.swagger-codegen-ignore +23 -0
- data/qc/.swagger-codegen/VERSION +1 -0
- data/qc/Gemfile +7 -0
- data/qc/README.md +58 -0
- data/qc/Rakefile +8 -0
- data/qc/docs/Alert.md +13 -0
- data/qc/docs/AudioStream.md +13 -0
- data/qc/docs/Container.md +9 -0
- data/qc/docs/Data.md +10 -0
- data/qc/docs/Data1.md +9 -0
- data/qc/docs/ExtraFile.md +10 -0
- data/qc/docs/Job.md +12 -0
- data/qc/docs/JobData.md +9 -0
- data/qc/docs/JobDetails.md +9 -0
- data/qc/docs/JobDetailsResult.md +8 -0
- data/qc/docs/JobsCollection.md +12 -0
- data/qc/docs/Media.md +10 -0
- data/qc/docs/Options.md +7 -0
- data/qc/docs/Project.md +12 -0
- data/qc/docs/Proxy.md +12 -0
- data/qc/docs/QcApi.md +719 -0
- data/qc/docs/UploadSession.md +13 -0
- data/qc/docs/VideoStream.md +13 -0
- data/qc/docs/VideoUploadBody.md +12 -0
- data/qc/git_push.sh +55 -0
- data/qc/lib/telestream_cloud_qc.rb +64 -0
- data/qc/lib/telestream_cloud_qc/api/qc_api.rb +781 -0
- data/qc/lib/telestream_cloud_qc/api_client.rb +389 -0
- data/qc/lib/telestream_cloud_qc/api_error.rb +38 -0
- data/qc/lib/telestream_cloud_qc/configuration.rb +209 -0
- data/qc/lib/telestream_cloud_qc/models/alert.rb +236 -0
- data/qc/lib/telestream_cloud_qc/models/audio_stream.rb +238 -0
- data/qc/lib/telestream_cloud_qc/models/container.rb +198 -0
- data/qc/lib/telestream_cloud_qc/models/data.rb +208 -0
- data/qc/lib/telestream_cloud_qc/models/data_1.rb +197 -0
- data/qc/lib/telestream_cloud_qc/models/extra_file.rb +221 -0
- data/qc/lib/telestream_cloud_qc/models/job.rb +269 -0
- data/qc/lib/telestream_cloud_qc/models/job_data.rb +197 -0
- data/qc/lib/telestream_cloud_qc/models/job_details.rb +199 -0
- data/qc/lib/telestream_cloud_qc/models/job_details_result.rb +190 -0
- data/qc/lib/telestream_cloud_qc/models/jobs_collection.rb +230 -0
- data/qc/lib/telestream_cloud_qc/models/media.rb +210 -0
- data/qc/lib/telestream_cloud_qc/models/options.rb +179 -0
- data/qc/lib/telestream_cloud_qc/models/project.rb +262 -0
- data/qc/lib/telestream_cloud_qc/models/proxy.rb +224 -0
- data/qc/lib/telestream_cloud_qc/models/upload_session.rb +249 -0
- data/qc/lib/telestream_cloud_qc/models/video_stream.rb +235 -0
- data/qc/lib/telestream_cloud_qc/models/video_upload_body.rb +242 -0
- data/qc/lib/telestream_cloud_qc/uploader.rb +244 -0
- data/qc/lib/telestream_cloud_qc/version.rb +18 -0
- data/qc/spec/api/qc_api_spec.rb +202 -0
- data/qc/spec/api_client_spec.rb +226 -0
- data/qc/spec/configuration_spec.rb +42 -0
- data/qc/spec/models/alert_spec.rb +72 -0
- data/qc/spec/models/audio_stream_spec.rb +72 -0
- data/qc/spec/models/container_spec.rb +48 -0
- data/qc/spec/models/data_1_spec.rb +48 -0
- data/qc/spec/models/data_spec.rb +54 -0
- data/qc/spec/models/extra_file_spec.rb +54 -0
- data/qc/spec/models/job_data_spec.rb +48 -0
- data/qc/spec/models/job_details_result_spec.rb +42 -0
- data/qc/spec/models/job_details_spec.rb +48 -0
- data/qc/spec/models/job_spec.rb +74 -0
- data/qc/spec/models/jobs_collection_spec.rb +66 -0
- data/qc/spec/models/media_spec.rb +54 -0
- data/qc/spec/models/options_spec.rb +36 -0
- data/qc/spec/models/project_spec.rb +70 -0
- data/qc/spec/models/proxy_spec.rb +66 -0
- data/qc/spec/models/upload_session_spec.rb +72 -0
- data/qc/spec/models/video_stream_spec.rb +72 -0
- data/qc/spec/models/video_upload_body_spec.rb +66 -0
- data/qc/spec/spec_helper.rb +111 -0
- data/qc/telestream_cloud_qc.gemspec +47 -0
- data/telestream_cloud.gemspec +7 -12
- data/tts/.gitignore +39 -0
- data/tts/.rspec +2 -0
- data/tts/.swagger-codegen-ignore +23 -0
- data/tts/.swagger-codegen/VERSION +1 -0
- data/tts/Gemfile +7 -0
- data/tts/README.md +92 -0
- data/tts/Rakefile +8 -0
- data/tts/docs/CorporaCollection.md +8 -0
- data/tts/docs/Corpus.md +9 -0
- data/tts/docs/ErrorResponse.md +7 -0
- data/tts/docs/ExtraFile.md +10 -0
- data/tts/docs/Fragment.md +10 -0
- data/tts/docs/FragmentVariant.md +9 -0
- data/tts/docs/Job.md +23 -0
- data/tts/docs/JobResult.md +8 -0
- data/tts/docs/JobsCollection.md +12 -0
- data/tts/docs/Project.md +18 -0
- data/tts/docs/ProjectsCollection.md +12 -0
- data/tts/docs/Result.md +12 -0
- data/tts/docs/TtsApi.md +902 -0
- data/tts/docs/UploadSession.md +13 -0
- data/tts/docs/VideoUploadBody.md +12 -0
- data/tts/git_push.sh +55 -0
- data/tts/lib/telestream_cloud_tts.rb +60 -0
- data/tts/lib/telestream_cloud_tts/api/tts_api.rb +946 -0
- data/tts/lib/telestream_cloud_tts/api_client.rb +389 -0
- data/tts/lib/telestream_cloud_tts/api_error.rb +38 -0
- data/tts/lib/telestream_cloud_tts/configuration.rb +209 -0
- data/tts/lib/telestream_cloud_tts/models/corpora_collection.rb +191 -0
- data/tts/lib/telestream_cloud_tts/models/corpus.rb +199 -0
- data/tts/lib/telestream_cloud_tts/models/error_response.rb +179 -0
- data/tts/lib/telestream_cloud_tts/models/extra_file.rb +221 -0
- data/tts/lib/telestream_cloud_tts/models/fragment.rb +211 -0
- data/tts/lib/telestream_cloud_tts/models/fragment_variant.rb +199 -0
- data/tts/lib/telestream_cloud_tts/models/job.rb +372 -0
- data/tts/lib/telestream_cloud_tts/models/job_result.rb +191 -0
- data/tts/lib/telestream_cloud_tts/models/jobs_collection.rb +230 -0
- data/tts/lib/telestream_cloud_tts/models/project.rb +322 -0
- data/tts/lib/telestream_cloud_tts/models/projects_collection.rb +230 -0
- data/tts/lib/telestream_cloud_tts/models/result.rb +230 -0
- data/tts/lib/telestream_cloud_tts/models/upload_session.rb +249 -0
- data/tts/lib/telestream_cloud_tts/models/video_upload_body.rb +241 -0
- data/tts/lib/telestream_cloud_tts/uploader.rb +244 -0
- data/tts/lib/telestream_cloud_tts/version.rb +18 -0
- data/tts/spec/api/tts_api_spec.rb +236 -0
- data/tts/spec/api_client_spec.rb +226 -0
- data/tts/spec/configuration_spec.rb +42 -0
- data/tts/spec/models/corpora_collection_spec.rb +42 -0
- data/tts/spec/models/corpus_spec.rb +48 -0
- data/tts/spec/models/error_response_spec.rb +36 -0
- data/tts/spec/models/extra_file_spec.rb +54 -0
- data/tts/spec/models/fragment_spec.rb +54 -0
- data/tts/spec/models/fragment_variant_spec.rb +48 -0
- data/tts/spec/models/job_result_spec.rb +42 -0
- data/tts/spec/models/job_spec.rb +136 -0
- data/tts/spec/models/jobs_collection_spec.rb +66 -0
- data/tts/spec/models/project_spec.rb +106 -0
- data/tts/spec/models/projects_collection_spec.rb +66 -0
- data/tts/spec/models/result_spec.rb +66 -0
- data/tts/spec/models/upload_session_spec.rb +72 -0
- data/tts/spec/models/video_upload_body_spec.rb +66 -0
- data/tts/spec/spec_helper.rb +111 -0
- data/tts/telestream_cloud_tts.gemspec +47 -0
- metadata +281 -123
- data/Gemfile +0 -2
- data/lib/telestream_cloud/api_authentication.rb +0 -66
- data/lib/telestream_cloud/base.rb +0 -111
- data/lib/telestream_cloud/config.rb +0 -87
- data/lib/telestream_cloud/connection.rb +0 -101
- data/lib/telestream_cloud/errors.rb +0 -17
- data/lib/telestream_cloud/faraday.rb +0 -84
- data/lib/telestream_cloud/modules/associations.rb +0 -55
- data/lib/telestream_cloud/modules/builders.rb +0 -45
- data/lib/telestream_cloud/modules/destroyers.rb +0 -25
- data/lib/telestream_cloud/modules/factory_connection.rb +0 -7
- data/lib/telestream_cloud/modules/finders.rb +0 -68
- data/lib/telestream_cloud/modules/router.rb +0 -62
- data/lib/telestream_cloud/modules/updatable.rb +0 -31
- data/lib/telestream_cloud/modules/video_state.rb +0 -16
- data/lib/telestream_cloud/parallel_uploader.rb +0 -52
- data/lib/telestream_cloud/proxies/encoding_scope.rb +0 -56
- data/lib/telestream_cloud/proxies/profile_scope.rb +0 -7
- data/lib/telestream_cloud/proxies/proxy.rb +0 -27
- data/lib/telestream_cloud/proxies/scope.rb +0 -94
- data/lib/telestream_cloud/proxies/video_scope.rb +0 -28
- data/lib/telestream_cloud/resources/encoding.rb +0 -47
- data/lib/telestream_cloud/resources/factory.rb +0 -72
- data/lib/telestream_cloud/resources/profile.rb +0 -22
- data/lib/telestream_cloud/resources/resource.rb +0 -48
- data/lib/telestream_cloud/resources/video.rb +0 -39
- data/lib/telestream_cloud/telestream_cloud.rb +0 -69
- data/lib/telestream_cloud/upload_session.rb +0 -40
- data/lib/telestream_cloud/uploader.rb +0 -123
- data/lib/telestream_cloud/uploader/file_reader.rb +0 -27
- data/spec/cloud_spec.rb +0 -132
- data/spec/encoding_spec.rb +0 -260
- data/spec/heroku_spec.rb +0 -32
- data/spec/panda_spec.rb +0 -206
- data/spec/profile_spec.rb +0 -117
- data/spec/spec_helper.rb +0 -18
- data/spec/uploader_spec.rb +0 -143
- data/spec/video_spec.rb +0 -399
@@ -0,0 +1,244 @@
|
|
1
|
+
require 'pathname'
|
2
|
+
require 'json'
|
3
|
+
require 'concurrent'
|
4
|
+
|
5
|
+
module TelestreamCloud::Tts
|
6
|
+
class Uploader
|
7
|
+
class FileReader
|
8
|
+
attr_reader :file
|
9
|
+
|
10
|
+
def initialize(path)
|
11
|
+
@mutex = Mutex.new
|
12
|
+
@path = path
|
13
|
+
reopen
|
14
|
+
end
|
15
|
+
|
16
|
+
def [](range)
|
17
|
+
@mutex.synchronize do
|
18
|
+
file.seek(range.begin)
|
19
|
+
file.read(range.size)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def size
|
24
|
+
@size ||= file.size
|
25
|
+
end
|
26
|
+
|
27
|
+
def name
|
28
|
+
Pathname.new(file.path).basename
|
29
|
+
end
|
30
|
+
|
31
|
+
def close
|
32
|
+
@file.close
|
33
|
+
@file = nil
|
34
|
+
end
|
35
|
+
|
36
|
+
def reopen
|
37
|
+
@file ||= File.open(@path)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
class FileUploadSession
|
42
|
+
attr_reader :uploader, :reader, :tag
|
43
|
+
|
44
|
+
def initialize(uploader, path, tag = nil)
|
45
|
+
@uploader = uploader
|
46
|
+
@reader = FileReader.new(path)
|
47
|
+
@tag = tag
|
48
|
+
@status = :ready
|
49
|
+
end
|
50
|
+
|
51
|
+
def success?
|
52
|
+
@status == :success
|
53
|
+
end
|
54
|
+
|
55
|
+
def params
|
56
|
+
upload_params = {
|
57
|
+
file_size: reader.size,
|
58
|
+
file_name: reader.name
|
59
|
+
}
|
60
|
+
|
61
|
+
upload_params[:tag] = @tag if @tag
|
62
|
+
upload_params
|
63
|
+
end
|
64
|
+
|
65
|
+
def upload!
|
66
|
+
reader.reopen
|
67
|
+
|
68
|
+
upload_chunks(missing_parts)
|
69
|
+
|
70
|
+
raise MissingPartError unless missing_parts.empty?
|
71
|
+
|
72
|
+
@status = :success
|
73
|
+
ensure
|
74
|
+
reader.close
|
75
|
+
end
|
76
|
+
|
77
|
+
private
|
78
|
+
|
79
|
+
def upload_chunks(indexes)
|
80
|
+
indexes.each do |index|
|
81
|
+
send_chunk(index)
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
def session
|
86
|
+
uploader.send(:session)
|
87
|
+
end
|
88
|
+
|
89
|
+
def send_chunk(index)
|
90
|
+
range = (index * part_size...[(index + 1) * part_size, reader.size].min)
|
91
|
+
|
92
|
+
# TODO: remove when 1.9 dropped
|
93
|
+
unless range.respond_to?(:size)
|
94
|
+
def range.size; self.end - self.begin + (exclude_end? ? 0 : 1); end
|
95
|
+
end
|
96
|
+
|
97
|
+
response = Typhoeus.put(
|
98
|
+
session.location,
|
99
|
+
body: reader[range],
|
100
|
+
headers: {
|
101
|
+
'Content-Type' => 'application/octet-stream',
|
102
|
+
'X-Part' => index.to_s,
|
103
|
+
'Content-Length' => range.size.to_s,
|
104
|
+
'X-Extra-File-Tag' => tag,
|
105
|
+
}.reject { |_, v| v.nil? }
|
106
|
+
)
|
107
|
+
|
108
|
+
puts response.body
|
109
|
+
|
110
|
+
uploader.send(:set_resource_id, response)
|
111
|
+
response
|
112
|
+
end
|
113
|
+
|
114
|
+
def missing_parts
|
115
|
+
upload_status['missing_parts']
|
116
|
+
end
|
117
|
+
|
118
|
+
def upload_status
|
119
|
+
response = Typhoeus.get(
|
120
|
+
session.location,
|
121
|
+
headers: {
|
122
|
+
'X-Extra-File-Tag' => @tag
|
123
|
+
}.reject { |_, v| v.nil? }
|
124
|
+
)
|
125
|
+
JSON.parse(response.body)
|
126
|
+
end
|
127
|
+
|
128
|
+
def parts; session.parts; end
|
129
|
+
def part_size; session.part_size; end
|
130
|
+
def max_connections; session.max_connections; end
|
131
|
+
end
|
132
|
+
|
133
|
+
class ConcurrentFileUploadSession < FileUploadSession
|
134
|
+
def upload_chunks(indexes)
|
135
|
+
|
136
|
+
indexes.map do |index|
|
137
|
+
Concurrent::Future.execute(executor: uploader.thread_pool) do
|
138
|
+
send_chunk(index)
|
139
|
+
end
|
140
|
+
end.map(&:value)
|
141
|
+
end
|
142
|
+
end
|
143
|
+
|
144
|
+
class UploadError < StandardError; end
|
145
|
+
class MissingPartError < StandardError; end
|
146
|
+
|
147
|
+
attr_reader :reader, :status, :error, :thread_pool, :concurrency
|
148
|
+
|
149
|
+
def self.upload(options)
|
150
|
+
retries = options.delete(:retries)
|
151
|
+
new(options).tap { |x| x.upload(*[retries].compact) }.video
|
152
|
+
end
|
153
|
+
|
154
|
+
def initialize(client, options)
|
155
|
+
@client = client
|
156
|
+
|
157
|
+
@thread_pool = Concurrent::ThreadPoolExecutor.new(
|
158
|
+
min_threads: 5,
|
159
|
+
max_threads: 5,
|
160
|
+
max_queue: 100,
|
161
|
+
fallback_policy: :caller_runs
|
162
|
+
)
|
163
|
+
|
164
|
+
file = options.delete(:file) do |key|
|
165
|
+
raise KeyError, "key not found: #{key}"
|
166
|
+
end
|
167
|
+
|
168
|
+
@extra_files = parse_extra_files(options.delete(:extra_files))
|
169
|
+
|
170
|
+
@upload_session = upload_session(file)
|
171
|
+
|
172
|
+
defaults = {
|
173
|
+
multi_chunk: true
|
174
|
+
}.merge(@upload_session.params)
|
175
|
+
|
176
|
+
@params = defaults.merge(options)
|
177
|
+
|
178
|
+
@params[:extra_files] = @extra_files.map(&:params) if @extra_files
|
179
|
+
|
180
|
+
@status = :ready
|
181
|
+
end
|
182
|
+
|
183
|
+
def parse_extra_files(extra_files)
|
184
|
+
return [] unless extra_files
|
185
|
+
|
186
|
+
extra_files.flat_map do |tag, paths|
|
187
|
+
paths = [paths] unless paths.kind_of?(Array)
|
188
|
+
|
189
|
+
paths.each_with_index.map do |path, i|
|
190
|
+
upload_session(path, paths.size > 1 ? "#{tag}.index-#{i}" : tag)
|
191
|
+
end
|
192
|
+
end
|
193
|
+
end
|
194
|
+
|
195
|
+
def upload(retries = 5)
|
196
|
+
session
|
197
|
+
|
198
|
+
count = 0
|
199
|
+
begin
|
200
|
+
count += 1
|
201
|
+
upload!
|
202
|
+
raise MissingPartError unless success?
|
203
|
+
rescue StandardError => e
|
204
|
+
puts e
|
205
|
+
@error = e
|
206
|
+
retry if count < retries
|
207
|
+
end
|
208
|
+
|
209
|
+
@resource_id
|
210
|
+
end
|
211
|
+
|
212
|
+
def success?
|
213
|
+
@resource_id && @upload_session.success? && Array(@extra_files).all?(&:success?)
|
214
|
+
end
|
215
|
+
|
216
|
+
def upload_session(path, tag = nil)
|
217
|
+
ConcurrentFileUploadSession.new(self, path, tag)
|
218
|
+
end
|
219
|
+
|
220
|
+
private
|
221
|
+
|
222
|
+
def upload!
|
223
|
+
@upload_session.upload!
|
224
|
+
@extra_files.each(&:upload!)
|
225
|
+
end
|
226
|
+
|
227
|
+
def set_resource_id(response)
|
228
|
+
return if response.code != 200 || response.body.empty?
|
229
|
+
@resource_id = JSON.parse(response.body).fetch('id')
|
230
|
+
end
|
231
|
+
|
232
|
+
def session
|
233
|
+
return @session if defined?(@session)
|
234
|
+
@session = case @client.class.name
|
235
|
+
when "TelestreamCloud::Flip::FlipApi"
|
236
|
+
@factory_id ||= @params.delete(:factory_id) do |key|
|
237
|
+
raise KeyError, "key not found: #{key}"
|
238
|
+
end
|
239
|
+
|
240
|
+
@client.upload_video(@factory_id, @params)
|
241
|
+
end
|
242
|
+
end
|
243
|
+
end
|
244
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module TelestreamCloud
|
2
|
+
end
|
3
|
+
|
4
|
+
=begin
|
5
|
+
#Tts API
|
6
|
+
|
7
|
+
#Description
|
8
|
+
|
9
|
+
OpenAPI spec version: 2.0.0
|
10
|
+
Contact: cloudsupport@telestream.net
|
11
|
+
Generated by: https://github.com/swagger-api/swagger-codegen.git
|
12
|
+
Swagger Codegen version: 2.3.0
|
13
|
+
|
14
|
+
=end
|
15
|
+
|
16
|
+
module TelestreamCloud::Tts
|
17
|
+
VERSION = "2.0.0.1"
|
18
|
+
end
|
@@ -0,0 +1,236 @@
|
|
1
|
+
=begin
|
2
|
+
#Tts API
|
3
|
+
|
4
|
+
#Description
|
5
|
+
|
6
|
+
OpenAPI spec version: 2.0.0
|
7
|
+
Contact: cloudsupport@telestream.net
|
8
|
+
Generated by: https://github.com/swagger-api/swagger-codegen.git
|
9
|
+
Swagger Codegen version: 2.3.0
|
10
|
+
|
11
|
+
=end
|
12
|
+
|
13
|
+
require 'spec_helper'
|
14
|
+
require 'json'
|
15
|
+
|
16
|
+
# Unit tests for TelestreamCloud::Tts::TtsApi
|
17
|
+
# Automatically generated by swagger-codegen (github.com/swagger-api/swagger-codegen)
|
18
|
+
# Please update as you see appropriate
|
19
|
+
describe 'TtsApi' do
|
20
|
+
before do
|
21
|
+
# run before each test
|
22
|
+
@instance = TelestreamCloud::Tts::TtsApi.new
|
23
|
+
end
|
24
|
+
|
25
|
+
after do
|
26
|
+
# run after each test
|
27
|
+
end
|
28
|
+
|
29
|
+
describe 'test an instance of TtsApi' do
|
30
|
+
it 'should create an instance of TtsApi' do
|
31
|
+
expect(@instance).to be_instance_of(TelestreamCloud::Tts::TtsApi)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
# unit tests for corpora
|
36
|
+
# Returns a collection of Corpora
|
37
|
+
# Returns a collection of Corpora
|
38
|
+
# @param project_id ID of the Project
|
39
|
+
# @param [Hash] opts the optional parameters
|
40
|
+
# @return [CorporaCollection]
|
41
|
+
describe 'corpora test' do
|
42
|
+
it "should work" do
|
43
|
+
# assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
# unit tests for corpus
|
48
|
+
# Returns the Corpus
|
49
|
+
# Returns the Corpus
|
50
|
+
# @param project_id ID of the Project
|
51
|
+
# @param name Corpus name
|
52
|
+
# @param [Hash] opts the optional parameters
|
53
|
+
# @return [Corpus]
|
54
|
+
describe 'corpus test' do
|
55
|
+
it "should work" do
|
56
|
+
# assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
# unit tests for create_corpus
|
61
|
+
# Creates a new Corpus
|
62
|
+
# Creates a new Corpus
|
63
|
+
# @param project_id ID of the Project
|
64
|
+
# @param name Corpus name
|
65
|
+
# @param body
|
66
|
+
# @param [Hash] opts the optional parameters
|
67
|
+
# @return [nil]
|
68
|
+
describe 'create_corpus test' do
|
69
|
+
it "should work" do
|
70
|
+
# assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
# unit tests for create_job
|
75
|
+
# Creates a new Job
|
76
|
+
# Creates a new Job
|
77
|
+
# @param project_id ID of the Project
|
78
|
+
# @param job
|
79
|
+
# @param [Hash] opts the optional parameters
|
80
|
+
# @return [Job]
|
81
|
+
describe 'create_job test' do
|
82
|
+
it "should work" do
|
83
|
+
# assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
# unit tests for create_project
|
88
|
+
# Creates a new Project
|
89
|
+
# Creates a new Project
|
90
|
+
# @param project
|
91
|
+
# @param [Hash] opts the optional parameters
|
92
|
+
# @return [Project]
|
93
|
+
describe 'create_project test' do
|
94
|
+
it "should work" do
|
95
|
+
# assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
# unit tests for delete_corpus
|
100
|
+
# Creates a new Corpus
|
101
|
+
# Creates a new Corpus
|
102
|
+
# @param project_id ID of the Project
|
103
|
+
# @param name Corpus name
|
104
|
+
# @param [Hash] opts the optional parameters
|
105
|
+
# @return [nil]
|
106
|
+
describe 'delete_corpus test' do
|
107
|
+
it "should work" do
|
108
|
+
# assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
112
|
+
# unit tests for delete_job
|
113
|
+
# Deletes the Job
|
114
|
+
# Deletes the Job
|
115
|
+
# @param project_id ID of the Project
|
116
|
+
# @param job_id
|
117
|
+
# @param [Hash] opts the optional parameters
|
118
|
+
# @return [nil]
|
119
|
+
describe 'delete_job test' do
|
120
|
+
it "should work" do
|
121
|
+
# assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
|
122
|
+
end
|
123
|
+
end
|
124
|
+
|
125
|
+
# unit tests for delete_project
|
126
|
+
# Deletes the Project
|
127
|
+
# Deletes the Project
|
128
|
+
# @param [Hash] opts the optional parameters
|
129
|
+
# @return [nil]
|
130
|
+
describe 'delete_project test' do
|
131
|
+
it "should work" do
|
132
|
+
# assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
|
133
|
+
end
|
134
|
+
end
|
135
|
+
|
136
|
+
# unit tests for job
|
137
|
+
# Returns the Job
|
138
|
+
# Returns the Job
|
139
|
+
# @param project_id ID of the Project
|
140
|
+
# @param job_id
|
141
|
+
# @param [Hash] opts the optional parameters
|
142
|
+
# @return [Job]
|
143
|
+
describe 'job test' do
|
144
|
+
it "should work" do
|
145
|
+
# assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
|
146
|
+
end
|
147
|
+
end
|
148
|
+
|
149
|
+
# unit tests for job_result
|
150
|
+
# Returns the Job Result
|
151
|
+
# Returns the Job Result
|
152
|
+
# @param project_id ID of the Project
|
153
|
+
# @param job_id
|
154
|
+
# @param [Hash] opts the optional parameters
|
155
|
+
# @return [JobResult]
|
156
|
+
describe 'job_result test' do
|
157
|
+
it "should work" do
|
158
|
+
# assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
|
159
|
+
end
|
160
|
+
end
|
161
|
+
|
162
|
+
# unit tests for jobs
|
163
|
+
# Returns a collection of Jobs
|
164
|
+
# Returns a collection of Jobs
|
165
|
+
# @param project_id ID of the Project
|
166
|
+
# @param [Hash] opts the optional parameters
|
167
|
+
# @option opts [Integer] :page page number
|
168
|
+
# @option opts [Integer] :per_page number of records per page
|
169
|
+
# @return [JobsCollection]
|
170
|
+
describe 'jobs test' do
|
171
|
+
it "should work" do
|
172
|
+
# assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
|
173
|
+
end
|
174
|
+
end
|
175
|
+
|
176
|
+
# unit tests for project
|
177
|
+
# Returns the Project
|
178
|
+
# Returns the Project
|
179
|
+
# @param project_id ID of the Project
|
180
|
+
# @param [Hash] opts the optional parameters
|
181
|
+
# @return [Project]
|
182
|
+
describe 'project test' do
|
183
|
+
it "should work" do
|
184
|
+
# assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
|
185
|
+
end
|
186
|
+
end
|
187
|
+
|
188
|
+
# unit tests for projects
|
189
|
+
# Returns a collection of Projects
|
190
|
+
# Returns a collection of Projects
|
191
|
+
# @param [Hash] opts the optional parameters
|
192
|
+
# @return [ProjectsCollection]
|
193
|
+
describe 'projects test' do
|
194
|
+
it "should work" do
|
195
|
+
# assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
|
196
|
+
end
|
197
|
+
end
|
198
|
+
|
199
|
+
# unit tests for train_project
|
200
|
+
# Queues training
|
201
|
+
# Queues training
|
202
|
+
# @param project_id ID of the Project
|
203
|
+
# @param [Hash] opts the optional parameters
|
204
|
+
# @return [nil]
|
205
|
+
describe 'train_project test' do
|
206
|
+
it "should work" do
|
207
|
+
# assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
|
208
|
+
end
|
209
|
+
end
|
210
|
+
|
211
|
+
# unit tests for update_project
|
212
|
+
# Updates an existing Project
|
213
|
+
# Updates an existing Project
|
214
|
+
# @param project
|
215
|
+
# @param [Hash] opts the optional parameters
|
216
|
+
# @return [Project]
|
217
|
+
describe 'update_project test' do
|
218
|
+
it "should work" do
|
219
|
+
# assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
|
220
|
+
end
|
221
|
+
end
|
222
|
+
|
223
|
+
# unit tests for upload_video
|
224
|
+
# Creates an upload session
|
225
|
+
#
|
226
|
+
# @param project_id ID of the Project
|
227
|
+
# @param video_upload_body
|
228
|
+
# @param [Hash] opts the optional parameters
|
229
|
+
# @return [UploadSession]
|
230
|
+
describe 'upload_video test' do
|
231
|
+
it "should work" do
|
232
|
+
# assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
|
233
|
+
end
|
234
|
+
end
|
235
|
+
|
236
|
+
end
|