Skip to content

Parse videopress media details #841

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: trunk
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions scripts/setup-test-site.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ tries=0
while true; do

code=0
wp db check || code=$?
wp db check --skip-ssl || code=$?

if [ $code == 0 ]; then
echo 'Database Ready'
Expand Down Expand Up @@ -169,5 +169,4 @@ wp option update timezone_string "America/New_York"

cp -rp wp-content/plugins wp-content/plugins-backup

wp db export --add-drop-table wp-content/dump.sql

wp db export --skip-ssl --add-drop-table wp-content/dump.sql
1 change: 1 addition & 0 deletions wp_api/src/jetpack/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use crate::request::endpoint::AsNamespace;
pub mod client;
pub mod connection;
pub mod endpoint;
pub mod videopress;

pub(crate) struct JetpackNamespace();

Expand Down
32 changes: 32 additions & 0 deletions wp_api/src/jetpack/videopress.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
use serde::{Deserialize, Serialize};

use crate::media::MediaDetails;

#[derive(Debug, Serialize, Deserialize, uniffi::Record)]
pub struct VideoPressMediaDetails {
pub width: u32,
pub height: u32,
pub videopress: VideoPressDetails,
}

#[derive(Debug, Serialize, Deserialize, uniffi::Record)]
pub struct VideoPressDetails {
pub duration: u64,
pub poster: String,
}

#[uniffi::export(with_foreign)]
pub trait VideoPressMediaDetailsExtension: Send + Sync {
fn parse_videopress(&self, mime_type: String) -> Option<VideoPressMediaDetails>;
}

#[uniffi::export]
impl VideoPressMediaDetailsExtension for MediaDetails {
fn parse_videopress(&self, mime_type: String) -> Option<VideoPressMediaDetails> {
if mime_type != "video/videopress" {
return None;
}

serde_json::from_str::<VideoPressMediaDetails>(self.payload.get()).ok()
}
}
2 changes: 1 addition & 1 deletion wp_api/src/media.rs
Original file line number Diff line number Diff line change
Expand Up @@ -544,7 +544,7 @@ pub struct SparseMedia {
#[derive(Debug, Serialize, Deserialize, uniffi::Object)]
#[serde(transparent)]
pub struct MediaDetails {
payload: Box<RawValue>,
pub payload: Box<RawValue>,
}

#[uniffi::export]
Expand Down