Streamline Video Metadata Retrieval with AIOV Cognitive Actions

In the age of digital content, integrating video capabilities into applications can significantly enhance user experience. The AIOV - Download YouTube Videos Cognitive Actions provide a simple and effective way to retrieve essential metadata from various social media platforms, including YouTube. By leveraging these pre-built actions, developers can streamline their applications to fetch video details effortlessly, enabling features such as video previews, analytics, and more.
Prerequisites
Before you start using the Cognitive Actions, ensure you have the following:
- An API key for the Cognitive Actions platform.
- Basic understanding of JSON and HTTP requests.
To authenticate your requests, you will typically pass your API key in the headers of your requests.
Cognitive Actions Overview
Fetch Social Media Video Metadata
The Fetch Social Media Video Metadata action allows you to retrieve comprehensive metadata for videos sourced from platforms like YouTube, Instagram, Facebook, and more. This action is invaluable for applications focused on video content, providing information such as titles, URLs, sizes, and formats.
Input
The input for this action requires a JSON object containing one required field:
- requestUrl: The URL of the requested video. This field is mandatory and should be a valid video URL from one of the supported platforms.
Example Input:
{
"requestUrl": "https://www.facebook.com/DIdrummers/videos/1069885786481223/"
}
Output
The output is a JSON object that includes detailed metadata about the video. Key attributes may include:
- id: Unique identifier of the video.
- title: Title of the video.
- url: Direct link to the video file.
- thumbnail: URL for the video thumbnail.
- duration: Length of the video in seconds.
Example Output:
{
"id": 1069885786481223,
"title": "Band Cover: Tool - Aenima",
"url": "https://video-iad3-2.xx.fbcdn.net/o1/v/t2/f2/m69/AQPb6ObhaDYz_LIy6g3LFjy8Xz9f4Yl3-VcwljAZVb8ZEycFLmh3Awx-oEyqRD6RIDn61Vk8vavVGJaEs7t-p2Pl.mp4?strext=1&_nc_cat=100&_nc_sid=8bf8fe&_nc_ht=video-iad3-2.xx.fbcdn.net&_nc_ohc=espjFju6UekQ7kNvgFGs0SX&efg=eyJ2ZW5jb2RlX3RhZyI6Inhwdl9wcm9ncmVzc2l2ZS5GQUNFQk9PSy4uQzMuNDAwLnN2ZV9zZCIsInhwdl9hc3NldF9pZCI6MTE2MzU0OTYyNDgzNzQ5OSwiYXNzZXRfYWdlX2RheXMiOjI3NjcsInZpX3VzZWNhc2VfaWQiOjEwMTM5LCJkdXJhdGlvbl9zIjo0MTUsInVybGdlbl9zb3VyY2UiOiJ3d3cifQ%3D%3D&ccb=17-1&_nc_zt=28&oh=00_AYF7rJ82r0uudR2HW_WXsBayOBuQfmiMoDPe-m31kBFTzQ&oe=67F3D05A",
"duration": 415.816,
"thumbnail": "https://scontent-iad3-1.xx.fbcdn.net/v/t15.5256-10/21368511_1069893576480444_7004872122522664960_n.jpg?_nc_cat=102&ccb=1-7&_nc_sid=50ce42&_nc_ohc=zFe9cB2jR6YQ7kNvgHvOvNN&_nc_oc=AdnRQFvzpXtIoWYlmjfkUZklhSlfQtNSJOTYpShq9HTjk1y350bbBvTSvRDQO1r25iM&_nc_zt=23&_nc_ht=scontent-iad3-1.xx&_nc_gid=nc-0PHPMJt75EorQhnotnw&oh=00_AYFlXlZVxgjc-eodu9vJJ36JNkb5TRQSJrn9Btpwd7jOgg&oe=67F3BC38"
}
Conceptual Usage Example (Python)
Here’s how you can call the Fetch Social Media Video Metadata action using a hypothetical Cognitive Actions execution endpoint in Python:
import requests
import json
# Replace with your Cognitive Actions API key and endpoint
COGNITIVE_ACTIONS_API_KEY = "YOUR_COGNITIVE_ACTIONS_API_KEY"
COGNITIVE_ACTIONS_EXECUTE_URL = "https://api.cognitiveactions.com/actions/execute" # Hypothetical endpoint
action_id = "d37c138e-b25c-4621-9fb4-4a44117f1150" # Action ID for Fetch Social Media Video Metadata
# Construct the input payload based on the action's requirements
payload = {
"requestUrl": "https://www.facebook.com/DIdrummers/videos/1069885786481223/"
}
headers = {
"Authorization": f"Bearer {COGNITIVE_ACTIONS_API_KEY}",
"Content-Type": "application/json"
}
try:
response = requests.post(
COGNITIVE_ACTIONS_EXECUTE_URL,
headers=headers,
json={"action_id": action_id, "inputs": payload} # Hypothetical structure
)
response.raise_for_status() # Raise an exception for bad status codes (4xx or 5xx)
result = response.json()
print("Action executed successfully:")
print(json.dumps(result, indent=2))
except requests.exceptions.RequestException as e:
print(f"Error executing action {action_id}: {e}")
if e.response is not None:
print(f"Response status: {e.response.status_code}")
try:
print(f"Response body: {e.response.json()}")
except json.JSONDecodeError:
print(f"Response body: {e.response.text}")
In this code snippet, you'll need to replace YOUR_COGNITIVE_ACTIONS_API_KEY with your actual API key. The action ID and input payload structure are tailored to the Fetch Social Media Video Metadata action.
Conclusion
The AIOV Cognitive Actions, particularly the Fetch Social Media Video Metadata, empower developers to seamlessly integrate video content into their applications. By utilizing these actions, you can enhance your app's functionality, providing users with rich video metadata that can be used for various applications. Consider exploring additional use cases, such as video analytics, content recommendations, or building a video library, to fully leverage the capabilities of these Cognitive Actions.