{"id":152,"date":"2015-10-14T10:45:45","date_gmt":"2015-10-14T14:45:45","guid":{"rendered":"http:\/\/provideotech.org\/?p=152"},"modified":"2016-08-18T14:26:26","modified_gmt":"2016-08-18T18:26:26","slug":"rest-api-for-toolsonair-justin-engine-calendar","status":"publish","type":"post","link":"https:\/\/provideotech.org\/?p=152","title":{"rendered":"REST API for ToolsOnAir Just:In Engine Calendar"},"content":{"rendered":"<p>Recently I had a project that required remote systems to create calendar events for ToolsOnAir&#8217;s Just:In ingest product. While Just:In supports scheduled record, it is based on the Apple Calendar for scheduling events.<\/p>\n<p>The bad news here is that Apple Calendar local calendars don&#8217;t have any method for remote access\/sharing. The good news is that Apple Calendar can be manipulated via Applescript. Since the Just:In Multi UI generally runs on a different machine from the Just:In engine, it seemed to make sense to build a way for other systems to schedule records on an engine that may be in a machine room other that Remote Desktop\/VNC.<\/p>\n<p>The REST API is written in <a href=\"http:\/\/flask.pocoo.org\" target=\"_blank\">flask<\/a> microframework using the <a href=\"http:\/\/flask-restful.readthedocs.org\" target=\"_blank\">flask_restful<\/a> library for python.<\/p>\n<p>Source code is available on github here: <a href=\"https:\/\/github.com\/szumlins\/toa_rest\" target=\"_blank\">https:\/\/github.com\/szumlins\/toa_rest<\/a><\/p>\n<p><!--more--><\/p>\n<p>Once you have the API up and running, working with it is fairly easy. You need to POST data to the API in JSON format. The JSON looks as follows:<\/p>\n<pre lang=\"json\">{\r\n\t\"start_time\": \"2015-10-14T13:45:30\",\r\n\t\"end_time\": \"2015-10-14T13:55:30\",\r\n\t\"summary\": \"NameOfFileWithoutExtension\",\r\n\t\"description\": \"Description of event for calendar notes\",\r\n\t\"UID\": \"UNIQUE-ID-OF-THIS-CALENDAR\"\r\n}\r\n<\/pre>\n<p>This data would create an event that started at 1:45:30pm in the timezone of the engine that would end at 1:55:30pm. The output file would be named NameOfFileWithoutExtension.ext (ext being either .mov,.mp4 or .mxf depending on your settings).<\/p>\n<p>This data needs to be POSTed to the URL http:\/\/ip.of.engine:service_port\/CalendarName<\/p>\n<p>ToolsOnAir Just:In Engine will create calendars in Apple Calendar for the name of each channel you have associated with the Engine. Let&#8217;s set up a printed scenario here.<\/p>\n<pre>ToolsOnAir Channel name: Router1\r\nToolsOnAir Engine IP: 192.168.10.55\r\nAPI Service Port: 4445\r\nFilename: A_Movie.mov\r\nStart Time: October 22nd, 2015 @ 10:45:15pm\r\nEnd Time: October 22nd, 2015 @ 11:03:33pm\r\nDescription: My First Clip<\/pre>\n<p>So now we know the URL, port, calendar, and data.  We can formulate a simple curl command to send this:<\/p>\n<pre lang=\"bash\">bash-3.2# curl -X POST -H content-type:application\/json -d '{\"start_time\": \"2015-10-22T22:45:15\",\"end_time\": \"2015-10-22T23:03:33\",\"summary\": \"A_Movie\",\"description\": \"My First Clip\",\"UID\": \"1234-5678-9012\"}' http:\/\/192.168.10.55:4445\/Router1\r\n<\/pre>\n<p>On success, this should return JSON encoded success info with success or failure of event registration along with the summary (filename) and UID of the post call.<\/p>\n<p>Because the Calendar.app doesn&#8217;t refresh automatically when events are posted in this way, you may need to check and then uncheck a calendar to force a refresh. This doesn&#8217;t mean the event isn&#8217;t registered, it is simply the UI hasn&#8217;t shown it.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Recently I had a project that required remote systems to create calendar events for ToolsOnAir&#8217;s Just:In ingest product. While Just:In supports scheduled record, it is based on the Apple Calendar for scheduling events. The bad news here is that Apple Calendar local calendars don&#8217;t have any method for remote access\/sharing. The good news is that &hellip; <a href=\"https:\/\/provideotech.org\/?p=152\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;REST API for ToolsOnAir Just:In Engine Calendar&#8221;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[3,12],"tags":[],"class_list":["post-152","post","type-post","status-publish","format-standard","hentry","category-general-info","category-toolsonair"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p2bwLw-2s","_links":{"self":[{"href":"https:\/\/provideotech.org\/index.php?rest_route=\/wp\/v2\/posts\/152","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/provideotech.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/provideotech.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/provideotech.org\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/provideotech.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=152"}],"version-history":[{"count":0,"href":"https:\/\/provideotech.org\/index.php?rest_route=\/wp\/v2\/posts\/152\/revisions"}],"wp:attachment":[{"href":"https:\/\/provideotech.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=152"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/provideotech.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=152"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/provideotech.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=152"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}