12, 'cdate' => '2021-12-01', 'name' => '吴倩COSMO武汉姑娘大片感受武汉日夜烟火', 'pic' => 'https://img.lianzhixiu.com/uploads/allimg/202010/9999/b5d3945c79.jpg,https://img.lianzhixiu.com/uploads/allimg/202010/9999/f9eb58379d.jpg', 'name' => 'jk制服国产女人美眉黑丝诱惑不露脸套图', 'pic' => 'https://img.lianzhixiu.com/uploads/allimg/202012/9999/1fd41507e0.jpg,https://img.lianzhixiu.com/uploads/allimg/202012/9999/4532772faa.jpg', 'cdate' => '2021-12-03', 'name' => '阳光下的漂亮美眉白丝美腿图片', 'pic' => 'https://img.lianzhixiu.com/uploads/allimg/202102/9999/b5d97a42d9.jpg,https://img.lianzhixiu.com/uploads/allimg/202102/9999/f64dc83f0d.jpg', 'cdate' => '2021-11-03', 'name' => '丸子头小姐姐美腿玉足居家写真', 'pic' => 'https://img.lianzhixiu.com/uploads/allimg/202003/9999/43eefe151d.jpg,https://img.lianzhixiu.com/uploads/allimg/202003/9999/31020deb3d.jpg', ); $this->pic($data); } # 从采集的数据导入 一天采集一次,一次使用12个 public function import_api() { $project_id = Dever::input('project_id', 1); $info_id = Dever::input('info_id', 1); $info = Dever::db('collection/info')->find($info_id); if (!$info) { Dever::alert('错误的配置'); } $project = Dever::db('spider/project')->find($project_id); if (!$project) { Dever::alert('错误的配置'); } $num = 9; $where['use'] = 1; $where['limit'] = '0,' . $num; $data = Dever::db('spider/data')->getAll($where); $name = $project['config'] ? $project['config'] : $project['name']; $year = date('Y'); $type = 11; if ($project['config']) { parse_str($project['config'], $config); if (isset($config['name'])) { $name = $config['name']; } if (isset($config['year'])) { $year = $config['year']; } if (isset($config['type'])) { $type = $config['type']; } } $update = array(); $update['pic_bg'] = array(); foreach ($data as $k => $v) { $value = Dever::json_decode($v['value']); if (isset($value['name']) && isset($value['pic'])) { $result = Dever::load('collection/lib/create.up', $info_id, $v['id'], $name, $value['name'], $year, $type, $value['pic'], '', $num); if ($result) { $update['pic_cover'] = $result['cover_center']; $update['pic_bg'][] = $result['cover']; } } Dever::db('spider/data')->update(array('where_id' => $v['id'], 'use' => 2)); } $update['pic_bg'] = implode(',', $update['pic_bg']); $update['where_id'] = $info_id; Dever::db('collection/info')->update($update); return 'ok'; # 导入到唯美中 # 每年12期, $info_id = Dever::input('info_id', 3); $source_id = $where['pid'] = Dever::input('pid', 14); $name = '测试'; $desc = '测试测试'; $year = date('Y'); $type = 11; $data = 'https://img.lianzhixiu.com/uploads/allimg/202003/9999/43eefe151d.jpg,https://img.lianzhixiu.com/uploads/allimg/202003/9999/31020deb3d.jpg'; $result = Dever::load('collection/lib/create.up_commit', $info_id, $source_id, $name, $desc, $year, $type, $data, $cover = ''); print_r($result);die; echo 1;die; $where['use'] = 1; $where['limit'] = '0,15'; $data = Dever::db('spider/data')->getAll($where); $main_name = '收集者'; $page_name = '唯美'; $page_desc = ''; $date = explode('-', date('Y-m-d')); $param = array(); if ($data) { print_r($data);die; foreach ($data as $k => $v) { $value = Dever::array_decode($v['value']); if ($value && is_array($value)) { //Dever::db('spider/data')->update(array('where_id' => $v['id'], 'use' => 2)); foreach ($value as $k1 => $v1) { $page_desc = $v1['name']; $pic = $v1['pic']; $this->upPic($id, $source_id, $date, $main_name, $page_name, $page_desc, $pic, $param); } } } } } # 接收采集的图片数据 public function pic($data) { return; $id = Dever::input('info_id'); $main_name = Dever::input('main_name', '图片收集序列'); $page_name = Dever::input('page_name'); $page_desc = Dever::input('page_desc'); $day_name_type = Dever::input('day_name_type', 1); if (!$id || !$main_name || !$page_name || !$page_desc) { return; } if (!isset($data['pic'])) { return; } if (!$data['pic']) { return; } $pic = explode(',', $data['pic']); $source_id = $data['project_id']; $date = array(); if (isset($data['cdate'])) { $date = explode('-', $data['cdate']); } else { if (isset($data['year']) && $data['year']) { $date[0] = $data['year']; } if (isset($data['month']) && $data['month']) { $date[1] = $data['month']; } if (isset($data['day']) && $data['day']) { $date[2] = $data['day']; } } $this->upPic($id, $source_id, $date, $main_name, $page_name, $page_desc, $pic, $data, $day_name_type); } public function upPic($id, $source_id, $date, $main_name, $page_name, $page_desc, $pic, $data, $day_name_type = 1) { if (isset($date[0]) && isset($date[1]) && isset($date[2])) { $year = intval($date[0]); if (!$year) { return; } $month = intval($date[1]); if (!$month) { return; } $day = intval($date[2]); if (!$day) { return; } if ($month < 4) { $page_name .= '第1季'; $page_reorder = 4; } elseif ($month >= 4 && $month <= 6) { $page_name .= '第2季'; $page_reorder = 3; } elseif ($month >= 7 && $month <= 9) { $page_name .= '第3季'; $page_reorder = 2; } elseif ($month > 9) { $page_name .= '第4季'; $page_reorder = 1; } # 按年生成子时光 $year_name = $year . '年'; # 按月生成子章节 $month_name = $month . '月'; # 生成内容名称 if ($day_name_type == 2 && isset($data['name']) && $data['name']) { $day_name = $data['name']; } else { $day_name = '第' . $day . '天'; } # 每期最多12个,多了有点卡顿,后续要优化的 $max = 12; /* if ($day <= 10) { $month_name .= '上旬'; } elseif ($day > 10 && $day <= 20) { $month_name .= '中旬'; } elseif ($day > 20) { $month_name .= '下旬'; } */ $reorder = (-1*($month - 12))*10 + 100; # 按项目生成主时光 $times_id_parent = $this->createTimes($id, $source_id, $main_name); if ($times_id_parent) { $times_id = $this->createTimes($id, $source_id, $year_name, $year, $times_id_parent); if ($times_id) { $parent_page_id = $this->createPage($id, $source_id, $page_name, -1, $times_id_parent, $times_id, '', '', $page_reorder); if ($parent_page_id) { $cover = $pic[0]; $cover = Dever::load('upload/view')->get($cover, 't', 1); $cover = Dever::load('upload/view')->get($cover, 'c', 1); $page_id = $this->createPage($id, $source_id, $month_name, $parent_page_id, $times_id_parent, $times_id, $page_desc, $cover, $reorder, $max); if ($page_id) { $content_id = $this->createContent($id, $source_id, $page_id, 11, $day_name, $cover); if ($content_id) { $this->createPic($id, $content_id, $pic); } } } } } } } # 生成时光 public function createTimes($info_id, $source_id, $name, $year = '', $parent = -1) { $table = 'collection/times'; $where['info_id'] = $info_id; $where['source_id'] = $source_id; $where['times_id'] = $parent; $where['name'] = $name; $param = array(); if ($year) { $param['year'] = $year; } return Dever::upinto($table, $where, $param); } # 生成章节 public function createPage($info_id, $source_id, $name, $parent = -1, $times_id_parent, $times_id, $desc = '', $pic = '', $reorder = 1, $max = 12, $num = 1) { $table = 'collection/page'; $where['info_id'] = $info_id; $where['source_id'] = $source_id; $where['name'] = $name; $where['page_id'] = $parent; $where['times_id_parent'] = $times_id_parent; $where['times_id'] = $times_id; if ($desc) { $param['desc'] = $desc; } if ($pic) { $param['pic'] = $pic; } if ($reorder) { $param['reorder'] = $reorder; } if ($parent > 0) { $where['clear'] = true; $where['name'] .= '第'.$num.'期'; $info = Dever::db($table)->one($where); if (!$info) { $param = array_merge($where, $param); $id = Dever::db($table)->insert($param); } else { $total = Dever::db('collection/content')->total(array('info_id' => $info_id, 'page_id' => $info['id'], 'clear' => true)); if ($total >= $max) { $num = $num+1; $reorder += $num; $id = $this->createPage($info_id, $source_id, $name, $parent, $times_id_parent, $times_id, $desc, $pic, $reorder, $max, $num); } else { $id = $info['id']; } } } else { $id = Dever::upinto($table, $where, $param); } return $id; } # 生成内容 public function createContent($info_id, $source_id, $page_id, $type, $name, $pic) { $table = 'collection/content'; $where['info_id'] = $info_id; $where['source_id'] = $source_id; $where['name'] = $name; $where['page_id'] = $page_id; $where['type'] = $type; if ($pic) { $param['pic'] = $pic; } return Dever::upinto($table, $where, $param); } # 自动创建章节 public function getContentNum($info_id) { $table = 'collection/content'; $where['info_id'] = $info_id; $info = Dever::db($table)->getNew($where); $max = 15; $result = array(); //唯美 第1章(时光)12季(主章节),1季12章(子章节),1章15篇(内容) if ($info) { if ($info['reorder'] >= $max) { $info['reorder'] = 1; # 篇数加1 } else { $result['reorder'] = $info['reorder'] + 1; $result['page_id'] = $info['page_id']; $result['content_id'] = $this->createContent($id, $source_id, $result['page_id'], 11, $day_name, $cover); } return $info['reorder'] + 1; } return 1; } # 生成图片 public function createPic($id, $content_id, $pic) { $table = 'content/pic'; $where['info_id'] = $id; $where['content_id'] = $content_id; foreach ($pic as $k => $v) { $where['pic_key'] = md5($v); $param['pic'] = $v; $v = Dever::curl($v . '?imageInfo'); $v = Dever::json_decode($v); if (isset($v['width']) && $v['width'] > 0) { Dever::upinto($table, $where, $param); Dever::load('collection/lib/content')->updateTypeId($id, '', $where); } } } }