fined('DEBUG') AND exit('Access Denied.'); // 豆瓣榜单:设置读取、分组定义、数据抓取、文件缓存 // 一级类型 function zybns_chart_types() { return array( 'movie' => '电影', 'tv' => '剧集', ); } function zybns_chart_type($type) { $type = strtolower(trim(strval($type))); return $type == 'tv' ? 'tv' : 'movie'; } // 站内搜索地址:点海报不跳豆瓣,而是在本站按片名搜资源 // url('search') 在 rewrite 关闭时是 ?search.htm,开启时是 search.htm,两种都要能拼 function zybns_chart_search_url($keyword) { $keyword = trim(strval($keyword)); $u = url('search'); $sep = strpos($u, '?') === FALSE ? '?' : '&'; return $u.$sep.'keyword='.urlencode($keyword); } /** * 前台卡片的分组:一级类型 => 二级榜单 * key 前端与接口的唯一标识(接口白名单用它) * text 前台显示文案 * tag 豆瓣接口的 tag 参数 * type 可选,覆盖一级类型(剧集接口没有「动画」,动画取的是动画电影) */ function zybns_chart_groups() { return array( 'movie' => array( 'hot' => array('text' => '热门', 'tag' => '热门'), 'new' => array('text' => '最新', 'tag' => '最新'), 'high' => array('text' => '豆瓣高分', 'tag' => '豆瓣高分'), 'niche' => array('text' => '冷门佳片', 'tag' => '冷门佳片'), ), 'tv' => array( 'cn' => array('text' => '国产剧', 'tag' => '国产剧'), // 豆瓣没有「欧美剧」这个 tag,用「美剧」的榜单顶上 'us' => array('text' => '欧美剧', 'tag' => '美剧'), 'jp' => array('text' => '日剧', 'tag' => '日剧'), 'kr' => array('text' => '韩剧', 'tag' => '韩剧'), // 剧集接口的「动画」返回空数组,改用动画电影 'anime' => array('text' => '动画', 'tag' => '动画', 'type' => 'movie'), 'doc' => array('text' => '纪录片', 'tag' => '纪录片'), ), ); } // 按 key 取分组信息,取不到返回 NULL(接口白名单校验也用它) function zybns_chart_group($key) { $key = strval($key); $groups = zybns_chart_groups(); foreach($groups as $type => $list) { if(isset($list[$key])) { $g = $list[$key]; $g['key'] = $key; $g['group'] = $type; $g['type'] = isset($g['type']) ? $g['type'] : $type; return $g; } } return NULL; } // 某个类型下所有 key(保持定义顺序) function zybns_chart_group_keys($type) { $type = zybns_chart_type($type); $groups = zybns_chart_groups(); return isset($groups[$type]) ? array_keys($groups[$type]) : array(); } // 某个类型下 key => 显示文案 function zybns_chart_group_options($type) { $type = zybns_chart_type($type); $groups = zybns_chart_groups(); $r = array(); if(isset($groups[$type])) { foreach($groups[$type] as $k => $g) $r[$k] = $g['text']; } return $r; } // 老配置里存的是中文 tag,按 tag 反查 key(升级兼容) function zybns_chart_key_by_tag($type, $tag) { $type = zybns_chart_type($type); $tag = trim(strval($tag)); $groups = zybns_chart_groups(); if(isset($groups[$type])) { foreach($groups[$type] as $k => $g) { if($g['tag'] === $tag) return $k; } } $keys = zybns_chart_group_keys($type); return empty($keys) ? '' : $keys[0]; } function zybns_chart_setting() { $default = array( 'movie_type' => 'movie', 'movie_key' => 'hot', 'movie_on' => 1, 'movie_rows' => 3, 'movie_title' => '豆瓣热门', 'movie_tag' => '热门', 'movie_cache_hours' => 6, ); $s = setting_get('zybns_chart'); // 兼容旧插件名 zybns_movie 的设置,首次读取时自动迁移一次 if(empty($s)) { $old = setting_get('zybns_movie'); if(!empty($old) && is_array($old)) { $s = $old; setting_set('zybns_chart', $old); } } is_array($s) OR $s = array(); $s = array_merge($default, $s); $s['movie_rows'] = intval($s['movie_rows']); $s['movie_rows'] < 1 AND $s['movie_rows'] = 1; $s['movie_rows'] > 10 AND $s['movie_rows'] = 10; $s['movie_cache_hours'] = intval($s['movie_cache_hours']); $s['movie_cache_hours'] < 1 AND $s['movie_cache_hours'] = 1; $s['movie_cache_hours'] > 72 AND $s['movie_cache_hours'] = 72; $s['movie_type'] = zybns_chart_type(isset($s['movie_type']) ? $s['movie_type'] : 'movie'); // 默认榜单:新配置用 movie_key;老配置只有 movie_tag,按 tag 反查 $keys = zybns_chart_group_keys($s['movie_type']); $key = isset($s['movie_key']) ? strval($s['movie_key']) : ''; if($key === '' || !in_array($key, $keys, TRUE)) { $key = zybns_chart_key_by_tag($s['movie_type'], isset($s['movie_tag']) ? $s['movie_tag'] : ''); } if(!in_array($key, $keys, TRUE)) $key = empty($keys) ? '' : $keys[0]; $s['movie_key'] = $key; $g = zybns_chart_group($key); $s['movie_tag'] = empty($g) ? '热门' : $g['tag']; return $s; } // 缓存文件按榜单 key 分文件,互不覆盖 function zybns_chart_cache_file($key = 'hot') { $key = preg_replace('/[^a-z0-9_]/i', '', strval($key)); $key === '' AND $key = 'hot'; return APP_PATH.'tmp/zybns_chart.'.$key.'.cache.json'; } function zybns_chart_cache_read($key = 'hot') { $file = zybns_chart_cache_file($key); if(!is_file($file)) return NULL; $s = file_get_contents($file); if($s === FALSE || $s === '') return NULL; $arr = xn_json_decode($s); return is_array($arr) ? $arr : NULL; } function zybns_chart_cache_write($data, $key = 'hot') { $arr = array('time' => time(), 'data' => $data); $s = xn_json_encode($arr); @file_put_contents(zybns_chart_cache_file($key), $s); } function zybns_chart_cache_delete($key = '') { if($key !== '') { $file = zybns_chart_cache_file($key); is_file($file) AND @unlink($file); return; } foreach((array)glob(APP_PATH.'tmp/zybns_chart.*.cache.json') as $file) { is_file($file) AND @unlink($file); } // 旧版(按类型命名)的缓存 foreach((array)glob(APP_PATH.'tmp/zybns_chart.cache.json') as $file) { is_file($file) AND @unlink($file); } } // 抓取豆瓣接口,curl 优先,失败回退 file_get_contents function zybns_chart_http_get($url, $timeout = 8) { $ua = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0 Safari/537.36'; if(function_exists('curl_init')) { $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5); curl_setopt($ch, CURLOPT_TIMEOUT, $timeout); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); curl_setopt($ch, CURLOPT_USERAGENT, $ua); curl_setopt($ch, CURLOPT_REFERER, 'https://movie.douban.com/'); $s = curl_exec($ch); $code = curl_getinfo($ch, CURLINFO_HTTP_CODE); curl_close($ch); if($s !== FALSE && $code == 200) return $s; } $ctx = stream_context_create(array('http' => array( 'method' => 'GET', 'timeout' => $timeout, 'header' => "User-Agent: $ua\r\nReferer: https://movie.douban.com/\r\n", ))); $s = @file_get_contents($url, FALSE, $ctx); return $s === FALSE ? FALSE : $s; } // 返回 array(array('id','title','rate','cover','url','durl','is_new'), ...) // $type: movie = 电影,tv = 剧集 function zybns_chart_fetch($tag, $limit, $type = 'movie') { $limit = intval($limit); $limit < 2 AND $limit = 2; $limit > 40 AND $limit = 40; $type = zybns_chart_type($type); $url = 'https://movie.douban.com/j/search_subjects?type='.$type.'&tag='.urlencode($tag) .'&sort=recommend&page_limit='.$limit.'&page_start=0'; $s = zybns_chart_http_get($url); if($s === FALSE || $s === '') return array(); $arr = xn_json_decode($s); if(empty($arr['subjects']) || !is_array($arr['subjects'])) return array(); $r = array(); foreach($arr['subjects'] as $v) { if(empty($v['title'])) continue; $cover = isset($v['cover']) ? str_replace('http://', 'https://', $v['cover']) : ''; // 不再用 episodes_info(「更新至10集」之类)顶替评分,没评分就留空,卡片更干净 $rate = isset($v['rate']) ? trim($v['rate']) : ''; $r[] = array( 'id' => isset($v['id']) ? strval($v['id']) : '', 'title' => $v['title'], 'rate' => $rate, 'cover' => $cover, // url 给前台点海报用:站内搜索该片名 'url' => zybns_chart_search_url($v['title']), // durl 是豆瓣详情页,留作备用(比如以后加个「豆瓣」小链接) 'durl' => isset($v['url']) ? $v['url'] : '', 'is_new' => !empty($v['is_new']) ? 1 : 0, ); } return $r; } // 每行显示几个(改这里即可切换 2 / 3 / 4 列,模板里的 col-* 与 max-width 同步改) function zybns_chart_cols() { return 3; } // 带缓存取列表;抓取失败时回退到过期缓存 // $key 传空表示用后台设置的默认榜单 function zybns_chart_list($force = FALSE, $key = '') { $set = zybns_chart_setting(); $key = $key === '' ? $set['movie_key'] : strval($key); $g = zybns_chart_group($key); if(empty($g)) return array(); $limit = $set['movie_rows'] * zybns_chart_cols(); $cache = zybns_chart_cache_read($key); if(!$force && !empty($cache['data']) && !empty($cache['time'])) { $ttl = $set['movie_cache_hours'] * 3600; $fresh = (time() - intval($cache['time'])) < $ttl; if($fresh && count($cache['data']) >= $limit) { return array_slice($cache['data'], 0, $limit); } } $data = zybns_chart_fetch($g['tag'], max($limit, 20), $g['type']); if(empty($data)) { if(!empty($cache['data'])) return array_slice($cache['data'], 0, $limit); return array(); } zybns_chart_cache_write($data, $key); return array_slice($data, 0, $limit); } // 前台卡片一级 tab function zybns_chart_tabs() { return zybns_chart_types(); } // 后台表单字段(设置标签页与插件列表「设置」共用) function zybns_chart_admin_input() { $set = zybns_chart_setting(); $input = array(); $input['movie_on'] = form_radio_yes_no('movie_on', $set['movie_on']); $input['movie_rows'] = form_text('movie_rows', $set['movie_rows'], 100); $input['movie_type'] = form_select('movie_type', zybns_chart_types(), $set['movie_type']); $input['movie_key'] = form_select('movie_key', zybns_chart_group_options($set['movie_type']), $set['movie_key']); $input['movie_cache_hours'] = form_text('movie_cache_hours', $set['movie_cache_hours'], 100); return $input; } // 保存(设置标签页与插件列表「设置」共用) function zybns_chart_admin_save() { $set = zybns_chart_setting(); $movie_on = param('movie_on', 0); $movie_on = $movie_on ? 1 : 0; $movie_rows = intval(param('movie_rows', 3)); $movie_rows < 1 AND $movie_rows = 1; $movie_rows > 10 AND $movie_rows = 10; $movie_type = param('movie_type', 'movie', FALSE); in_array($movie_type, array('movie', 'tv'), TRUE) OR $movie_type = 'movie'; $movie_type = zybns_chart_type($movie_type); // 默认榜单必须属于当前类型,否则用该类型的第一个 $movie_key = param('movie_key', '', FALSE); $keys = zybns_chart_group_keys($movie_type); in_array($movie_key, $keys, TRUE) OR $movie_key = empty($keys) ? 'hot' : $keys[0]; $movie_cache_hours = intval(param('movie_cache_hours', 6)); $movie_cache_hours < 1 AND $movie_cache_hours = 1; $movie_cache_hours > 72 AND $movie_cache_hours = 72; $g = zybns_chart_group($movie_key); setting_set('zybns_chart', array( 'movie_type' => $movie_type, 'movie_key' => $movie_key, 'movie_on' => $movie_on, 'movie_rows' => $movie_rows, // 卡片标题已改为前台类型标签,不再对外展示;保留旧值以兼容老配置 'movie_title' => $set['movie_title'], 'movie_tag' => empty($g) ? '热门' : $g['tag'], 'movie_cache_hours' => $movie_cache_hours, )); // 配置变了,清掉缓存,下次访问按新参数重新抓取 zybns_chart_cache_delete(); return TRUE; } ?>
请先登录后发表评论!
71
0
0

