=== ViewStream ===
Contributors: viewstream
Tags: video, video hosting, video player, streaming, hls
Requires at least: 6.4
Tested up to: 7.1
Requires PHP: 8.1
Stable tag: 1.4.0
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Upload videos to ViewStream, embed them with a block, and turn new videos, clips and AI articles into posts. Free account from the plugin.

== Description ==

ViewStream is a video platform (video hosting, adaptive HLS streaming, a video player, live channels, catch-up, clips and AI summaries) built for Israeli publishers and broadcasters. This plugin connects a WordPress site to a ViewStream account.

* **Free account from the plugin** — Settings → ViewStream → "Create a free ViewStream account": sign up, verify your e-mail, approve this site and you are back in WordPress, connected. The free plan has no time limit: 5 GB of video storage, 60 minutes of transcoding and 100 GB of viewing traffic a month (live channels are on paid plans).
* **Connect an existing account** — one button: sign in to ViewStream Studio, pick your organisation, approve. No API key to copy; Disconnect revokes the key.
* **Upload videos straight to ViewStream** — from Media → ViewStream or the block. The file goes from the browser to ViewStream storage in 64 MB parts (not through your server), with progress and resume.
* **New videos become posts** — published videos, final clips, published AI articles and, optionally, finished catch-up programmes with their AI summary. Drafts by default, or pending / published right away.
* **Signed webhooks** — ViewStream notifies the site within seconds; every delivery is signed (HMAC-SHA256) and checked. A 15-minute poll catches anything missed.
* **ViewStream video block** and `[viewstream]` shortcode — pick from your library in the editor; responsive 16:9 (9:16 for vertical clips), lazy-loaded.
* **AI articles** with chapters and quotes that jump the player to the moment; poster as featured image, tags from topics, VideoObject structured data.
* Hebrew and English, right-to-left ready.

The plugin is free (GPLv2 or later). It needs a ViewStream account, which you can create for free from the plugin; paid ViewStream plans add more storage, traffic and live channels. Nothing in the plugin is locked or time-limited.

== Installation ==

1. Plugins → Add New → search for "ViewStream" (or upload the zip) → Install → Activate.
2. Settings → ViewStream → **Create a free ViewStream account**, or **Connect to ViewStream** if you already have one. Approve the site in ViewStream Studio; the webhook is registered automatically (the site must be reachable over HTTPS; polling every 15 minutes works without it).
3. Choose what creates posts and how (draft / pending / published, post type, category, author, player).
4. Upload a video from Media → ViewStream, or add the "ViewStream video" block to a post.

== Frequently Asked Questions ==

= Do I need an account? =
Yes, the plugin is a client of the ViewStream video platform. You can create a free account from the plugin itself: Settings → ViewStream → "Create a free ViewStream account". The free plan has no time limit and includes 5 GB of video storage, 60 minutes of transcoding a month and 100 GB of viewing traffic a month; live channels are on paid plans. Nothing is sent to ViewStream until you press "Create a free ViewStream account" or "Connect to ViewStream".

= The player says "This video is not available on this site" or stays blank =
Your ViewStream account uses playback protection. In ViewStream Studio → Delivery → Protection, add this site's domain to "Sites allowed to embed the player" (iframe embed), "Allowed referrer sites" and "Allowed player origins (CORS)" (player tag). Settings → ViewStream shows the exact domain to add.

= Does the video pass through my WordPress server? =
No. The site asks ViewStream for an upload-only token (with its key, server side) and the browser sends the parts directly to ViewStream; the browser never sees the API key.

= Is the API key safe? =
It is stored in its own option (not autoloaded), never printed back to any page, and only administrators can change it. "Disconnect" revokes it in ViewStream.

= What can reach the site from outside? =
Only the webhook route `/wp-json/viewstream/v1/webhook`, and it does nothing unless the request carries a valid ViewStream signature less than 5 minutes old. Even then the data is fetched from the ViewStream API, never taken from the request.

