Last active
August 29, 2018 20:39
-
-
Save hohonuuli/1b01625de926d3a4f6313a9b20a36ad7 to your computer and use it in GitHub Desktop.
MBARI Media Management - Demonstrate how to register a video in the `vampire-squid` video asset manager
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import datetime | |
| import json | |
| import sys | |
| import requests | |
| host = "http://localhost:8084" | |
| client_secret = "foo" | |
| # Useful vampire-squid endpoints | |
| vampire_squid = "{}/vam/v1".format(host) | |
| auth_url = "{}/auth".format(vampire_squid) | |
| media_url = "{}/media".format(vampire_squid) | |
| def main(url, timeString): | |
| # -- Authenticate so that we can make a post request | |
| jwt_auth_header = {"Authorization": "APIKEY " + client_secret} | |
| jwt_response = requests.post(auth_url, headers=jwt_auth_header).json() | |
| access_token = jwt_response['access_token'] | |
| # -- Use POST to create media | |
| # This is totally mock data. The only real data is the URL and | |
| # time stamp. In production the media_data would be parse from the | |
| # file system, file names and or file metadata | |
| auth_header = {"Authorization": "Bearer " + access_token} | |
| media_data = {"video_sequence_name": "Ventana 0952", | |
| "camera_id": "Ventana", | |
| "video_name": "Ventana 0952 {}".format(timeString), | |
| "uri": url, | |
| "start_timestamp": timeString, | |
| "duration_millis": 123456} | |
| return requests.post(media_url, media_data, headers=auth_header).json() | |
| if __name__ == "__main__": | |
| """ | |
| Args: | |
| url -> A URL to a file. Should start with http but file URLS will work to | |
| time_string -> Start time of the video. Formatted as yyyy-MM-ddTHH:mm:ssZ | |
| Just use UTC times for now. | |
| """ | |
| url = sys.argv[1] | |
| time_string = sys.argv[2] | |
| response_body = main(url, time_string) | |
| print(response_body) |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
A
media_datacan have the following params:Required parameters
Optional parameters