# Video Sender standalone worker This draft is a reusable Google Apps Script worker for publishing videos from the project owner's Gmail and Drive to one YouTube channel. Each installation has its own Apps Script project, Google authorization, trigger, settings, and upload records. ## Install 1. Open [Google Apps Script](https://script.google.com/) with the Google account that owns the destination YouTube channel and can download the private MP4s from Drive. Create a standalone project and paste `Code.gs` into its script file. 2. In Project Settings, turn on **Show appsscript.json manifest file in editor**. Replace the manifest with `appsscript.json` and save. It enables the Advanced Gmail, Drive, and YouTube services. If you linked a standard Google Cloud project, enable the corresponding APIs there as well. [Advanced services](https://developers.google.com/apps-script/guides/services/advanced) 3. In **Project Settings → Script properties**, add the settings below. Keep the project restricted to trusted editors because an editor can change the code, settings, and upload records. 4. Select and run `preflightPublisher`. Complete Google's authorization dialog, then check the execution log for `mailboxVerified` and `channelVerified`. It verifies the exact mailbox and YouTube channel and shows the configured time and visibility. 5. Run `enablePublisher`, then run `publisherStatus`. Confirm `enabled`, `matchingSettings`, and one trigger. Send the first publishing email after activation. | Script property | Value | | --- | --- | | `VS_MAILBOX` | Full address of the account that will send mail to itself. | | `VS_CHANNEL_ID` | The intended YouTube channel's `UC…` ID from the owner's [advanced account settings](https://www.youtube.com/account_advanced). | | `VS_TIME_ZONE` | Your IANA time zone, for example `Etc/UTC` or `Europe/Paris`. | | `VS_START_TIME` | Local start time in 24-hour `HH:mm`, for example `19:30`. | | `VS_VISIBILITY` | Explicit `public`, `unlisted`, or `private`. | | `VS_CATEGORY_ID` | Optional YouTube category ID. If omitted the worker uses `22` for People & Blogs. | Google manages the Apps Script authorization. The script requests read-only mailbox and Drive access, YouTube read and upload access, and permission to run the trigger and make the Google API requests. ## Submit a video Send an email from the configured mailbox to itself. The subject starts with the exact uppercase `[YT-SHORT]` prefix. Use one downloadable private Drive MP4 link and the exact title and description you want YouTube to use. ```text YOUTUBE_TITLE: The video title YOUTUBE_DESCRIPTION: The video description. DRIVE_URL: https://drive.google.com/file/d/REPLACE_WITH_FILE_ID/view ``` Use `VIDEO_URL` or `DRIVE_URL`. The worker checks Gmail's Sent label and the sender and recipient addresses. To set the audience on a specific video, add `YOUTUBE_MADE_FOR_KIDS: true` or `YOUTUBE_MADE_FOR_KIDS: false`. With no email setting, the worker uses the channel owner's declared setting when YouTube returns it. The five-minute trigger checks for the configured day's mail for 45 minutes from the chosen start time. It can continue verifying processing for 90 minutes from the start. Uploads can start several minutes after the chosen time. The worker handles at most one distinct video per scheduled day and holds multiple distinct submissions for that day. The file limit is 50,000,000 bytes. [Clock triggers](https://developers.google.com/apps-script/guides/triggers/installable) · [Apps Script quotas](https://developers.google.com/apps-script/guides/services/quotas) ## Operate and troubleshoot - Run `publisherStatus` for the latest action and any configuration issue. `uploaded` means YouTube returned a video ID. `complete` means processing and configured visibility were verified. For an upload still processing after the window, run `verifyPublisherVideo` to check it again. - To pause, run `disablePublisher`. To change time zone, start time, visibility, or category, pause, edit the properties, run preflight, and enable again. The worker preserves the expected visibility of previously uploaded videos and holds unfinished transfers when their visibility or category changes. - To switch mailbox or YouTube channel, use a new Apps Script project. Keep the earlier project disabled as needed. Within a project, Drive file IDs and Gmail message IDs remain in the upload records to avoid reposting videos. Retain these records when updating the worker. - If a transfer is interrupted, the worker checks the saved upload session before resuming. An expired or inconclusive session is reported for review. Check the intended channel in YouTube Studio for the upload before taking further action. [YouTube resumable uploads](https://developers.google.com/youtube/data/guides/using_resumable_upload_protocol) ## Connect the optional preview status bridge 1. Add a script file named `PreviewStatus` to the same Apps Script project and paste `PreviewStatus.gs` into it. 2. Add `VS_PREVIEW_STATUS_URL` with the exact HTTPS `/api/installations/status` URL supplied by the preview operator. Add `VS_PREVIEW_INSTALLATION_TOKEN` with the 64-character lowercase hexadecimal token supplied for your installation. Keep the token in Script Properties. Google authorization remains in Apps Script. 3. Run `syncPreviewStatus` and look for `reported: true` in the execution log. Ask the preview operator to check the installation's status with you. The response log reports only the HTTP status or a short outcome label. The bridge reports the enabled flag, trigger count, time zone, local start time, visibility, latest phase, time of sync, and optional scheduled day. The token authenticates each PUT request, and redirect responses stop at the first endpoint. The bridge sends an update after enabling or disabling the worker or when the phase or scheduled day changes during a scheduled run. If delivery fails, publishing continues independently. Run `syncPreviewStatus` to retry the current snapshot. Remove the two Script Properties to turn off future reports. This draft supplies the worker and an installation procedure for a user-owned project. Live validation of this reusable configuration and public-product distribution are separate milestones.