mirror of
https://github.com/mashirozx/sakura.git
synced 2025-05-29 01:49:21 +08:00
perf: optimize code logic
Optimize code logic, fix a tiny bug issue #209
This commit is contained in:
parent
5c58c054c5
commit
f265fe83c6
15
inc/api.php
15
inc/api.php
@ -453,10 +453,15 @@ function get_bgm_items($page = 1){
|
|||||||
}
|
}
|
||||||
$lists = $bgm["list"];
|
$lists = $bgm["list"];
|
||||||
foreach ((array)$lists as $list) {
|
foreach ((array)$lists as $list) {
|
||||||
preg_match('/第(\d+)话/m',$list['progress'], $matches_progress);
|
if(preg_match('/已看完/m',$list["new_ep"]['index_show'], $matches_finish)){
|
||||||
preg_match('/第(\d+)话/m',$list["new_ep"]['index_show'], $matches_new);
|
$percent = 100;
|
||||||
$progress = is_numeric($matches_progress[1]) ? $matches_progress[1] : 0;
|
}else{
|
||||||
$total = is_numeric($matches_new[1]) ? $matches_new[1] : $list['total_count'];
|
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 .= '<div class="column">
|
$html .= '<div class="column">
|
||||||
<a class="bangumi-item" href="https://bangumi.bilibili.com/anime/' . $list['season_id'] . '/" target="_blank" rel="nofollow">
|
<a class="bangumi-item" href="https://bangumi.bilibili.com/anime/' . $list['season_id'] . '/" target="_blank" rel="nofollow">
|
||||||
<img class="bangumi-image" src="' . str_replace('http://', 'https://', $list['cover']) . '"/>
|
<img class="bangumi-image" src="' . str_replace('http://', 'https://', $list['cover']) . '"/>
|
||||||
@ -464,7 +469,7 @@ function get_bgm_items($page = 1){
|
|||||||
<h3 class="bangumi-title" title="' . $list['title'] . '">' . $list['title'] . '</h2>
|
<h3 class="bangumi-title" title="' . $list['title'] . '">' . $list['title'] . '</h2>
|
||||||
<div class="bangumi-summary"> '. $list['evaluate'] .' </div>
|
<div class="bangumi-summary"> '. $list['evaluate'] .' </div>
|
||||||
<div class="bangumi-status">
|
<div class="bangumi-status">
|
||||||
<div class="bangumi-status-bar" style="width: '. $progress / $total * 100 .'%"></div>
|
<div class="bangumi-status-bar" style="width: '. $percent .'%"></div>
|
||||||
<p>' . $list['new_ep']['index_show'] . '</p>
|
<p>' . $list['new_ep']['index_show'] . '</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user