From f265fe83c61cbbe6b5c72fcc94d9bce458715fe0 Mon Sep 17 00:00:00 2001 From: Spirit Date: Wed, 1 Apr 2020 19:23:37 +0800 Subject: [PATCH] perf: optimize code logic Optimize code logic, fix a tiny bug issue #209 --- inc/api.php | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/inc/api.php b/inc/api.php index 3ec4b8c..6b1f652 100644 --- a/inc/api.php +++ b/inc/api.php @@ -453,10 +453,15 @@ function get_bgm_items($page = 1){ } $lists = $bgm["list"]; foreach ((array)$lists as $list) { - preg_match('/第(\d+)话/m',$list['progress'], $matches_progress); - preg_match('/第(\d+)话/m',$list["new_ep"]['index_show'], $matches_new); - $progress = is_numeric($matches_progress[1]) ? $matches_progress[1] : 0; - $total = is_numeric($matches_new[1]) ? $matches_new[1] : $list['total_count']; + if(preg_match('/已看完/m',$list["new_ep"]['index_show'], $matches_finish)){ + $percent = 100; + }else{ + preg_match('/第(\d+)话/m',$list['progress'], $matches_progress); + preg_match('/第(\d+)话/m',$list["new_ep"]['index_show'], $matches_new); + $progress = is_numeric($matches_progress[1]) ? $matches_progress[1] : 0; + $total = is_numeric($matches_new[1]) ? $matches_new[1] : $list['total_count']; + $percent = $progress / $total * 100; + } $html .= '
@@ -464,7 +469,7 @@ function get_bgm_items($page = 1){

' . $list['title'] . '

'. $list['evaluate'] .'
-
+

' . $list['new_ep']['index_show'] . '