Contents
Create Episode - Plugixa Stream
POST /plugixa-stream/v1/admin/episodes
Add an episode to a title. For a movie, this is its one video.
Needs a user with the plugixa_stream_create capability (signed in with an Application Password or the login cookie). Administrators hold it; other roles only when you grant it.
Request
POST https://your-site.example/wp-json/plugixa-stream/v1/admin/episodes
Request body
Content type: application/json
| Field | Type | Required | Description |
|---|---|---|---|
series_id |
integer |
Yes on create | The title. Ignored on update. |
number |
integer |
No | 1 or more, unique within the title. On create, defaults to one more than the title’s highest number. |
title |
string |
No | Defaults to Episode and the number. |
description |
string |
No | HTML; tags WordPress does not allow in posts are removed. |
status |
string |
No | draft (the default) or publish. |
publish_at |
string |
No | With status: publish: a later date and time, site time, Y-m-d H:i, schedules the episode. Ignored without status. |
season |
integer |
No | Season number. |
provider |
string |
No | self_hosted, embed; with Pro bunny. Empty uses the site’s video service. |
asset_id |
string |
No | The video: see provider. An embed link must be https to a YouTube or Vimeo video, or an https embed URL. |
duration |
integer |
No | Seconds. |
thumbnail_id |
integer |
No | A Media Library image id, 0 for none. |
access |
string |
No | auto (follow the title’s free episodes), free or paid. Anything else reads as auto. |
price_override |
integer|null |
No | Coins for this episode PRO. null or empty for the usual price. |
intro_start |
integer|null |
No | Seconds. null clears it. Also intro_end and credits_start. |
subtitles |
object[] |
No | Pro: replaces the subtitle tracks. Each needs attachment_id; lang, label, kind (subtitles or captions) are optional. Other formats are converted to WebVTT. |
audio_tracks |
object[] |
No | Pro: replaces the dubbed audio tracks. Each needs an audio attachment_id, and lang, label. |
{
"series_id": 2814,
"number": 1,
"title": "Chapter 1: The Planet of Peril",
"status": "publish",
"provider": "self_hosted",
"asset_id": "https://archive.org/download/flash-gordon-1936/chapter-1.mp4",
"duration": 1134
}
Responses
201 Created. data is the new episode.
{
"success": true,
"data": {
"id": 2815,
"series_id": 2814,
"number": 1,
"title": "Chapter 1: The Planet of Peril",
"description": "",
"status": "publish",
"publish_at": "",
"url": "https://your-site.example/episode/flash-gordon-ep-1/",
"season": 1,
"provider": "self_hosted",
"asset_id": "https://archive.org/download/flash-gordon-1936/chapter-1.mp4",
"duration": 1134,
"thumbnail_id": 0,
"access": "auto",
"price_override": null,
"intro_start": null,
"intro_end": null,
"credits_start": null,
"thumbnail_url": "",
"subtitles": [],
"audio_tracks": []
}
}
| Field | Type | Meaning |
|---|---|---|
data.id |
integer |
The episode’s id |
data.series_id |
integer |
Its title |
data.number |
integer |
Episode number, unique within the title |
data.title |
string |
Raw title |
data.description |
string |
HTML as stored |
data.status |
string |
publish, draft or future (scheduled) |
data.publish_at |
string |
A scheduled episode’s release, site time, Y-m-d H:i:s; empty otherwise |
data.url |
string |
Public page |
data.season |
integer |
Season, 0 when not set |
data.provider |
string |
self_hosted, embed, with Pro bunny; empty means the site’s video service |
data.asset_id |
string |
A Media Library id or video URL (self-hosted), an https embed link (embed), or a video GUID (Bunny) |
data.duration |
integer |
Seconds |
data.thumbnail_id |
integer |
Media Library id, 0 for none |
data.access |
string |
auto, free or paid |
data.price_override |
integer|null |
Coins for this episode PRO, null for the usual price |
data.intro_start |
integer|null |
Seconds. Also intro_end and credits_start |
data.thumbnail_url |
string |
Thumbnail, medium size |
data.subtitles |
object[] |
Pro: subtitle tracks (lang, label, attachment_id, source, from, kind, url) |
data.audio_tracks |
object[] |
Pro: dubbed audio tracks, same fields |
Errors
| Status | Code | When |
|---|---|---|
401 / 403 |
plugixa_stream_forbidden |
The caller lacks the capability. |
422 |
plugixa_stream_invalid |
series_id is not a title, the title is a movie that already has its video, number is below 1 or already used, or an embed link is not usable. data.field names the field. |
Plus the errors every endpoint can return.
Examples
curl -s -X POST "https://your-site.example/wp-json/plugixa-stream/v1/admin/episodes" \
-u "$WP_USER:$WP_APP_PASSWORD" \
-H "Content-Type: application/json" \
-d '{"series_id":2814,"number":1,"title":"Chapter 1: The Planet of Peril","status":"publish","provider":"self_hosted","asset_id":"https://archive.org/download/flash-gordon-1936/chapter-1.mp4","duration":1134}'
<?php
$ch = curl_init('https://your-site.example/wp-json/plugixa-stream/v1/admin/episodes');
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_USERPWD => getenv('WP_USER') . ':' . getenv('WP_APP_PASSWORD'),
CURLOPT_HTTPHEADER => ['Content-Type: application/json'],
CURLOPT_POSTFIELDS => json_encode([
'series_id' => 2814,
'number' => 1,
'title' => 'Chapter 1: The Planet of Peril',
'status' => 'publish',
'provider' => 'self_hosted',
'asset_id' => 'https://archive.org/download/flash-gordon-1936/chapter-1.mp4',
'duration' => 1134,
]),
]);
$response = json_decode(curl_exec($ch), true);
curl_close($ch);
const response = await fetch('https://your-site.example/wp-json/plugixa-stream/v1/admin/episodes', {
method: 'POST',
headers: {
'Authorization': `Basic ${btoa(`${process.env.WP_USER}:${process.env.WP_APP_PASSWORD}`)}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({ series_id: 2814, number: 1, title: 'Chapter 1: The Planet of Peril', status: 'publish', provider: 'self_hosted', asset_id: 'https://archive.org/download/flash-gordon-1936/chapter-1.mp4', duration: 1134 }),
});
const { data } = await response.json();
Quick Links
Share