Python guard: refuse a Short over 180 s before the render bills

A 20-line Python check that blocks a Shorts render over 180 seconds and prices the Sume Timeline minutes (10 cents each) before you submit.

4 min readSume
All posts

Check the length in your own code before you call Timeline. YouTube says a video with a square or vertical ratio and up to three minutes is a Short, so 180 seconds is the cap you test against. Sume's Timeline accepts 1 to 1,800 seconds and bills $0.10 per whole output minute, so a 181-second file is billed as four minutes and is no longer a Short.

The guard

This runs as written with Python 3. It does not call the API; it only encodes the two numbers and the ceil-minute arithmetic.

The -(-seconds // 60) line is ceiling division, which matches the rule that Timeline bills by the ceil of the output minutes.

import sys

SHORTS_MAX_SECONDS = 180      # YouTube Help: Shorts up to three minutes
TIMELINE_MAX_SECONDS = 1800   # Sume Timeline audio.duration_seconds ceiling
LIMITS = {"shorts": SHORTS_MAX_SECONDS, "timeline": TIMELINE_MAX_SECONDS}

def check(target, seconds):
    cap = min(LIMITS[target], TIMELINE_MAX_SECONDS)
    if seconds > cap:
        return f"refuse: {seconds}s is over the {cap}s cap for {target}"
    minutes = -(-seconds // 60)  # Sume bills whole output minutes
    return f"ok: {seconds}s, {minutes} billable min, ${minutes * 0.10:.2f}"

def main():
    for target, seconds in [("shorts", 179), ("shorts", 181), ("timeline", 1800)]:
        print(target, check(target, seconds))

if __name__ == "__main__":
    sys.exit(main())

What each number comes from

The 180-second cap is from the YouTube Help page, which also sets the square or vertical aspect rule. The 1,800-second limit and $0.10 rate are from the Timeline docs.

I did not verify TikTok or Instagram caps against a vendor page for this post, so the guard has no entries for them. Add a row to LIMITS once you have read the platform's own page.

Guard results for three sample renders, read 2026-10-07
TargetSecondsResult
shorts179ok, 3 billable min, $0.30
shorts181refuse, over the 180 s cap
timeline1800ok, 30 billable min, $3.00

Where this fits

Use the guard first, then the unbilled POST /v1/timeline-1.0/plan call, which returns billable_minutes and an estimated cost without creating a job. The local check is a fast fail; the plan call is the authority on what Sume will bill.

Sources

Related posts

More in Developers

All Developers posts

Written by Sume