= Does it publish the whole back catalogue? =
No. Polling imports only items newer than the moment it was switched on. Older items can be added from Media → ViewStream.

= What is removed when I delete the plugin? =
All its options, transients and scheduled events (on every site of a multisite network). Posts it created stay, and your videos stay in your ViewStream account.

== External services ==

This plugin is a client of the ViewStream video platform (https://www.viewstream.co.il/), operated by Online Advertising & Video Streaming Solutions Ltd. It does not contact ViewStream until an administrator presses "Create a free ViewStream account" or "Connect to ViewStream" (or saves a manual API key), and it sends data only as described here. It has no analytics or tracking of its own.

* **ViewStream Studio** (`https://studio.viewstream.co.il`): "Create a free ViewStream account" and "Connect to ViewStream" send the administrator's browser to Studio's sign-up or consent page with the site's admin address, a callback address, the admin's language and a one-time PKCE challenge, so a ViewStream user can create an account and approve the connection. Sign-up data (name, e-mail, password) is entered on Studio, never on this site.
* **ViewStream API** (`https://api.viewstream.co.il`, or the API address set under "Advanced"): when the connection is completed, tested or disconnected, when an editor searches the library or uploads a video, every 15 minutes while polling is on, and when a signed webhook arrives. It sends the site's API key, the site's address (in the user agent), its webhook and admin addresses, search text, and the names, sizes and titles of uploaded videos. It reads videos, clips, programmes, AI articles and their posters, which become posts on this site.
* **ViewStream storage** (`https://api.viewstream.co.il/v1/upload-parts/…`): an uploaded video file goes from the uploader's browser straight to ViewStream.
* **ViewStream player** (`https://player.viewstream.co.il`) and the account's video CDN: posts with a ViewStream video (and the block preview in the editor) load the player, as an iframe or the player script `https://player.viewstream.co.il/embed.js`, so visitors' browsers request the player and the video from ViewStream (their IP address and browser details reach ViewStream as with any embedded video). The player can keep the playback position in the visitor's browser.

Terms of service: https://www.viewstream.co.il/terms/ — Privacy policy: https://www.viewstream.co.il/privacy/

== Screenshots ==

1. Settings → ViewStream before connecting: create a free account or connect an existing one.
2. Settings → ViewStream once connected: the organisation, the key's scopes, the player and publishing options.
3. Media → ViewStream: upload a video straight to ViewStream and create posts from your library.
4. The ViewStream video block in the editor: pick a video from your library or upload a new one.

== Changelog ==

= 1.4.0 =
* Subtitles for uploaded videos: a site setting (account default, create, none) and a per-upload choice in the upload panel.
* Large uploads: the upload may take up to 24 hours (the upload token is extended as parts arrive).

= 1.3.0 =
* "Create a free ViewStream account" in Settings → ViewStream: sign up for the free plan from the plugin and come back connected (same secure flow as Connect).
* Settings → ViewStream lists what the free plan includes.
* WordPress.org readme: external services, FAQ and screenshots.

= 1.2.0 =
* Tested with WordPress 7.1 and PHP 8.1–8.5.
* Catch-up programmes are imported when the programme was recorded, also when AI summaries are off for the account.
* API errors show the field reason; Settings → ViewStream explains what an account with playback protection must allow.
* WordPress.org Plugin Check and the WordPress coding standards pass; uninstall also cleans every site of a multisite network.

= 1.1.0 =
* Connect to ViewStream (authorisation code + PKCE) instead of pasting a key; Disconnect revokes the key.
* Upload video from Media → ViewStream and the block, straight to ViewStream storage, with resume.

= 1.0.0 =
* First release.

== Upgrade Notice ==

= 1.4.0 =
Choose whether videos uploaded from WordPress get automatic subtitles.

= 1.3.0 =
New: create a free ViewStream account straight from Settings → ViewStream.
