Module: X::Uploader::Metadata
Overview
Describes uploaded media with alt text, and uploaded videos with subtitles
Class Method Summary collapse
-
.add_alt_text(media, text, client:) ⇒ UploadedMedia
Describe uploaded media with alt text, for people who cannot see it.
-
.add_subtitles(video, subtitles, language_code, client:, display_name: nil, media_category: SUBTITLED_MEDIA_CATEGORY) ⇒ UploadedMedia
Attach uploaded subtitles to an uploaded video.
Instance Method Summary collapse
-
#add_alt_text(media, text, client:) ⇒ UploadedMedia
Describe uploaded media with alt text, for people who cannot see it.
-
#add_subtitles(video, subtitles, language_code, client:, display_name: nil, media_category: SUBTITLED_MEDIA_CATEGORY) ⇒ UploadedMedia
Attach uploaded subtitles to an uploaded video.
Class Method Details
.add_alt_text(media, text, client:) ⇒ UploadedMedia
Describe uploaded media with alt text, for people who cannot see it
Alt text added twice is added once, so it is sent again after a server or network error, as a client sends an idempotent request again, up to the max_retries of the client.
It returns the media it described, as uploaded media, so that a call can be chained to the upload it describes. The response holds nothing more than the media identifier and the alt text that was sent.
44 45 46 47 48 |
# File 'x-uploader/lib/x/uploader/metadata.rb', line 44 def add_alt_text(media, text, client:) Validator.validate_alt_text!(text) body = {id: Utils.media_id(media), metadata: {alt_text: {text:}}} Utils.described(Utils.sending_again(client) { client.post("media/metadata", body, **JSON_CLASSES) }, media) end |
.add_subtitles(video, subtitles, language_code, client:, display_name: nil, media_category: SUBTITLED_MEDIA_CATEGORY) ⇒ UploadedMedia
Attach uploaded subtitles to an uploaded video
Subtitles attached twice are attached once, as the track of their language, so they are sent again after a server or network error, as alt text is, up to the max_retries of the client.
It returns the video it subtitled, as uploaded media, so that a call can be chained to the upload of the video. The response holds nothing more than the identifiers, the category, and the track that were sent.
83 84 85 86 87 |
# File 'x-uploader/lib/x/uploader/metadata.rb', line 83 def add_subtitles(video, subtitles, language_code, client:, display_name: nil, media_category: SUBTITLED_MEDIA_CATEGORY) track = {id: Utils.media_id(subtitles), language_code: Validator.validate_language_code!(language_code), display_name:}.compact body = {id: Utils.media_id(video), media_category: Utils.subtitled_media_category(media_category), subtitles: track} Utils.described(Utils.sending_again(client) { client.post("media/subtitles", body, **JSON_CLASSES) }, video) end |
Instance Method Details
#add_alt_text(media, text, client:) ⇒ UploadedMedia
Describe uploaded media with alt text, for people who cannot see it
Alt text added twice is added once, so it is sent again after a server or network error, as a client sends an idempotent request again, up to the max_retries of the client.
It returns the media it described, as uploaded media, so that a call can be chained to the upload it describes. The response holds nothing more than the media identifier and the alt text that was sent.
44 45 46 47 48 |
# File 'x-uploader/lib/x/uploader/metadata.rb', line 44 def add_alt_text(media, text, client:) Validator.validate_alt_text!(text) body = {id: Utils.media_id(media), metadata: {alt_text: {text:}}} Utils.described(Utils.sending_again(client) { client.post("media/metadata", body, **JSON_CLASSES) }, media) end |
#add_subtitles(video, subtitles, language_code, client:, display_name: nil, media_category: SUBTITLED_MEDIA_CATEGORY) ⇒ UploadedMedia
Attach uploaded subtitles to an uploaded video
Subtitles attached twice are attached once, as the track of their language, so they are sent again after a server or network error, as alt text is, up to the max_retries of the client.
It returns the video it subtitled, as uploaded media, so that a call can be chained to the upload of the video. The response holds nothing more than the identifiers, the category, and the track that were sent.
83 84 85 86 87 |
# File 'x-uploader/lib/x/uploader/metadata.rb', line 83 def add_subtitles(video, subtitles, language_code, client:, display_name: nil, media_category: SUBTITLED_MEDIA_CATEGORY) track = {id: Utils.media_id(subtitles), language_code: Validator.validate_language_code!(language_code), display_name:}.compact body = {id: Utils.media_id(video), media_category: Utils.subtitled_media_category(media_category), subtitles: track} Utils.described(Utils.sending_again(client) { client.post("media/subtitles", body, **JSON_CLASSES) }, video) end |