苹果cms解决豆瓣评分失效的方法

苹果cms后台豆瓣评分失效,无法获取豆瓣评分以及相关资料

是一套不可多得的影视cms,可以轻松搭建一个免费电影网站,由于包含大量的版权纠纷,导致苹果cms官方一直无人更新维护,目前属于无维护状态,程序后台的自动获取的功能由于豆瓣API更新导致无法获取评分以及资料,下面来解决这个问题。

手动查询豆瓣评分以及视频数据

下面是苹果cms v10 豆瓣评分信息采集api接口源码,将PHP源码复制保存为douban.php

然后将douban.php上传至网站根目录下。

<?php
@header("Content-type: text/html;charset=utf-8");
define('SELF', pathinfo(__FILE__, PATHINFO_BASENAME));
define('FCPATH', str_replace("\\", "/", str_replace(SELF, '', __FILE__)));
if($_GET['id']){
$id=$_GET['id']; //豆瓣ID
$callback=$_GET['callback'];
if(stristr($id,".com")==true){
$id=str_substr('subject/','/', $id);
}else{
$id=$id;
}
$file = FCPATH.'/douban/'.$id.'.txt';
if(file_exists($file)){
$vurl = file_get_contents($file);
}else{
$data = geturl('https://movie.douban.com/subject/'.$id.'/');
$data=str_replace(" / ",",",$data); //别名
$txt3 = str_substr("首播:</span> ","<br/>", $data);
if($txt3==''){
$vod_pic = str_substr('"image": "','",', $data);
$vod_score=str_substr('<strong class="ll rating_num" property="v:average">','</strong>', $data); //评分
$vod_reurl=str_substr('data-url="','"', $data); //豆瓣地址
$a_name=str_substr('<i class="">','</i>', $data);
if(baohan($a_name,'剧情简介')=='1'){
$d_name=str_substr('<div>','的剧情简介', '<div>'.$a_name);
}elseif(baohan($a_name,'的分集短评')=='1'){
$d_name=str_substr('<div>','的分集', '<div>'.$a_name);
}elseif(baohan($a_name,'的演职员')=='1'){
$d_name=str_substr('<div>','的演职员', '<div>'.$a_name);
}elseif(baohan($a_name,'的图片')=='1'){
$d_name=str_substr('<div>','的图片', '<div>'.$a_name);
}elseif(baohan($a_name,'的短评')=='1'){
$d_name=str_substr('<div>','的短评', '<div>'.$a_name);
}elseif(baohan($a_name,'的影评')=='1'){
$d_name=str_substr('<div>','的影评', '<div>'.$a_name);
}
$a_name=str_substr('<span property="v:itemreviewed">','</span>', $data);
$vod_year=str_substr('<span class="year">(',')</span>', $data); //年代
$txt1 = str_substr("导演</span>: <span class='attrs'>","</span></span><br/>", $data);
$vod_director=preg_replace("/<a[^>]*>(.*)<\/a>/isU",'${1}',$txt1); //导演
$txt = str_substr("主演</span>: <span class='attrs'>","</span></span><br/>", $data);
$d_starring=preg_replace("/<a[^>]*>(.*)<\/a>/isU",'${1}',$txt);
$vod_actor=str_replace("'",',',$d_starring); //主演
$txt5 = str_substr("编剧</span>: <span class='attrs'>","</span></span><br/>", $data);
$vod_writer=preg_replace("/<a[^>]*>(.*)<\/a>/isU",'${1}',$txt5); //编辑
$txt2 = str_substr("类型:</span> ","<br/>", $data);
$vod_class=preg_replace("/<span[^>]*>(.*)<\/span>/isU",'${1}',$txt2); //分类
$vod_area = str_substr("制片国家/地区:</span> ","<br/>", $data); //地区
$vod_lang = str_substr("语言:</span> ","<br/>", $data); //语言
$d_subname=str_substr("又名:</span> ","<br/>", $data);
$vod_sub=str_replace("'","'",$d_subname); //别名
$txt3 = str_substr("上映日期:</span> ","<br/>", $data);
$vod_pubdate=preg_replace("/<span[^>]*>(.*)<\/span>/isU",'${1}',$txt3); //上映日期
$vod_duration=str_substr('片长:</span> <span property="v:runtime" content="','">', $data); //片长
$d_content=str_substr('<span property="v:summary" class="">','</span>', $data);
if($d_content==''){
$d_content=str_substr('<span class="all hidden">','</span>', $data);
}
$vod_content=str_replace("'","'",$d_content); //简介
$vod_total=''; //集数
if(strstr($vod_area,"中国")==true){
    $vod_remarks='高清国语';
}elseif(strstr($vod_area,"台湾")==true){
    $vod_remarks='高清国语';
}else{
    $vod_remarks='高清中字';
}
}else{
$vod_pic = str_substr('"image": "','",', $data);
$vod_score=str_substr('<strong class="ll rating_num" property="v:average">','</strong>', $data); //评分
$vod_reurl=str_substr('data-url="','"', $data); //豆瓣地址
$a_name=str_substr('<i class="">','</i>', $data);
if(baohan($a_name,'剧情简介')=='1'){
$d_name=str_substr('<div>','的剧情简介', '<div>'.$a_name);
}elseif(baohan($a_name,'的分集短评')=='1'){
$d_name=str_substr('<div>','的分集', '<div>'.$a_name);
}elseif(baohan($a_name,'的演职员')=='1'){
$d_name=str_substr('<div>','的演职员', '<div>'.$a_name);
}elseif(baohan($a_name,'的图片')=='1'){
$d_name=str_substr('<div>','的图片', '<div>'.$a_name);
}elseif(baohan($a_name,'的短评')=='1'){
$d_name=str_substr('<div>','的短评', '<div>'.$a_name);
}elseif(baohan($a_name,'的影评')=='1'){
$d_name=str_substr('<div>','的影评', '<div>'.$a_name);
}
$a_name=str_substr('<span property="v:itemreviewed">','</span>', $data);
$vod_year=str_substr('<span class="year">(',')</span>', $data); //年代
$txt1 = str_substr("导演</span>: <span class='attrs'>","</span></span><br/>", $data);
$vod_director=preg_replace("/<a[^>]*>(.*)<\/a>/isU",'${1}',$txt1); //导演
$txt = str_substr("主演</span>: <span class='attrs'>","</span></span><br/>", $data);
$vod_actor=preg_replace("/<a[^>]*>(.*)<\/a>/isU",'${1}',$txt); //主演
$txt5 = str_substr("编剧</span>: <span class='attrs'>","</span></span><br/>", $data);
$vod_writer=preg_replace("/<a[^>]*>(.*)<\/a>/isU",'${1}',$txt5); //编辑
$txt2 = str_substr("类型:</span> ","<br/>", $data);
$vod_class=preg_replace("/<span[^>]*>(.*)<\/span>/isU",'${1}',$txt2); //分类
$vod_area = str_substr("制片国家/地区:</span> ","<br/>", $data); //国家
$vod_lang = str_substr("语言:</span> ","<br/>", $data); //语言
$d_subname=str_substr("又名:</span> ","<br/>", $data);
$vod_sub=str_replace("'","'",$d_subname); //别名
$txt3 = str_substr("首播:</span> ","<br/>", $data);
$vod_pubdate=preg_replace("/<span[^>]*>(.*)<\/span>/isU",'${1}',$txt3); //上映日期
$vod_duration=str_substr('单集片长:</span> ','<br/>', $data); //片长
$vod_duration=str_replace("分钟","",$vod_duration);
$d_content=str_substr('<span property="v:summary" class="">','</span>', $data);
if($d_content==''){
$d_content=str_substr('<span class="all hidden">','</span>', $data);
}
$vod_content=str_replace("'","'",$d_content); //简介
$vod_total=str_substr('集数:</span> ','<br/>', $data); //集数
$vod_remarks='总集数'.$vod_total;
}
if($vod_sub==''){
$vod_sub=$a_name.$vod_year;
}
if($vod_year==''){
$vod_year='内详';
}
if($vod_score==''){
$vod_score=rand(1,4).'.'.rand(0,9);
}
if($vod_director==''){
$vod_director='内详';
}
if($vod_actor==''){
$vod_actor='内详';
}
if($vod_content==''){
$vod_content='内详';
}
if($d_name==''){
$vurl='({"code":102,"auth":"豆瓣评分","msg":"资料采集失败"});';
}else{
$info['vod_name'] = $d_name;
$info['vod_sub'] = $vod_sub.','.$a_name;
$info['vod_pic'] = $vod_pic;
$info['vod_year'] = $vod_year;
$info['vod_lang'] = $vod_lang;
$info['vod_area'] = $vod_area;
$info['vod_remarks'] = $vod_remarks;
$info['vod_total'] = $vod_total;
$info['vod_serial'] = '';
$info['vod_isend'] = 1;
$info['vod_class'] = $vod_class;
$info['vod_tag'] = '';
$info['vod_actor'] = $vod_actor;
$info['vod_director'] = $vod_director;
$info['vod_pubdate'] = $vod_pubdate;
$info['vod_writer'] = $vod_writer;
$info['vod_score'] = $vod_score;
$info['vod_score_num'] = rand(100,1000);
$info['vod_score_all'] = rand(200,500);
$info['vod_douban_score'] = $vod_score;
$info['vod_duration'] = strip_tags($vod_duration);
$info['vod_reurl'] = $vod_reurl;
$info['vod_author'] = $vod_author;
$info['vod_content'] = cutstr_html($vod_content);
$info['vod_douban_id'] = $id;
$vurl='({"code":1,"auth":"豆瓣评分","msg":"资料采集成功","data":'.json_encode($info).'});';
}
// file_put_contents($file,$vurl);
}
echo $callback.$vurl;
}else{
echo $callback.'({"code":102,"auth":"豆瓣评分","msg":"资料采集失败"});';
}
function baohan($str,$needle){
$tmparray = explode($needle,$str);
if(count($tmparray)>1){
    $yyy='1';
}else{
    $yyy='2';
}
return $yyy;
}
function tugeturl($url){
     if(function_exists('curl_init')){
         $ch = curl_init();
         $timeout = 30;
         curl_setopt ($ch,CURLOPT_URL,$url);
         curl_setopt ($ch,CURLOPT_SSL_VERIFYPEER, false); // 跳过证书检查  
         curl_setopt ($ch,CURLOPT_SSL_VERIFYHOST, true);
         curl_setopt ($ch,CURLOPT_RETURNTRANSFER,1);
         curl_setopt ($ch,CURLOPT_REFERER, $url);  
         curl_setopt ($ch,CURLOPT_CONNECTTIMEOUT,$timeout);
         $handles = curl_exec($ch);
         curl_close($ch);
      }else{
         $handles = @file_get_contents($url);
      }
  return $handles;
}
function geturl($url){
     if(function_exists('curl_init')){
         $ch = curl_init();
         $timeout = 30;
         curl_setopt ($ch,CURLOPT_URL,$url);
         curl_setopt ($ch,CURLOPT_RETURNTRANSFER,1);
         curl_setopt ($ch,CURLOPT_REFERER, $url);  
         curl_setopt ($ch,CURLOPT_CONNECTTIMEOUT,$timeout);
         $handles = curl_exec($ch);
         curl_close($ch);
      }else{
         $handles = @file_get_contents($url);
      }
  return $handles;
}
function getvrl($url){
    $vurl = str_replace(array('"',"'"),array("'","‘"),$url);
    return $vurl;
}
function cutstr_html($string){
    $string = strip_tags($string);
    $string = trim($string);
    $string = str_replace("\t","",$string);
    $string = str_replace("\r\n","",$string);
    $string = str_replace("\r","",$string);
    $string = str_replace("\n","",$string);
    $string = str_replace(" ","",$string);
    $string = str_replace(" ","",$string);
    return trim($string);
}
function str_substr($start, $end, $str){
    $temp = explode($start, $str, 2);
    $content = explode($end, $temp[1], 2);
    return $content[0];
}
?>

