{"manifest":{"schemaVersion":1,"sdkVersion":"0.1.0","id":"sm.youtube","version":"2.0.0","name":"YouTube publication","description":"Prepare a reviewed, account-owned MP4 for upload to a connected YouTube channel and return its verified video reference.","kind":"task","runtime":"javascript","entry":"src/run.js","license":"MIT","provenance":{"notice":"MIT License\n\nCopyright (c) 2026 StillMade contributors\n\nPermission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n"},"inputs":{"video":{"type":"video","primary":true,"semantic":"finished_video","required":true,"sources":["user","upstream"],"description":"The exact saved MP4 export to publish."},"title":{"type":"text","required":true,"sources":["user","upstream"],"description":"YouTube video title."},"description":{"type":"text","required":false,"default":"","sources":["user","upstream","default"],"description":"YouTube description."},"tags":{"type":"text","required":false,"default":"","sources":["user","default"],"description":"Comma-separated tags."},"visibility":{"type":"text","required":false,"default":"private","sources":["user","default"],"description":"Private, unlisted, or public."},"publishAt":{"type":"text","required":false,"default":"","sources":["user","default"],"description":"Optional future ISO date; scheduled uploads stay private."},"madeForKids":{"type":"boolean","required":false,"default":false,"sources":["user","default"],"description":"YouTube made-for-kids declaration."},"aiGenerated":{"type":"boolean","required":false,"default":true,"sources":["user","default"],"description":"Altered or synthetic content disclosure."}},"outputs":{"uploadAction":{"type":"approval","role":"portable_media_action","semantic":"portable_media_action","description":"Review the exact saved video, channel, metadata and disclosures."},"publication":{"type":"json","semantic":"youtube_publication","required":false,"description":"Verified YouTube video and channel reference."}},"permissions":{"project":[],"network":[],"filesystem":[],"secrets":[],"actions":["youtube.upload"]},"ui":[{"control":"text","port":"title"},{"control":"text","port":"description"},{"control":"text","port":"tags"},{"control":"select","port":"visibility","options":["private","unlisted","public"]},{"control":"text","port":"publishAt"},{"control":"checkbox","port":"madeForKids"},{"control":"checkbox","port":"aiGenerated"}],"platforms":{"phone":{"supported":true},"browser":{"supported":true},"desktop":{"supported":true}}},"code":"const video=input.video;\nif(!video||video.kind!=='video'||typeof video.assetId!=='string'||!video.assetId||typeof video.versionId!=='string'||!video.versionId||typeof video.url!=='string'||!/^\\/api\\/media\\/[a-f0-9-]{36}\\/[a-f0-9-]{36}\\.mp4$/.test(video.url))throw new Error('Connect an exact saved MP4 video asset.');\nconst title=String(input.title||'').trim(),description=String(input.description||'').trim(),tags=String(input.tags||'').split(',').map(value=>value.trim()).filter(Boolean),visibility=String(input.visibility||'private');\nif(!title||title.length>100||description.length>5000||tags.length>30||tags.some(tag=>tag.length>100)||!['private','unlisted','public'].includes(visibility))throw new Error('Review the YouTube title, description, tags, and visibility.');\nconst publishAt=String(input.publishAt||'').trim();\nif(publishAt&&(!Number.isFinite(+new Date(publishAt))||+new Date(publishAt)<=Date.now()||visibility!=='private'))throw new Error('Schedule a future date with private visibility.');\nif(typeof input.madeForKids!=='boolean'||typeof input.aiGenerated!=='boolean')throw new Error('Review both YouTube content disclosures.');\nreturn {uploadAction:{schemaVersion:1,kind:'stillmade.media-action',operation:'youtube.upload',request:{asset:{kind:'video',assetId:video.assetId,versionId:video.versionId,url:video.url},title,description,tags,visibility,publishAt:publishAt?new Date(publishAt).toISOString():null,madeForKids:input.madeForKids,aiGenerated:input.aiGenerated},resultPort:'publication'}};\n","tests":[{"name":"Prepares a private upload from an exact saved video and reviewed disclosures","input":{"video":{"kind":"video","assetId":"export-one","versionId":"source-v1","url":"/api/media/11111111-1111-4111-8111-111111111111/44444444-4444-4444-8444-444444444444.mp4"},"title":"  Finished clip  ","description":"A finished result","tags":"customer, story","visibility":"private","publishAt":"","madeForKids":false,"aiGenerated":true},"expected":{"uploadAction":{"schemaVersion":1,"kind":"stillmade.media-action","operation":"youtube.upload","request":{"asset":{"kind":"video","assetId":"export-one","versionId":"source-v1","url":"/api/media/11111111-1111-4111-8111-111111111111/44444444-4444-4444-8444-444444444444.mp4"},"title":"Finished clip","description":"A finished result","tags":["customer","story"],"visibility":"private","publishAt":null,"madeForKids":false,"aiGenerated":true},"resultPort":"publication"}}}]}