Git Product home page Git Product logo

meting's Introduction

Meting

Author Version Downloads Travis License

🍰 Wow, such a powerful music API framework

Introduction

A powerful music API framework to accelerate your development

  • Elegant - Easy to use, a standardized format for all music platforms.
  • Lightweight - A single-file library that's less than 51KB.
  • Powerful - Support various music platforms, including Tencent, NetEase, Xiami, KuGou, Baidu, Kuwo and more.
  • Free - Under MIT license, need I say more?

Requirement

PHP 5.4+ and BCMath, Curl, OpenSSL extension installed.

Installation

Require this package, with Composer, in the root directory of your project.

$ composer require metowolf/meting

Then you can import the class into your application:

use Metowolf\Meting;

$api = new Meting('netease');

$data = $api->format(true)->search('Soldier');

Note: Meting requires BCMath, cURL and OpenSSL extension in order to work.

Quick Start

require 'vendor/autoload.php';
// require 'Meting.php';

use Metowolf\Meting;

// Initialize to netease API
$api = new Meting('netease');

// Use custom cookie (option)
// $api->cookie('paste your cookie');

// Get data
$data = $api->format(true)->search('Soldier', [
    'page' => 1,
    'limit' => 50
]);

echo $data;
// [{"id":35847388,"name":"Hello","artist":["Adele"],"album":"Hello","pic_id":"1407374890649284","url_id":35847388,"lyric_id":35847388,"source":"netease"},{"id":33211676,"name":"Hello","artist":["OMFG"],"album":"Hello",...

// Parse link
$data = $api->format(true)->url(35847388);

echo $data;
// {"url":"http:\/\/...","size":4729252,"br":128}

More usage

Join the Discussion

Related Projects

Author

Meting © metowolf, Released under the MIT License.

Blog @meto · GitHub @metowolf · Twitter @metowolf

meting's People

Contributors

and0rw avatar dodododooo avatar hans362 avatar henryqw avatar lwl12 avatar metowolf avatar unknown-o avatar yiyungent avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

meting's Issues

syntax error, unexpected '['

Want to test this API, but failed. PHP=5.3.6
BTW, i'm not familiar to PHP.

<?php
// If you installed via composer, just use this code to requrie autoloader on the top of your projects.
//require 'mting.php';

//Or require file
require 'Meting.php';

use Metowolf\Meting;
//use Metowolf\Meting;

// Initialize to netease API
$API = new Meting('netease');

// Get data
$data = $API->format(true)->search('Soldier');

// Enjoy
echo $data;
?>

Parse error: syntax error, unexpected '[' in .....\www\mting\Meting.php on line 703

Tencent Music 搜索结果为空时进行格式化报错 Notice: Undefined index

我知道这个问题不大,关掉报错就好了,不过强迫症还是想办法收拾一下
自己PHP水平一般,大神如果有更好的写法还请指导(也正因此没有发PR)
语句:
$data=$Tencent->format(1)->search("dbiusbdisdfidhiuhfn");

报错信息:
Notice: Undefined index: songmid in /Meting.php on line 1004
Notice: Undefined index: songname in /Meting.php on line 1005
Notice: Undefined index: albummid in /Meting.php on line 1007
Notice: Undefined index: songmid in /Meting.php on line 1008
Notice: Undefined index: songmid in /Meting.php on line 1009
Notice: Undefined index: singer in /Meting.php on line 1012
Warning: Invalid argument supplied for foreach() in /Meting.php on line 1012

解决方案:加一个判断,如果$data为空则返回全空,否则返回正常数据。

private function format_tencent($data)
{
    if (isset($data['musicData'])) {
        $data=$data['musicData'];
    }
    if($data){
        $result=array(
            'id'        => $data['songmid'] ? $data['songmid'] : null,
            'name'      => $data['songname'],
            'artist'    => array(),
            'pic_id'    => $data['albummid'],
            'url_id'    => $data['songmid'],
            'lyric_id'  => $data['songmid'],
            'source'    => 'tencent',
        );
        foreach ($data['singer'] as $vo) {
            $result['artist'][]=$vo['name'];
        }
        return $result;
    }else{
        $result=array(
            'id'        => null,
            'name'      => null,
            'artist'    => null,
            'pic_id'    => null,
            'url_id'    => null,
            'lyric_id'  => null,
            'source'    => 'tencent',
        );
        return $result;
    }
}

