diff --git a/cloudinary/utils.py b/cloudinary/utils.py index dd89537..87914ee 100644 --- a/cloudinary/utils.py +++ b/cloudinary/utils.py @@ -121,6 +121,7 @@ "async", "cinemagraph_analysis", "accessibility_analysis", + "auto_chaptering", ] __SERIALIZED_UPLOAD_PARAMS = [ @@ -138,6 +139,7 @@ "responsive_breakpoints", "access_control", "metadata", + "auto_transcription", ] upload_params = __SIMPLE_UPLOAD_PARAMS + __SERIALIZED_UPLOAD_PARAMS @@ -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 diff --git a/test/test_uploader.py b/test/test_uploader.py index be23308..b9e1d39 100644 --- a/test/test_uploader.py +++ b/test/test_uploader.py @@ -1,4 +1,5 @@ import io +import json import os import tempfile import unittest @@ -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"} @@ -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)