最新更新

热门分类

更多
/** * 远程解析接口:给远程 video.php 通过文章ID读取 video_url */ add_action('rest_api_init', function () { register_rest_route('javdb/v1', '/video', array( 'methods' => 'GET', 'callback' => 'javdb_remote_video_info', 'permission_callback' => '__return_true', )); }); if (!function_exists('javdb_remote_video_info')) { function javdb_remote_video_info($request) { $id = intval($request->get_param('id')); if (!$id) { return array('code' => 0, 'msg' => '缺少文章ID'); } $post = get_post($id); if (!$post || $post->post_type !== 'post' || $post->post_status !== 'publish') { return array('code' => 0, 'msg' => '文章不存在或未发布'); } $video_url = trim(get_post_meta($id, 'video_url', true)); if (!$video_url) { return array('code' => 0, 'msg' => 'video_url为空'); } return array( 'code' => 1, 'msg' => 'ok', 'data' => array( 'id' => $id, 'title' => get_the_title($id), 'video_url' => $video_url, 'video_thumb' => get_post_meta($id, 'video_thumb', true), 'video_thumb_local' => get_post_meta($id, 'video_thumb_local', true), 'video_thumb_webp' => get_post_meta($id, 'video_thumb_webp', true), 'video_duration' => get_post_meta($id, 'video_duration', true), 'video_quality' => get_post_meta($id, 'video_quality', true), 'video_actor' => get_post_meta($id, 'video_actor', true), 'video_area' => get_post_meta($id, 'video_area', true), 'video_year' => get_post_meta($id, 'video_year', true), ), ); } }