暂时不清楚其他的格式化是否存在相应问题。
Meting很好用,省掉了大量的抓包破js时间,十分感谢。

关于孟坤播放器网页版歌单读取失败-200反馈

最近孟坤播放器网页版经常听说歌单读取失败-200,换句话说就是有时候无法获取网易云音乐的的歌曲地址,这个跟cookie有关系吗?我在meting.php里面换上自己的cookie还是行不通,有时候可以,有时候不可以,假如我现在有两个网站用了孟坤的播放器网页版,如果这个时候不能读取到网易云音乐的的歌曲地址,换另外一个网站却又可以用,好像同时在线播放的人数不能过多,不然就获取不到网易云音乐的歌曲地址

启用插件没反应

你好,我将插件启用之后,在编辑栏是出现一个音乐按钮,点击添加音乐,然后预览什么都没有,发布文章之后也是不显示音乐播放器,也没有声音,这是什么原因呐?请赐教,谢谢

百度音乐获取歌曲地址失败

public function url($id, $br = 320000)
    {
        code...
            case 'baidu':
            $api = array(
                'method' => 'GET',
                'url'    => 'https://gss2.baidu.com/6Ls1aze90MgYm2Gp8IqW0jdnxx1xbK/v1/restserver/ting',
                'body'   => array(
                    'from'     => 'qianqianmini',
                    'method'   => 'baidu.ting.song.getInfos',
                    'songid'   => $id,
                    'res'      => 1,
                    'platform' => 'darwin',
                    'version'  => '1.0.0',
                ),
                'encode' => 'baidu_AESCBC',
                'decode' => 'baidu_url',
            );
            break;
        }
        code...
    }

github拉的最新版本
这里面的url已失效了.
测试:
http://music.taihe.com/song/137406983
id给的137406983
返回

{
    "url": "",
    "br": 1002
}

url返回空字符串

如何获取播放列表封面

试着用format(0)->playlist('列表ID'),没有找到列表封面的pic id,album('列表ID')也不行,有什么方法么?

网易接口出现奇怪问题

我在返回的json数据中是能看到歌曲是存在320K版本的,但是用url方法只能得到一个192K版本的文件。我在url方法的第二个参数已经设置为9999了,但是没有效果,而且Meting项目的提交记录中是写着支持无损版本的。

APIs doesn't word anymore

hey bro, check your api , all of services except 'tencent' doesn't work properly , tencet api url has not 320 bitrate .. plz check it tnx

screen shot 2017-05-09 at 7 43 45 pm

screen shot 2017-05-09 at 7 43 53 pm

Please close the issue

Please close the issue, im sorry!

original title: $API->pic($id);好像失效了
RT,现在它直接返回null
用的是最新版的Meting.php,id是图片的id

调用失败

更新版本后获取数据失败 测试发现提示:
Parse error: syntax error, unexpected '[' in /htdocs/Meting.php on line 74
该行改用下面格式后正常
$httpheader[] = 'Accept: /';
$httpheader[] = 'Accept-Encoding: gzip, deflate';
$httpheader[] = 'Accept-Language: zh-CN,zh;q=0.8,gl;q=0.6,zh-TW;q=0.4';
$httpheader[] = 'Connection: keep-alive';
$httpheader[] = 'Content-Type: application/x-www-form-urlencoded';
$httpheader[] = 'Referer: ' . $BASE['referer'];
$httpheader[] = 'User-Agent: ' . $BASE['useragent'];
curl_setopt($curl, CURLOPT_HTTPHEADER, $httpheader);

api接口请求一直超时

本地运行的博客和托管到github上的博客都报这个错,不管是http协议还是https协议:
image

但是在接口测试工具上能够正常请求:
image

大佬们有没有知道怎么解决啊?

网易云搜索分页问题

网易云音乐的搜索 api 里的 offset 参数应是偏移量,而不是页码。

