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.

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.
| Target | Seconds | Result |
|---|---|---|
| shorts | 179 | ok, 3 billable min, $0.30 |
| shorts | 181 | refuse, over the 180 s cap |
| timeline | 1800 | ok, 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
- Python: cheapest Sume image model that lists your aspect ratio
A 25-line Python script reads Sume's image catalog, keeps models that list your aspect ratio, prices each from its endpoints record and prints the cheapest.
- Python preflight for a Sume bulk body: count, keys, bytes, caps
Check a Sume bulk-run body offline before the POST: 1 to 100 items, concurrency 1 to 16, 64 input keys, 2 MiB input, 4 MiB body and a spend cap in range.
- Sume job webhook receiver in plain Python, no framework
A 30-line stdlib http.server receiver for Sume job webhooks: raw-body HMAC, 300-second window, rotation-safe header, refuses an empty secret, answers 204.
- Python urllib: honor retry-after on a Sume 429, back off without it
A stdlib retry for GET calls that sleeps for retry-after when the 429 carries it and for a capped exponential delay when it does not, with jitter.
Written by Sume