Automatically schedule 2 YouTube Shorts per day using n8n + YouTube API

Hi everyone,

I’m trying to automate the scheduling of 2 YouTube Shorts per day using n8n and the YouTube Data API.

:bullseye: Goal:

  • Take all my uploaded videos (currently in private status)
  • Schedule them at a rate of 2 per day
  • Publish them between 15:00 and 23:59 UTC
  • Start scheduling from the day after the last already scheduled or published video
  • Ensure each scheduled video is at least 15 minutes in the future (to satisfy the API constraint)

:white_check_mark: What I’ve already done:

  • Retrieve all my videos using the YouTube API
  • Filter only those with the status private
  • Use a PATCH request to update the publishAt field of each video
  • Built a script in a Function node that:
    • Gets the latest scheduled/published date (publishedAt or publishAt)
    • Calculates the next available time slots for publishing
    • Assigns 2 videos per day in the given time range (15:00–23:59 UTC)

:brain: My logic:

  • I convert the publishedAt or publishAt of each video to a Date object
  • I sort them in descending order to find the most recent one
  • Then I generate upcoming time slots (2 per day), skipping the current day
  • I randomly assign a time between 15:00 and 23:59 UTC for each slot
  • I ensure that each scheduled time is at least 15 minutes later than the current time

:thinking: Where I need help:

  • I want to make sure the logic for:
    • assigning 2 videos per day
    • generating random publish times in the correct time window
    • checking the 15-minute rule
      is reliable and optimized.

If anyone here has tackled something similar, I’d love to see how you handled the scheduling logic, or any improvements you would suggest for performance or reliability.

Thanks in advance!

Describe the problem/error/question

What is the error message (if any)?

Please share your workflow

(Select the nodes on your canvas and use the keyboard shortcuts CMD+C/CTRL+C and CMD+V/CTRL+V to copy and paste the workflow.)

Share the output returned by the last node

Information on your n8n setup

  • n8n version:
  • Database (default: SQLite):
  • n8n EXECUTIONS_PROCESS setting (default: own, main):
  • Running n8n via (Docker, npm, n8n cloud, desktop app):
  • Operating system:

Use schedule node, maybe it will helps.