Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion cloudinary/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@
"async",
"cinemagraph_analysis",
"accessibility_analysis",
"auto_chaptering",
]

__SERIALIZED_UPLOAD_PARAMS = [
Expand All @@ -138,6 +139,7 @@
"responsive_breakpoints",
"access_control",
"metadata",
"auto_transcription",
]

upload_params = __SIMPLE_UPLOAD_PARAMS + __SERIALIZED_UPLOAD_PARAMS
Expand Down Expand Up @@ -1173,7 +1175,8 @@ def build_upload_params(**options):
"auto_tagging": options.get("auto_tagging") and str(options.get("auto_tagging")),
"responsive_breakpoints": generate_responsive_breakpoints_string(options.get("responsive_breakpoints")),
"access_control": options.get("access_control") and json_encode(
build_list_of_dicts(options.get("access_control")))
build_list_of_dicts(options.get("access_control"))),
"auto_transcription": json_encode(options.get("auto_transcription")),
}

# make sure that we are in-sync with __SERIALIZED_UPLOAD_PARAMS which are in use by other methods
Expand Down
19 changes: 18 additions & 1 deletion test/test_uploader.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import io
import json
import os
import tempfile
import unittest
Expand Down Expand Up @@ -460,6 +461,20 @@ def test_explicit_error_handling_not_found(self):
self.assertTrue(not_found_res["error"]["message"].startswith("Resource not found"))


@patch(URLLIB3_REQUEST)
@unittest.skipUnless(cloudinary.config().api_secret, "requires api_key/api_secret")
def test_explicit_auto_transcription(self, mocker):
"""Should pass auto_transcription to the API via explicit"""
mocker.return_value = MOCK_RESPONSE

uploader.explicit("test_id", type="upload", resource_type="video", auto_transcription=True)
self.assertEqual(get_param(mocker, "auto_transcription"), "true")

uploader.explicit("test_id", type="upload", resource_type="video",
auto_transcription={"translate": ["pl-PL", "he-IL"]})
result = json.loads(get_param(mocker, "auto_transcription"))
self.assertEqual(result, {"translate": ["pl-PL", "he-IL"]})

@unittest.skipUnless(cloudinary.config().api_secret, "requires api_key/api_secret")
def test_update_metadata(self):
metadata = {METADATA_FIELD_UNIQUE_EXTERNAL_ID: "test"}
Expand Down Expand Up @@ -960,7 +975,9 @@ def test_various_upload_parameters(self, request_mock):
'media_metadata': True,
'visual_search': True,
'on_success': ON_SUCCESS_STR,
'regions': {"box_1": [[1, 2], [3, 4]], "box_2": [[5, 6], [7, 8]]}
'regions': {"box_1": [[1, 2], [3, 4]], "box_2": [[5, 6], [7, 8]]},
'auto_transcription': True,
'auto_chaptering': True,
}

uploader.upload(TEST_IMAGE, **options)
Expand Down
Loading