Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 | 4x 3x 3x 3x 3x 3x 3x 3x 3x 4x 4x 4x | /**
* Internal dependencies
*/
import { OriginalVideoPressVideo, VideoPressVideo } from '../../admin/types';
export const mapVideoFromWPV2MediaEndpoint = (
video: OriginalVideoPressVideo
): VideoPressVideo => {
const {
media_details: mediaDetails,
id,
jetpack_videopress: jetpackVideoPress,
jetpack_videopress_guid: guid,
} = video;
const { videopress: videoPressMediaDetails, width, height } = mediaDetails;
const {
title,
description,
caption,
rating,
allow_download: allowDownload,
display_embed: displayEmbed,
privacy_setting: privacySetting,
needs_playback_token: needsPlaybackToken,
is_private: isPrivate,
// Whether this site still owns the video on WordPress.com. A video that was
// moved to another blog stays in this (local) library with stale metadata;
// the server marks it not-owned so the UI can flag it as read-only. Absent
// means unknown -> treat as owned so nothing is spuriously flagged.
is_owned: isOwned = true,
} = jetpackVideoPress;
const {
original: url,
poster,
upload_date: uploadDate,
duration,
file_url_base: fileURLBase,
finished,
files = {
dvd: {
original_img: '',
},
},
} = videoPressMediaDetails || {};
const { dvd } = files;
/*
* Define thumbnail picking the image from DVD file type
* Issue: https://github.com/Automattic/jetpack/issues/26319
*/
const thumbnail = dvd?.original_img ? `${ fileURLBase.https }${ dvd.original_img }` : undefined;
const filename = url?.split( '/' ).slice( -1 )[ 0 ];
return {
id,
guid,
title,
description,
caption,
url,
uploadDate,
duration,
isPrivate,
posterImage: poster,
allowDownload,
displayEmbed,
rating,
privacySetting,
needsPlaybackToken,
width,
height,
poster: {
src: poster,
},
thumbnail,
finished,
filename,
isOwned,
};
};
export const mapVideosFromWPV2MediaEndpoint = (
videos: OriginalVideoPressVideo[]
): VideoPressVideo[] => {
return videos?.map?.( mapVideoFromWPV2MediaEndpoint );
};
export const mapLocalVideoFromWPV2MediaEndpoint = (
video: OriginalVideoPressVideo
): VideoPressVideo => {
const {
media_details: mediaDetails,
id,
jetpack_videopress: jetpackVideoPress,
source_url: url,
date: uploadDate,
} = video;
const { width, height, length: duration } = mediaDetails;
const { title, description, caption } = jetpackVideoPress;
return {
id,
title,
description,
caption,
width,
height,
url,
uploadDate,
duration,
};
};
export const mapLocalVideosFromWPV2MediaEndpoint = (
videos: OriginalVideoPressVideo[]
): VideoPressVideo[] => {
return videos.map( mapLocalVideoFromWPV2MediaEndpoint );
};
|