Resolved

YouTube series videos upload in reverse order with incorrect scheduling

Python
YouTube API
Automation
Backend
Debugging
Scheduling
Video Processing
Data Sorting

Video series parts uploading out of sequence (part 2 before part 1) with incorrect timing gaps | Python watcher system using negative sort keys caused reverse upload order, breaking YouTube scheduler logic

Issue

The YouTube video upload automation system incorrectly ordered series uploads, causing part 2 to upload before part 1. This resulted in:

  • Part 2 scheduling one year later (2026-11-17) while part 1 scheduled normally (2025-11-17).
  • Paired uploads (horizontal video + shorts) failing to synchronize, with shorts sometimes publishing a year after their corresponding horizontal video.
  • Complete breakdown of series narrative flow for viewers.

Culprit

Primary Root Cause

A negative sort key in the watcher component caused descending sort order, making part 2 sort before part 1. This was implemented as return (self.creation_time, -series_part, series_total) in run_watcher.py, which incorrectly evaluated (time, -2, 2) as less than (time, -1, 2) due to the negative value.

Secondary Issue

The scheduler’s fallback logic triggered catastrophic delays when part 2 uploaded first, adding 365 days to the schedule and exacerbating the issue.

Solution

Fix 1: Correct Sort Order

Removed the negative sign in the watcher’s sort key to enforce ascending order (part 1 before part 2). This ensured chronological upload processing and fixed the core issue.

Fix 2: Improved Scheduler Error Handling

Replaced the +365-day fallback with critical error logging and normal scheduling to prevent delays. Added explicit documentation to surface the issue for immediate resolution.

Verification

Tested with a 2-part series and paired uploads, confirming:

  • Part 1 uploads before part 2.
  • Part 2 schedules exactly 6 hours after part 1 (as configured).
  • Paired uploads share identical publish times.
  • Series appears in correct order on YouTube.