接着在FTP中打开网站的/application/admin/view/vod/info.html 文件,

搜索:url: '

第719行

timeout: 5000,
url: '//' + 'api' + '.' + 'mac'+ 'cms' + '.'+ 'la' + '/douban/index/id/' + id,

将上面两行替换为:

timeout: 10000,
url: 'https://你的域名/douban.php?id=' + id,

苹果cms解决豆瓣评分失效的方法-1

现在点击查询数据之后,就可以成功获取豆瓣评分,以及相关内容了。

测试douban.php文件是否有数据返回,在文件后面加上?id=36151692,数字是豆瓣编号。

https://你的域名/douban.php?id=36151692

({"code":1,"auth":"豆瓣评分","msg":"资料采集成功","data":{"vod_name":"\u5468\u5904\u9664\u4e09\u5bb3","vod_sub":"The Pig, the Snake, and the Pigeon,\u5468\u5904\u9664\u4e09\u5bb3 \u5468\u8655\u9664\u4e09\u5bb3","vod_pic":"https:\/\/img3.doubanio.com\/view\/photo\/s_ratio_poster\/public\/p2905021483.jpg","vod_year":"2023","vod_lang":"\u6c49\u8bed\u666e\u901a\u8bdd,\u95fd\u5357\u8bed,\u7ca4\u8bed","vod_area":"\u4e2d\u56fd\u53f0\u6e7e","vod_remarks":"\u9ad8\u6e05\u56fd\u8bed","vod_total":"","vod_serial":"","vod_isend":1,"vod_class":"\u52a8\u4f5c,\u72af\u7f6a","vod_tag":"","vod_actor":"\u962e\u7ecf\u5929,\u8881\u5bcc\u534e,\u9648\u4ee5\u6587,\u738b\u51c0,\u8c22\u743c\u7156,\u674e\u674e\u4ec1,\u5218\u5b50\u94e8,\u66fe\u73ee\u745c,\u9648\u79c9\u4f51 ,\u6e38\u5b89\u987a,\u90d1\u6709\u6770,\u76db\u9274,\u5434\u5955\u84c9,\u9ec4\u8fea\u626c,\u66fe\u5411\u9547,\u6c88\u5a01\u5e74,\u6768\u8fe6\u6069,\u66fe\u7693\u6cfd,\u90d1\u6c38\u5cb3,\u5f20\u542f\u4e50,\u82cf\u8000\u5ead,\u7ec3\u5bb6\u8c6a,\u674e\u660e\u54f2,\u5ed6\u5a01\u8fea,\u7f57\u632f\u4f51,\u738b\u53c8\u6b63,\u6797\u541b\u67d4,\u9ec4\u701a\u5fb7,\u5218\u5b50\u670b,\u7f57\u80fd\u534e,\u8bb8\u8389\u5ef7,\u6797\u745e\u534e,\u5218\u79be\u80b2,\u90ed\u5bb9\u817e,\u674e\u5e74\u96c4,\u8bb8\u5fb7\u57ce,\u9ec4\u60e0\u537f,\u5218\u6615\u660a","vod_director":"\u9ec4\u7cbe\u752b","vod_pubdate":"2024-03-01(\u4e2d\u56fd\u5927\u9646),2023-10-06(\u4e2d\u56fd\u53f0\u6e7e)","vod_writer":"\u9ec4\u7cbe\u752b","vod_score":"8.1","vod_score_num":354,"vod_score_all":331,"vod_douban_score":"8.1","vod_duration":"134","vod_reurl":"https:\/\/movie.douban.com\/subject\/36151692\/","vod_author":null,"vod_content":"\u901a\u7f09\u72af\u9648\u6842\u6797\uff08\u962e\u7ecf\u5929\u9970\uff09\u5728\u9003\u4ea1\u85cf\u533f\u4e2d\u5931\u53bb\u6700\u540e\u4e00\u4e2a\u4eb2\u4eba\uff0c\u540c\u65f6\u5f97\u77e5\u81ea\u5df1\u53ea\u6709\u4e0d\u5230\u4e09\u4e2a\u6708\u7684\u751f\u547d\u3002\u4e07\u5ff5\u4ff1\u7070\u7684\u4ed6\u539f\u6253\u7b97\u6295\u6848\u81ea\u9996\uff0c\u53ef\u662f\u5f53\u53d1\u73b0\u4ed6\u5728\u4e09\u5927\u901a\u7f09\u72af\u4e2d\u4ec5\u4ec5\u6392\u540d\u7b2c\u4e09\u65f6\uff0c\u5185\u5fc3\u7a81\u7136\u8e81\u52a8\u8d77\u6765\u3002\u5728\u6b64\u4e4b\u540e\uff0c\u4ed6\u51b3\u5b9a\u4eff\u6548\u53e4\u65f6\u5019\u5468\u5904\u9664\u4e09\u5bb3\u7684\u6545\u4e8b\uff0c\u4e34\u7ec8\u4e4b\u9645\u8981\u5728\u6c5f\u6e56\u4e0a\u7559\u4e0b\u4ed6\u7684\u4f20\u5947\u540d\u53f7\u3002\u901a\u8fc7\u5730\u4e0b\u533b\u751f\u5f20\u8d35\u537f\uff08\u8c22\u743c\u7156\u9970\uff09\uff0c\u9648\u6842\u6797\u627e\u5230\u4e86\u5206\u522b\u6392\u540d\u7b2c\u4e8c\u548c\u7b2c\u4e00\u7684\u9999\u6e2f\u4ed4\uff08\u8881\u5bcc\u534e\u9970\uff09\u548c\u725b\u5934\u7684\u7ebf\u7d22\uff0c\u968f\u540e\u8e0f\u4e0a\u5f81\u9014\u3002\u8d2a\u55d4\u75f4\uff0c\u4e09\u6bd2\u71ac\u714e\uff0c\u7ea2\u5c18\u6df7\u6c8c\u4e4b\u4eba\uff0c\u88ab\u4e1a\u969c\u7f20\u7ed5\uff0c\u6c38\u8fdc\u65e0\u6cd5\u8df3\u8131\u56e0\u679c\u8f6e\u56de\u2026\u2026\u7535\u5f71\u5f15\u7528\u7684\u201c\u5468\u5904\u9664\u4e09\u5bb3\u201d\u5178\u6545\uff0c\u89c1\u4e8e\u300a\u664b\u4e66\u00b7\u5468\u5904\u4f20\u300b\u548c\u300a\u4e16\u8bf4\u65b0\u8bed\u300b\u3002","vod_douban_id":"36151692"}});

