function get_netease_music($paged = null) { global $nmjson; $index = 0; $userid = nm_get_setting('id') ? nm_get_setting('id') : 30829298; $row = nm_get_setting('number') ? nm_get_setting('number') : 4; $contents = $nmjson->netease_user($userid); array_shift($contents); $per_page = nm_get_setting('perpage') ? nm_get_setting('perpage') : 16; $count = count($contents); $max_page = ceil($count / $per_page); $paged = $paged ? $paged : 1; $contents = array_slice($contents, ($paged - 1) * $per_page, $per_page); $is_small = nm_get_setting('small'); $css = 'album--nice-list'; $size = nm_get_setting('coverwidth') ? nm_get_setting('coverwidth') : 180; $output = '<div class="' . $css . '">'; foreach ($contents as $content) { $index++; $output .= '<div class="album--nice" data-type="163collect" data-thumbnail="' . $content['playlist_coverImgUrl'] . '" data-id="' . $content['playlist_id'] . '" data-tooltip="' . $content['playlist_name'] . '"><img src="' . $content['playlist_coverImgUrl'] . '?param=' . $size . 'y' . $size . '"> <i class="fxfont"></i><span class="music-info">' . $content['playlist_name'] . '<span class="play-count-wrapper">[<span class="play-count">' . netease_music_get_play_count($content['playlist_id']) . '</span>]</span></span> </div>'; if ($index % $row == 0 && $index < $per_page) { $output .= '</div><div class="' . $css . '">'; } } $output .= '</div>'; return $output; }
function netease_music_update_play_count($id) { $count = netease_music_get_play_count($id) + 1; update_option('nmpc' . $id, $count); }