APlayer_Plugin::parse_netease PHP Method

parse_netease() private static method

解析netease信息
private static parse_netease ( unknown $id, unknown $type ) : boolean | multitype:multitype:unknown
$id unknown
$type unknown
return boolean | multitype:multitype:unknown
    private static function parse_netease($id, $type)
    {
        //当id过长时md5避免缓存出错
        $key = 'netease_' . $type . '_' . (strlen($id) > 20 ? md5($id) : $id);
        $result = self::cache_get($key);
        //列表更新周期
        $listexpire = Typecho_Widget::widget('Widget_Options')->plugin('APlayer')->listexpire;
        if ($listexpire === null) {
            $listexpire = 43200;
        }
        $listexpire = (int) $listexpire;
        //缓存过期或者找不到的时候则重新请求服务器(设置过期时间是因为歌单等信息可能会发生改变),否则返回缓存
        if ($result && isset($result['data']) && ($type == "song" || isset($result['time']) && time() - $result['time'] < $listexpire)) {
            $data = $result['data'];
        } else {
            $data = self::get_netease_music($id, $type);
            self::cache_set($key, array('time' => time(), 'data' => $data));
        }
        if (empty($data['trackList'])) {
            return false;
        }
        $return = array();
        foreach ($data['trackList'] as $v) {
            $return[] = array('author' => $v['artist'], 'artist' => $v['artist'], 'title' => $v['title'], 'pic' => $v['pic'], 'url' => $v['location'], 'lyric' => $v['lyric']);
        }
        return $return;
    }