public function updateInfoAction() { if (Wekit::C('site', 'app.torrent.titlegen.ifopen') > 0) { $t_type = $this->getInput('t_type', 'post'); $w_type = $this->getInput('w_type', 'post'); $wikilink = $this->getInput('wikilink', 'post'); $paras_se = $this->getInput('se', 'post'); $paras_rip = $this->getInput('rip', 'post'); $paras_resolution = $this->getInput('resolution', 'post'); $paras_sub = $this->getInput('sub', 'post'); $paras_format = $this->getInput('format', 'post'); $paras_status = $this->getInput('status', 'post'); $paras_bps = $this->getInput('bps', 'post'); $paras_platform = $this->getInput('platform', 'post'); $paras_name = $this->getInput('name', 'post'); $paras_oname = $this->getInput('oname', 'post'); $paras_lang = $this->getInput('lang', 'post'); if (!$this->loginUser->uid) { $this->showError('必须登录才能进行本操作!'); } // Check if user was banned $userBan = $this->__getUserBanDS()->getBanInfo($this->loginUser->uid); if ($userBan) { $this->showError('用户处于封禁期!'); } Wind::import('EXT:torrent.service.srv.helper.PwUtils'); switch ($t_type) { case '1': // 书籍 $url = 'https://api.douban.com/v2/book/' . $wikilink; if (!empty(Wekit::C('site', 'app.torrent.titlegen.douban'))) { $url .= '?apikey=' . Wekit::C('site', 'app.torrent.titlegen.douban'); } $result = json_decode(PwUtils::curl($url)); $title = '[' . $result->pubdate . ']'; // 年份 $title .= '[' . $result->title . ']'; // 标题 // 子标题 if ($result->subtitle) { $title .= '[' . $result->subtitle . ']'; } // 作者 if ($result->author) { $title .= '['; $i = 0; foreach ($result->author as $author) { if ($i <= 2) { $title .= $author . ' / '; $i++; } } $title = substr($title, 0, strlen($title) - 3); $title .= ']'; } $wikilink = $result->alt; $content = '[img]' . $result->image . '[/img]<br />' . $result->summary; break; case '2': case '21': // 影视 if ($w_type == 12) { // 豆瓣 $url = 'https://api.douban.com/v2/movie/subject/' . $wikilink; if (!empty(Wekit::C('site', 'app.torrent.titlegen.douban'))) { $url .= '?apikey=' . Wekit::C('site', 'app.torrent.titlegen.douban'); } $result = json_decode(PwUtils::curl($url)); $title = '[' . $result->countries[0] . ']'; // 国别 $title .= '[' . $result->year . ']'; // 年份 $title .= '[' . $result->title . ']'; // 影片中文名 // 又名 $title .= '['; $i = 0; foreach ($result->aka as $aka) { if ($i <= 2 && $aka != $result->title) { $title .= $aka . ' / '; $i++; } } $title = substr($title, 0, strlen($title) - 3); $title .= ']'; // 季度、集数 if ($paras_se) { $title .= '[' . $paras_se . ']'; } // 类型 $title .= '['; $i = 0; foreach ($result->genres as $genre) { if ($i <= 2) { $title .= $genre . ' / '; $i++; } } $title = substr($title, 0, strlen($title) - 3); $title .= ']'; $title .= '[' . $paras_rip . ']'; // 压制 $title .= '[' . $paras_resolution . ']'; // 分辨率 $title .= '[' . $paras_sub . ']'; // 字幕 $title .= '[' . $paras_format . ']'; // 格式 // 状态 if ($paras_status) { $title .= '[' . $paras_status . ']'; } $wikilink = $result->alt; $content = '[img]' . $result->images->large . '[/img]<br />' . $result->summary; } elseif ($w_type == 2) { // IMDB $url = 'http://omdbapi.com/?i=' . $wikilink; $result = json_decode(PwUtils::curl($url)); $title = '[' . $result->Country . ']'; // 国别 $title .= '[' . $result->Year . ']'; // 年份 $title .= '[' . $result->Title . ']'; // 影片名 // 季度、集数 if ($paras_se) { $title .= '[' . $paras_se . ']'; } // 类型 $title .= '[' . str_replace(', ', ' ', $result->Genre) . ']'; $title .= '[' . $paras_rip . ']'; // 压制 $title .= '[' . $paras_resolution . ']'; // 分辨率 $title .= '[' . $paras_sub . ']'; // 字幕 $title .= '[' . $paras_format . ']'; // 格式 // 状态 if ($paras_status) { $title .= '[' . $paras_status . ']'; } $wikilink = 'http://www.imdb.com/title/' . $wikilink; $content = '[img]' . $result->Poster . '[/img]<br />' . $result->Plot; } break; case '3': // 音乐 $url = 'https://api.douban.com/v2/music/' . $wikilink; if (!empty(Wekit::C('site', 'app.torrent.titlegen.douban'))) { $url .= '?apikey=' . Wekit::C('site', 'app.torrent.titlegen.douban'); } $result = json_decode(PwUtils::curl($url)); $title = '[' . $result->attrs->pubdate . ']'; // 年份 $title .= '[' . $result->attrs->title . ']'; // 标题 $title .= '[' . $result->attrs->singer . ']'; // 艺人 $title .= '[' . $paras_format . ']'; // 格式 $title .= '[' . $paras_bps . ']'; // 码率 $wikilink = $result->alt; $content = '[img]' . $result->image . '[/img]<br />' . $result->summary; break; case '4': // 软件 $title = '[' . $paras_platform . ']'; // 平台 $title .= '[' . $paras_name . ']'; // 中文名 // 原名 if ($paras_oname) { $title .= '[' . $paras_oname . ']'; } $title .= '[' . $paras_lang . ']'; // 语言 $title .= '[' . $paras_format . ']'; // 格式 break; case '5': // 其他 $title .= '[' . $paras_name . ']'; // 中文名 // 原名 if ($paras_oname) { $title .= '[' . $paras_oname . ']'; } $title .= '[' . $paras_lang . ']'; // 语言 $title .= '[' . $paras_format . ']'; // 格式 break; } echo json_encode(array('title' => $title, 'wikilink' => $wikilink, 'content' => $content)); } exit; }