因此第 143 行应该修改为
'offset' => ($page-1) * $limit,

😄

请求网易的api 时候url($id) 获取不到音乐链接。

{ "data": [ { "id": 65795, "url": null, "br": 0, "size": 0, "md5": null, "code": 404, "expi": 1200, "type": null, "gain": 0, "fee": 0, "uf": null, "payed": 0, "flag": 0, "canExtend": false } ], "code": 200 }

返回数据如上所示,有点奇怪。。。。

ID3

hey buddy, why any of api's have not any artwork and correct ID3 tag ? their mp3 files have nothing! just song :))

网易云音乐图片ID有效位溢出问题

部分网易云的图片ID在32位系统下经过json_decode处理之后由于超大溢出变成了科学计数法,有效精度丢失导致无法还原回原来的ID了,建议需要单独处理这部分ID,强制转换为字符串。调试数据如下:

{"songs":[{"name":"Time","id":1426503,"pst":0,"t":0,"ar":[{"id":34517,"name":"Hans Zimmer","tns":[],"alias":[]}],"alia":["《盗梦空间》插曲"],"pop":100.0,"st":0,"rt":"","fee":8,"v":27,"crbt":null,"cf":"","al":{"id":146120,"name":"Inception (Music From The Motion Picture)","tns":["电影《盗梦空间》原声带"],"pic":6659741929670226},"dt":275546,"h":{"br":320000,"fid":0,"size":11024762,"vd":0.07},"m":{"br":160000,"fid":0,"size":5512404,"vd":0.0422504},"l":{"br":96000,"fid":0,"size":3307460,"vd":-2.65076E-4},"a":null,"cd":"1","no":12,"rtUrl":null,"ftype":0,"rtUrls":[],"djId":0,"copyright":1,"s_id":0,"rtype":0,"rurl":null,"mst":9,"cp":7002,"mv":0}],"privileges":[{"id":1426503,"fee":8,"payed":0,"st":0,"pl":128000,"dl":0,"sp":7,"cp":1,"subp":1,"cs":false,"maxbr":999000,"fl":128000,"toast":false,"flag":0}],"code":200}

json_decode之后:

["al"]=> array(4) { ["id"]=>int(146120) ["name"]=>string(41) "Inception (Music From The Motion Picture)" ["tns"]=>array(1) {[0]=>string(33) "电影《盗梦空间》原声带" } ["pic"]=>float(6.6597419296702E+15)}

在json_decode前$data=preg_replace('/("pic":)([0-9]+)/', '$1"$2"', $data)单独处理pic之后:

{"songs":[{"name":"Time","id":1426503,"pst":0,"t":0,"ar":[{"id":34517,"name":"Hans Zimmer","tns":[],"alias":[]}],"alia":["《盗梦空间》插曲"],"pop":100.0,"st":0,"rt":"","fee":8,"v":27,"crbt":null,"cf":"","al":{"id":146120,"name":"Inception (Music From The Motion Picture)","tns":["电影《盗梦空间》原声带"],"pic":"6659741929670226"},"dt":275546,"h":{"br":320000,"fid":0,"size":11024762,"vd":0.07},"m":{"br":160000,"fid":0,"size":5512404,"vd":0.0422504},"l":{"br":96000,"fid":0,"size":3307460,"vd":-2.65076E-4},"a":null,"cd":"1","no":12,"rtUrl":null,"ftype":0,"rtUrls":[],"djId":0,"copyright":1,"s_id":0,"rtype":0,"rurl":null,"mst":9,"cp":7002,"mv":0}],"privileges":[{"id":1426503,"fee":8,"payed":0,"st":0,"pl":128000,"dl":0,"sp":7,"cp":1,"subp":1,"cs":false,"maxbr":999000,"fl":128000,"toast":false,"flag":0}],"code":200}

["al"]=>array(4) { ["id"]=>int(146120) ["name"]=>string(41) "Inception (Music From The Motion Picture)" ["tns"]=>array(1) {[0]=>string(33) "电影《盗梦空间》原声带"} ["pic"]=>string(16)"6659741929670226"}

url 方法中 Xiami 部分歌曲无法正确返回 url

