Skip to main content

Create Video Clip List

Description

The create_video_clip_list function creates multiple video clip records for a given device in a single API call. It takes a list of CreateVideoClip objects, formats them for the backend, and sends them to the service.

Function Signature:

def create_video_clip_list(
ws_config: WebServiceConfig,
device_name: str,
create_video_clips: List[CreateVideoClip]
) -> tuple[int, str]:

Parameters

  • ws_config (WebServiceConfig): Configuration object for the web service.
  • device_name (str): The name of the device creating the clips. The name will be sanitized and URL-encoded.
  • create_video_clips (List[CreateVideoClip]): A list of objects, each containing metadata and options for a video clip.

Returns

  • tuple[int, str]: A tuple with:
    • int: The HTTP response code from the server.
    • str: The HTTP response body, often a status message or JSON string.

Example Usage

ws_config = WebServiceConfig(base_url="https://api.actionstreamer.com")
clips = [CreateVideoClip(...), CreateVideoClip(...)]
device_name = "My Device"

response_code, response_string = create_video_clip_list(ws_config, device_name, clips)
print(response_code, response_string)

Behavior

  • Cleans and URL-encodes the device_name.
  • Converts each CreateVideoClip object into a dictionary.
  • Sends a POST request to the endpoint v1/videoclip/createlist/{device_name} with a JSON array in the body.
  • Returns the response from the web service.

Error Handling

  • On exception:
    • Sets response_code to -1.
    • Provides a descriptive response_string with the line number where the exception occurred.
    • Logs the exception details to the console.