alleyinteractive/wp-video-sync
Composer 安装命令:
composer require alleyinteractive/wp-video-sync
包简介
Sync videos from a hosting provider to WordPress
关键字:
README 文档
README
Contributors: alleyinteractive
Tags: alleyinteractive, wp-video-sync
Stable tag: 0.1.0
Requires at least: 6.0
Tested up to: 6.6
Requires PHP: 8.2
License: GPL v2 or later
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
- Requires the JW Player 7 for WordPress plugin to be installed, activated, and properly configured with access credentials. Also supports the premium version.
- The video object in the callback is a
stdClasswith the properties described in themediaobject under response code200in the JW Player API documentation for the media list endpoint.
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.
alleyinteractive/wp-video-sync 适用场景与选型建议
alleyinteractive/wp-video-sync 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 326.9k 次下载、GitHub Stars 达 0, 最近一次更新时间为 2024 年 07 月 23 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「JW Player」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 alleyinteractive/wp-video-sync 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 alleyinteractive/wp-video-sync 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 alleyinteractive/wp-video-sync 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
A video extension for TYPO3 built on the VideoJS HTML5 video player library. Allows you to embed video in your website using HTML5 with Flash fallback support for non-HTML5 browsers. Work on VideoJS 4.12.6 and support YouTube and Vimeo video in the same style.
A library to fetch the query information of Minecraft: Bedrock Edition servers
Vimeo API extension for Contao Open Source CMS
Responsive, mobile ready player
The essentials and basic data for a gaming backend server.
Connect both extensions to fetch user input (one powermail form) before the user can access the detail view.
统计信息
- 总下载量: 326.9k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 27
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: GPL-2.0-or-later
- 更新时间: 2024-07-23