成功有数据返回,已经生效了,快去后台更新吧,这个豆瓣采集美中不足的就是需要手工采集,你需要点击获取资料才能采集到豆瓣里相关的内容。

苹果cms采集二次更新豆瓣ID、豆瓣评分

在使用苹果cms采集影视资源站的数据时,有些影片没有评分以及豆瓣ID,当二次更新时的资源站存在豆瓣ID和豆瓣评分,但是在入库的时候,无法同步更新豆瓣评分。下面教你如何解决这个问题。

采集参数配置的二次更新规则中没有豆瓣评分的选项,需要更改苹果cms的管理文件,添加豆瓣评分选项。

打开 application/admin/view/system/configcollect.html 第155行<div class="layui-input-block"> 的下面增加如下代码

<input type="checkbox" lay-skin="primary" name="collect[vod][uprule][]" value="tv" title="豆瓣ID" {if condition="strpos($config['collect']['vod']['uprule'],'tv') !==false"}checked {/if}>
<input type="checkbox" lay-skin="primary" name="collect[vod][uprule][]" value="av" title="豆瓣评分" {if condition="strpos($config['collect']['vod']['uprule'],'av') !==false"}checked {/if}>

然后打开 application/common/model/Collect.php 在539行,替换代码。

原始代码

if($config['score']==1) {
    $v['vod_score_num'] = rand(1, 1000);
    $v['vod_score_all'] = $v['vod_score_num'] * rand(1, 10);
    $v['vod_score'] = round($v['vod_score_all'] / $v['vod_score_num'], 1);
}

