Resolved

Automated video uploader processes horizontal and vertical videos independently, causing out-of-order uploads and missing cross-links

Automation
YouTube API
Video Processing
AsyncIO
Metadata Management

The system for uploading YouTube videos processed horizontal and vertical (Shorts) videos independently, resulting in incorrect upload order and missing links between related videos.

An automated system was responsible for uploading pairs of YouTube videos: one horizontal (standard) video and one vertical (Shorts) video. However, the system processed these videos independently, leading to incorrect upload order and missing cross-links.

Issue

The automated video uploader exhibited three critical problems:

  1. Incorrect upload order: Vertical videos (Shorts) were frequently uploaded before their corresponding horizontal videos, violating intended sequencing.
  2. Missing cross-links: Shorts descriptions lacked references to the full video, missing the “Full Video: [URL]” section.
  3. Lack of sequence awareness: The system did not respect the intended upload sequence, potentially uploading part 2 of a series before part 1.

Culprit

The original architecture used a simple first-in-first-out (FIFO) queue that treated each video independently, lacking coordination between related videos. Key technical gaps included:

  • No mechanism to associate horizontal and vertical versions of videos.
  • No priority-based processing to enforce proper upload order.
  • Metadata injection occurred post-upload, without the URL of the full video being available.
  • State management did not track pending pairs, leading to uncoordinated uploads.

Solution

Video Pair Representation

Introduced a structured representation for video pairs to logically group related videos (horizontal and vertical versions). This ensured that pairs were processed together rather than independently.

Priority-Based Processing

Replaced the FIFO queue with a priority-based queue to enforce proper upload order:

  • Horizontal videos were uploaded first to obtain their URLs.
  • Shorts were uploaded after their corresponding horizontal videos, ensuring proper sequencing.
  • Series awareness was implemented to respect the intended order within a series.

Coordinated Upload Workflow

  1. Pair Detection: Videos were grouped by base name to identify related pairs.
  2. Ordered Processing: Horizontal videos were uploaded first to generate their URLs.
  3. Metadata Injection: The URL of the horizontal video was injected into the description of the corresponding Shorts video before upload.
  4. Error Handling: If the upload of the horizontal video failed, the upload of the Shorts video was skipped.

State Management

Added mechanisms to track pending pairs in a thread-safe manner, ensuring that pairs were processed correctly and in the right order.

Result: Videos are now uploaded in the correct order, and cross-links are automatically added to Shorts descriptions, improving user experience and coordination between related content.