查找数据库标题相同的文章ID
$post_title = trim(hm_strip_slashes($post_title));
$sql = "SELECT `ID` FROM $wpdb->posts WHERE `post_title` = '$post_title' AND `post_type` = 'post' ORDER BY ID DESC LIMIT 0,1";
$t_row = $wpdb->get_results($sql);
$t_row_ID = $t_row[0];
global $id;
$id = $t_row_ID->ID;
获取采集和文章的备注信息、日期
$zidingyi = $post['post_meta']['subtitle'];
$zidingyi = trim(hm_strip_slashes($zidingyi));
$oldzidingyi = get_post_meta( $id, "subtitle",true);
$dtyear = $post['post_meta']['releaseyear'];
$dtyear = trim(hm_strip_slashes($dtyear));
$olddtyears = get_post_meta( $id, "releaseyear",true);
判断如果同时满足有相同文章、备注信息不同、年份一直、有M3U8地址,则更新视频地址
if(!empty($id) AND $oldzidingyi != $zidingyi AND !empty($playurl) AND $olddtyears == $dtyear){
$i = 0;$playurls = array();$singeurls = explode("#", $playurl,-1);
foreach($singeurls as $singeurl){
$m3u8title = substr($singeurl,0,strpos($singeurl,'$'));
$m3u8url = trim(strrchr($singeurl,'$'),'$');
if ($i < 1) { of_set_posts_meta($id, 'posts_zibpay','video_url', $m3u8url);
of_set_posts_meta($id, 'posts_zibpay','video_title', $m3u8title);
} else
{$playurls[$i -1] = array(
'title' => $m3u8title,
'url' => $m3u8url,
);
}
$i++;
}
of_set_posts_meta($id, 'posts_zibpay','video_episode', $playurls);
update_post_meta($id, "subtitle", $zidingyi);
$newdate = date("Y-m-d H:i:s");
$postdddd = array(
'ID' => $id,
'post_modified' => $newdate,
'post_modified_gmt' => $newdate
);
wp_update_post($postdddd);
echo '发布成功';
}
© 版权声明
THE END
暂无评论内容