替换为

if($config['score']==1) {
    $v['vod_score_num'] = rand(1, 1000);
    $v['vod_score_all'] = $v['vod_score_num'] * rand(1, 10);
    //$v['vod_score'] = round($v['vod_score_all'] / $v['vod_score_num'], 1);
    $v['vod_score'] = $v['vod_douban_score'];
}

注释掉 //$v[‘vod_score'] = round($v[‘vod_score_all'] / $v[‘vod_score_num'], 1);,添加 $v[‘vod_score'] = $v[‘vod_douban_score'];

最后一步,在第886行

if ($config['urlrole'] == 1) {
$tmp1 = explode('#',$arr1[$down_key]);
$tmp2 = explode('#',$cj_down_url);
$tmp1 = array_merge($tmp1,$tmp2);
$tmp1 = array_unique($tmp1);
$cj_down_url = join('#', (array)$tmp1);
unset($tmp1,$tmp2);
}

下面增加如下代码:

 if (strpos(',' . $config['uprule'], 'tv')!==false && !empty($v['vod_douban_id']) && $v['vod_douban_id']!=$info['vod_douban_id']) {
     $update['vod_douban_id'] = $v['vod_douban_id'];
 }
if (strpos(',' . $config['uprule'], 'av')!==false && !empty($v['vod_douban_score']) && $v['vod_douban_score']!=$info['vod_douban_id'] && $v['vod_douban_score'] != 0) {
     $update['vod_douban_score'] = $v['vod_douban_score'];
 }

保存后上传,后台清空缓存后,再次更新时,只需在二更规则勾选豆瓣评分,即可更新豆瓣评分。

 

5/5 - (1 vote)

留下评论

您的电子邮箱地址不会被公开。 必填项已用 * 标注