例如 id : 1776312852 ,

response:

{ status: true,
  message: '抱歉,应版权方要求,没有歌曲可以播放~',
  data: 
   { trackList: null,
     lastSongId: 0,
     type: 'default',
     type_id: 1,
     clearlist: null,
     vip: 0,
     vip_role: 0,
     hqset: 0 },
  jumpurl: null }

Getting album pic failed

Hi!
I use
$API->pic($id);
to get the album pic. But when I open the link there's nothing and the debugger returns me a 404.
I choose Netease and my server isn't in China. My PHP version is 7.1.0
Thanks your hard work!

搜索时找不到歌曲会报错

如果关键词搜索找不到歌曲(手机客户端测试过),就会爆出错误:Undefined index: songs in /vendor/metowolf/meting/src/Meting.php:112
测试时使用的关键词: adenli

Parse error: syntax error, unexpected '['

低版本PHP出现不兼容,例如:
$url=json_decode($data, 1)['data']['song']['logo'];

需要修改为:
$json=json_decode($data, 1);
$url=json['data']['song']['logo'];

Why fail to get data?

I download the project. and create a new php file, this is my test code:

<?php 

require './src/Meting.php';
use Metowolf\Meting;

// Initialize to netease API
$api = new Meting('netease');

// Use custom cookie (option)
$api->cookie('paste your cookie');

// Get data
$data = $api->format(true)->search('Soldier');

// Enjoy
echo $data;

?>

when I run the server, I can not get the correct data:

{"error":7,"info":{"url":"http:\/\/music.163.com\/api\/linux\/forward","content_type":null,"http_code":0,"header_size":0,"request_size":0,"filetime":-1,"ssl_verify_result":0,"redirect_count":0,"total_time":0,"namelookup_time":1.9e-5,"connect_time":0,"pretransfer_time":0,"size_upload":0,"size_download":0,"speed_download":0,"speed_upload":0,"download_content_length":-1,"upload_content_length":-1,"starttransfer_time":0,"redirect_time":0,"redirect_url":"","primary_ip":"","certinfo":[],"primary_port":0,"local_ip":"","local_port":0},"status":""}

What should I do ?

Thank you !

Pagination Problem

I want to setup a pagination search function in my application. And I have finished API part by follow your instruction

$api = new Meting('netease');

$data = $api->format(true)->search('Soldier', [
    'page' => 1,
    'limit' => 50
]);

echo $data;

The data have successfully received. However, without the total I can't calculate the last page. Same as your NeteaseCloudMusicApi repo songCount data.

Also, I had reviewed Meting.php. And I found out there is a parameter call total in netease. By default set it to true, but I still can't get the total.

My question is how I get the total when run the search function? thanks in advance

网易云url无损解析存在问题

网易云的url解析里对有ape格式的无损音乐会单独放在uf结构体内。整体结构类似于

{
    "data": [
        {
            "id": 418603077,
            "url": "320k地址",
            "br": 320000,
            "size": 8608958,
            "md5": "7917f621d8ec9ad72e8261b3f5c1cd19",
            "code": 200,
            "expi": 1200,
            "type": "MP3",
            "gain": 0,
            "fee": 0,
            "uf": {
                "id": 418603077,
                "url": "ape地址",
                "br": 930354,
                "size": 25020330,
                "md5": "7917f621d8ec9ad72e8261b3f5c1cd19",
                "code": 200,
                "expi": 1200,
                "type": "APE",
                "gain": 0,
                "fee": 0,
                "uf": null,
                "payed": 1,
                "flag": 0,
                "canExtend": false
            },
            "payed": 1,
            "flag": 0,
            "canExtend": false
        }
    ],
    "code": 200
}

在当前版本的解析中只会获取320k地址数据。望改进

PHPUnit\Framework\TestCase 文件不存在

测试用例里面的PHPUnit\Framework\TestCase类文件没有上传到github上面吧?

http://localhost/meting/tests/NeteaseTest.php

提示错误:

Fatal error: Class 'PHPUnit\Framework\TestCase' not found in /Applications/XAMPP/xamppfiles/htdocs/meting/tests/NeteaseTest.php on line 6

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.