TrollflixDevelopers

Scheduling uploads

Upload now, publish later. Plan a week of memes in one script run.

Send scheduled_publish_at with a Unix timestamp (in seconds) and the meme is uploaded and processed now, then goes live at that moment.

# Publish tomorrow at 18:00 UTC
PUBLISH_AT=$(date -u -d "tomorrow 18:00" +%s)   # macOS: date -u -v+1d -v18H -v0M -v0S +%s

curl -X POST "https://uploads.backend.trollflix.com/api/php/developer/upload_video" \
  -H "Authorization: Bearer $TROLLFLIX_API_KEY" \
  -F "[email protected]" \
  -F "caption=Friday deploy energy #programming" \
  -F "scheduled_publish_at=$PUBLISH_AT"

The response echoes the time in scheduled_publish_at_unix.

Rules

RuleValueError when broken
Must be in the futurescheduled_publish_time_invalid
How far aheadup to 32 daysscheduled_publish_time_too_far (+ max_schedule_days_ahead)
Per publish day (UTC)up to 22 memesscheduled_content_day_slot_full (+ max_scheduled_per_day)

Scheduled uploads have their own daily allowance, separate from the 4 immediate uploads per day. That is what makes scheduling the right tool for posting regularly.

Plan a week

schedule_week.py
import os, uuid, requests
from datetime import datetime, timedelta, timezone

API = "https://uploads.backend.trollflix.com/api/php/developer/upload_video"
HEADERS = {"Authorization": f"Bearer {os.environ['TROLLFLIX_API_KEY']}"}

first = datetime.now(timezone.utc).replace(hour=18, minute=0, second=0, microsecond=0) + timedelta(days=1)

for day, path in enumerate(["mon.mp4", "tue.mp4", "wed.mp4"]):
    publish_at = int((first + timedelta(days=day)).timestamp())
    with open(path, "rb") as video:
        result = requests.post(
            API,
            headers=HEADERS,
            files={"file": (path, video, "video/mp4")},
            data={"scheduled_publish_at": str(publish_at), "upload_token": str(uuid.uuid4())},
            timeout=600,
        ).json()
    print(path, result.get("success"), result.get("error_message_code"))

Your scheduled memes are listed in the Trollflix app and on the website, where you can also delete one before it goes live.

On this page