WP Manifestindependent plugin directory
manifest / media / wp-video-sync

WP Video Sync WP Registry grade A. No security issues foundWP RegistryNo security issues foundOpen the reportA

Sync videos from a hosting provider to WordPress

★ 0stars
430kcomposer installs
v0.2.0latest · 2 years ago

Install

Download source zip No release zip yet

This is the repository archive. It installs, but the folder name will carry the branch suffix and updates will not flow.

Install straight from GitHub with WP-CLI:

wp plugin install https://github.com/alleyinteractive/wp-video-sync/archive/refs/heads/develop.zip

On Packagist as alleyinteractive/wp-video-sync:

composer require alleyinteractive/wp-video-sync
No built-in updater. New versions won't appear under Dashboard → Updates. Install new releases yourself, or let Git Updater track the repository.

Sync videos from a hosting provider to WordPress.

Runs a scheduled task to sync videos from a supported video hosting provider to WordPress in batches based on the last modified date of the video. Implementers are responsible for installing and configuring a compatible plugin, choosing it as an adapter, and defining the callback that will be run for each video, which will be responsible for performing any post creations or updates in WordPress.

This plugin is a great way to sync videos uploaded to a hosting provider (such as JW Player) to WordPress, such that the video itself remains on the hosting provider, but the video can be displayed in WordPress using a player block or shortcode, appears at its own unique URL, and can be included in search results.

Installation

You can install the package via Composer:

composer require alleyinteractive/wp-video-sync

Usage

Activate the plugin in WordPress and use it like so:

use Alley\WP\WP_Video_Sync\Adapters\JW_Player_7_For_WP;
use Alley\WP\WP_Video_Sync\Sync_Manager;
use DateInterval;
use DateTimeImmutable;
use WP_Query;

add_action( 'plugins_loaded', function () {
    $sync_manager = Sync_Manager::init()
        ->with_adapter( new JW_Player_7_For_WP() )
        ->with_frequency( 'hourly' )
        ->with_batch_size( 1000 )
        ->with_callback(
            function ( $video ) {
                $existing_video = new WP_Query( [ 'meta_key' => '_jwppp-video-url-1', 'meta_value' => $video->id ] );
                $existing_id    = $existing_video->posts[0]->ID ?? 0;
                $duration       = '';
                try {
                    if ( ! empty( $video->metadata->duration ) ) {
                        $duration = ( new DateTimeImmutable() )
                            ->add( new DateInterval( sprintf( 'PT%dS', (int) $video->metadata->duration ) ) )
                            ->diff( new DateTimeImmutable() )->format( 'H:i:s' );
                    }
                } catch ( Exception $e ) {
                    $duration = '';
                }
                wp_insert_post(
                    [
                        'ID'            => $existing_id,
                        'post_type'     => 'post',
                        'post_status'   => 'publish',
                        'post_title'    => $video->metadata->title,
                        'post_content'  => $video->metadata->description ?? '',
                        'post_date'     => DateTimeImmutable::createFromFormat( DATE_W3C, $video->created )->format( 'Y-m-d H:i:s' ),
                        'post_modified' => DateTimeImmutable::createFromFormat( DATE_W3C, $video->last_modified )->format( 'Y-m-d H:i:s' ),
                        'meta_input'    => [
                            '_jwppp-video-url-1'           => $video->id,
                            '_jwppp-cloud-playlist-1'      => 'no',
                            '_jwppp-sources-number-1'      => 1,
                            '_jwppp-video-title-1'         => $video->metadata->title,
                            '_jwppp-video-description-1'   => $video->metadata->description ?? '',
                            '_jwppp-activate-media-type-1' => 0,
                            '_jwppp-playlist-carousel-1'   => 0,
                            '_jwppp-video-duration-1'      => $duration,
                            '_jwppp-video-tags-1'          => $video->metadata->tags ?? '',
                        ],
                    ]
                );
            }
        );
} );

This will configure the plugin to import a batch of 1000 videos every hour from JW Player, sorted by least to most recently updated, starting with the date and time of the last video that was updated. If videos have already been imported (as identified by the postmeta value saved for the unique video ID) they will be updated rather than created. New videos will be created. The example code above uses the post post type for this purpose, but the code could easily be adapted to use a custom post type. Additionally, the post content could be set to include a Gutenberg block or a shortcode for a player.

Supported Adapters

As of now, the plugin only supports JW Player 7 for WordPress (both the free and premium versions). Other adapters may be added in the future.

JW Player 7 for WordPress

Releasing the Plugin

New versions of this plugin will be created as releases in GitHub once ready.

Changelog

Please see CHANGELOG for more information on what has changed recently.

Credits

This project is actively maintained by Alley Interactive. Like what you see? Come work with us.

License

The GNU General Public License (GPL) license. Please see License File for more information.

Releases

2 releases.

Tag
Published
v0.2.0 latest
Oct 9, 2024 2 years ago
Jul 23, 2024 2 years ago

These releases are tags only. The author does not attach a packaged zip, so there are no download counts to report.

A grade

Security

WP Video Sync 0.2.0 · audited by WP Registry

No security issues found.

Audited release
0.2.0
Findings
none
Worst severity
—
Content hash
a5474a291c033594c8f03807…

WP Registry hashes the installable build and reports on that exact bytes-for-bytes copy. Embargoed findings are withheld until they are disclosed, so a clean verdict means nothing public is outstanding. WP Manifest does not audit code itself.