示例#1
0
 public function updateEpisodesInfo($url = null, $for_season_num = null)
 {
     //        dd($for_season_num);
     if ($url == null) {
         $url = $this->getFirstKATLink()->url;
         $link = $this->getDI()->get('url')->get(['for' => 'tvserials.show', 'tvserial' => $this->id]);
         if (!$url) {
             echo '无法获取KAT的url地址,请先设置本连续剧的kat地址:<a href="' . $link . '">链接</a>';
             die;
         }
     }
     //        dd($url);
     $parser = Sites::findByUrl($url)->getParser();
     $data = $parser->parseTVSerialsinfo($url);
     $this->updateTvSerial($data['info']);
     $seasons = $data['seasons'];
     foreach ($seasons as $season => $episodes) {
         //            $season_number = (int) preg_replace('|^Season\s+([0-9]+)$|','$1',$season);
         $season_number = $season;
         if (null != $for_season_num and $for_season_num != $season_number) {
             continue;
         }
         $serial = $this->getSerialBySeasonNum($season_number);
         //            dd($serial);
         if (null == $serial) {
             continue;
         }
         //如果没有序列的话,则直接退出
         foreach ($episodes as $episode) {
             $num = $episode['num'];
             if ($e = Episodes::findBySerialAndNumOrNew($serial->id, $num)) {
                 $this->saveEpisode($episode, $e, $serial);
             }
         }
     }
 }