🎴【电影】寒战1994 寒戰1994 (2026) [4K高码60帧][吴彦祖 刘俊谦 吴慷仁][动作 犯罪][2026]

网盘资源避难所
3月前 6603

📢【电影】寒战1994 寒戰1994 (2026) [4K高码60帧] [吴彦祖 刘俊谦 吴慷仁] [动作 犯罪] [2026]


动作 剧情 犯罪 123云盘
如有侵权,可把相关信息发送到邮箱meijuchong@gmail.com,将在7天内处理。
If there is any infringement, please send relevant information to 327788@163.com, and we will process it within 7 days.

请先登录后发表评论!

最新回复 (71)
  • anyebojue 5天前
    72楼

    谢谢

    0
  • hc470 10天前
    71楼

    !

    0
  • hyts008 10天前
    70楼

    !

    0
  • Lali 10天前
    69楼

    666

    0
  • GZITSS 10天前
    68楼

    ssee

    0
  • lovebaby2026 12天前
    67楼

    哈哈,不错哦!

    0
  • liuche 12天前
    66楼

    哈哈,不错哦!

    0
  • phpubb 12天前
    65楼

    哈哈,不错哦!

    0
  • 剑来 25天前
    64楼

    哈哈,不错哦!

    0
  • Gleaming0350 1月前
    63楼

    0
返回
发新帖 搜索 反馈 回顶部