【原创】修复handsome音乐代码,修复handsome网易云音乐 QQ音乐

这个代码我是不想放出来的,写的太烂了,之前没打算放出来,打算自己能用就好,代码烂就烂点反正没人知道,但是在@七云的强烈要求下,表示他们也需要修复,我就把代码贴了出来,顺便修复了一些网易的,下面贴代码步骤,

首先打开tpyecho根目录:/usr/themes/handsome/libs 然后编辑文件Meting.php,找到 982行代码, netease_url() 下面还有一个tencent_url(),删除这个两个函数然后用下面的代码替换

private function netease_url($result)
{
    $data = json_decode($result, true);
    $ch = curl_init('https://music.163.com/song/media/outer/url?id='.$data['data'][0]['id']);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.87 Safari/537.36');
    curl_exec($ch);
    $url = curl_getinfo($ch, CURLINFO_EFFECTIVE_URL);
    curl_close($ch);
    if (isset($data['data'][0]['url'])) {
        $url = array(
            'url' =>$url,
            'size' => $data['data'][0]['size'],
            'br' => $data['data'][0]['br'] / 1000,
        );
    } else {
        $url = array(
            'url' => '',
            'size' => 0,
            'br' => -1,
        );
    }
    return json_encode($url);
}

private function tencent_url($result)
{
    $data = json_decode($result, true);
    $url = 'http://u.y.qq.com/cgi-bin/musicu.fcg?-=getplaysongvkey05350635758664701&hostUin=0&format=json&inCharset=utf8&outCharset=utf-8&notice=0&platform=yqq.json&needNewCode=0&data=%7B"req"%3A%7B"module"%3A"CDN.SrfCdnDispatchServer"%2C"method"%3A"GetCdnDispatch"%2C"param"%3A%7B"guid"%3A"9483748307"%2C"calltype"%3A0%2C"userip"%3A""%7D%7D%2C"req_0"%3A%7B"module"%3A"vkey.GetVkeyServer"%2C"method"%3A"CgiGetVkey"%2C"param"%3A%7B"guid"%3A"9483748307"%2C"songmid"%3A%5B"' . $data['data'][0]['mid'] . '"%5D%2C"songtype"%3A%5B0%5D%2C"uin"%3A"010000"%2C"loginflag"%3A1%2C"platform"%3A"20"%7D%7D%2C"comm"%3A%7B"uin"%3A"010000"%2C"format"%3A"json"%2C"ct"%3A24%2C"cv"%3A0%7D%7D';
    $ch = curl_init($url);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.87 Safari/537.36');
    $content = curl_exec($ch);
    curl_close($ch);
    $ndata = json_decode($content, 1)['req_0']['data']['midurlinfo'][0]['purl'];
    $url = array(
        'url' => 'https://isure.stream.qqmusic.qq.com/' . $ndata,
        'size' => 0,
        'br' => -1,
    );
    return json_encode($url);
}

作者在内置的时候好像有curl请求方法,但是我没有用直接重新写了一个,毕竟我懒研究太久太浪费时间了,如果你有时间可以通过文件以前的内置函数优化一下代码,可能就没这么多垃圾代码。

下面来两首测试音乐

网易云音乐:

00:00
加载中……请稍等……

腾讯音乐(QQ音乐):

00:00
加载中……请稍等……

Last modification:August 22nd, 2019 at 01:09 pm
如果觉得我的文章对你有用,请随意赞赏

8 comments

  1. 热搜

    文章不错非常喜欢

  2. 雾里看雪

    想偷评论区的小猫咪

    1. Reaper
      @雾里看雪

      好多人来我博客偷图(๑•̀ㅁ•́ฅ)

    2. Reaper
      @雾里看雪

      有眼光,今天刚刚换的 图片地址:https://upload.cc/i1/2019/08/23/YBeZ4O.png 拿去

      1. Qicloud
        @Reaper

        偷走了,鬼知道我从你博客偷了多少好玩意

        1. Reaper
          @Qicloud

          我知道, 你偷了一堆又一堆

      2. 雾里看雪
        @Reaper

        多谢,嘻嘻

  3. Qicloud

    hhhh知我者赖皮也

Leave a Comment