Music API-based QQ music and apiqq music

Source: Internet
Author: User

Music API-based QQ music and apiqq music

Welcome to my blog. This is the first article I wrote in the blog Garden, but it is not the last one. I hope you will pay more attention to me and support me!
At the beginning of the text, today we are talking about QQ music APIs, all of which come from official addresses. I used to write one, but Baidu and Google are some of them long ago, today, I capture packets from the QQ music client. I hope you will like it.

The sample code in this tutorial is C # WPF, which can be used in other languages. The most important thing is API.
First, we need to find the music and retrieve its values to play it.
Http: // 59.37.96.220/soso/fcgi-bin/client_search_cp? Format = json & t = 0 & inCharset = GB2312 & outCharset = UTF-8 & qqmusic_ver = 1302 & catZhida = 0 & p = {0} & n = {1} & w = {2} & flag_qc = 0 & remoteplace = sizer. newclient. song & new_json = 1 & lossless = 0 & aggr = 1 & cr = 1 & sem = 0 & force_zonghe = 0
{0}: Current page number, starting from 1
{1}: number returned by each request
{2}: Search Keyword
We can get some json. in C #, I am familiar with using Newtonsoft. Json to operate JSON.
For example:

C # sample code:

1 Music m = new Music (); 2 3 m. musicName = o ["data"] ["song"] ["list"] [I] ["name"]. toString (); 4 5 string Singer = ""; 6 7 for (int osxc = 0; osxc! = O ["data"] ["song"] ["list"] [I] ["singer"]. count (); osxc ++) 8 9 {Singer + = o ["data"] ["song"] ["list"] [I] ["singer"] [osxc] ["name"] +" /";} 10 11 m. singer = Singer. substring (0, Singer. lastIndexOf ("/"); // artist 12 13 m. ZJ = o ["data"] ["song"] ["list"] [I] ["album"] ["name"]. toString (); // album 14 15 MB. musicID = o ["data"] ["song"] ["list"] [I] ["mid"]. toString (); // music ID16 17 m. imageID = o ["data"] ["song"] ["list"] [I] ["album"] ["Mid"]. toString (); // album image ID18 19 m. GC = o ["data"] ["song"] ["list"] [I] ["id"]. toString (); // The lyrics ID20 21 m. fotmat = o ["data"] ["song"] ["list"] [I] ["file"] ["size_flac"]. toString (); // whether the value is FLAC. In fact, it is not much 22 23 m. HQFOTmat = o ["data"] ["song"] ["list"] [I] ["file"] ["size_ogg"]. toString (); // HQ24 25 m. MV = o ["data"] ["song"] ["list"] [I] ["mv"] ["id"]. toString (); // MV iD26 27 string Q = ""; 28 29 if (m. fotmat! = "0") 30 31 Q = "SQ"; 32 33 if (m. HQFOTmat! = "0") 34 35 if (m. Fotmat = "0") 36 37 Q = "HQ"; 38 39 // judge the highest quality (SQ, HQ, standard)

 

Here, Music is a custom class of mine, and you can store it in string directly.

After obtaining the music information, we will use it.

Album image API:

Https://y.gtimg.cn/music/photo_new/t002r300x300m00041702.16.jpg

{0}: the album image ID obtained from above

 

The next step is to obtain the song, which has three quality items, depending on whether the song is supported (HQ, standard, and economical). Because the sq api adds the green diamond detection and QQ login detection, therefore, it is impossible to crack SQ-quality songs.

 

Economic quality, minimum size, minimum quality, and simplest retrieval:

 

Http://cc.stream.qqmusic.qq.com/c10020.02.16.m4a? Fromtag = 52

{0}: The music ID obtained above

How about it ~

 

Standard Quality, general size, and general quality. It is a bit difficult to obtain because KEY is required:

First, we need a few things:

Guid: 20D919A4D7700FBC424740E8CED80C5F, used to obtain the KEY

 

Address:

Http: // 59.37.96.220/base/fcgi-bin/fcg_musicexpress2.fcg? Version = 12 & miniversion = 92 & key = strong & guid = {guid}

{Guid}: The above string.

 

We can use a stupid method to retrieve the key, that is, extract the intermediate text:

Front: "key = \" "back:" \ "speedrpttype"

 

In this way, we can get the key to request the song file:

Http: // 182.247.250.19/streamoc.music.tc.qq.com/m500?musicid=? Vkey = {vkey} & guid = {guid}

{Musicid}: The music ID obtained above

{Vkey}: the KEY obtained above

{Guid}: Guid obtained above

 

This completes the playing of the standard quality.

 

The quality of HQ, that is, high quality, is the same as the difficulty of obtaining it. However, some songs do not support HQ.

First, prepare a GUID: "20D919A4D7700FBC424740E8CED80C5F"

Send another request: http: // 59.37.96.220/base/fcgi-bin/fcg_musicexpress2.fcg? Version = 12 & miniversion = 92 & key = strong & guid = {guid}

These steps are actually the same as standard methods.

Then retrieve the key

Extract the intermediate text: "key = \" "followed by" \ "speedrpttype"

 

After getting the KEY, we can get the link to the song:

Http: // 182.247.250.19/streamoc.music.tc.qq.com/o600?musicid=.ogg? Vkey = {vkey} & guid = {guid}

The parameters are the same as above. In fact, the M5 and O6 parameters have changed, and the others are the same.

 

Other APIs are captured on y.qq.com.

To obtain an individual ticket API, you must open a ticket.

Bytes

{0}: Song order ID, which can be viewed from the official website.

Then retrieve JSON Parsing

"{\" List \ ":" + extract text (s, "var getSongInfo =", ";", 0) + "}"

 

Hot search keywords API:

Http: // 59.37.96.220/soso/fcgi-bin/dynamic_content? Format = json & outCharset = UTF-8

No parameters to be changed. parse JSON as much as possible.

It is located at ["data"] ["search_content"] in JSON.

 

Final API-lyrics + Translation

This is an API that I have studied for a long time. I used to capture packets from the QQ music client, but it was too complicated. So I started from y.qq.com and finally found my dream API.

 

It is encrypted with BESE64, which is not too troublesome.

Request connection:

Because you have configured anti-leech protection, you need to do something to disguise yourself.

Here is an example of C # code:

 1 WebClient c = new WebClient(); 2  3 .Headers.Add("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.110 Safari/537.36"); 4  5 c.Headers.Add("Accept", "*/*"); 6  7 c.Headers.Add("Referer", "https://y.qq.com/portal/player.html"); 8  9 c.Headers.Add("Accept-Language", "zh-CN,zh;q=0.8");10 11 c.Headers.Add("Cookie", "tvfe_boss_uuid=c3db0dcc4d677c60; pac_uid=1_2728578956; qq_slist_autoplay=on; ts_refer=ADTAGh5_playsong; RK=pKOOKi2f1O; pgv_pvi=8927113216; o_cookie=2728578956; pgv_pvid=5107924810; ptui_loginuin=2728578956; ptcz=897c17d7e17ae9009e018ebf3f818355147a3a26c6c67a63ae949e24758baa2d; pt2gguin=o2728578956; pgv_si=s5715204096; qqmusic_fromtag=66; yplayer_open=1; ts_last=y.qq.com/portal/player.html; ts_uid=996779984; yq_index=0");12 13 c.Headers.Add("Host", "c.y.qq.com");

 

Add a large string of Logo headers, haha

 

Https://c.y.qq.com/lyric/fcgi-bin/fcg_query_lyric_new.fcg? Callback = callback & pcachetime = 1494070301711 & songmid = {McMind} & g_tk = 5381 & jsonpCallback = callback & loginUin = 0 & hostUin = 0 & format = jsonp & inCharset = utf8 & outCharset = UTF-8 encoded ice = 0 & platform = yqq & needNewCode = 0

{McMind}: Music ID

 

First, extract the lyric and trans data using the JSON method.

Next, use BASE64 to decrypt the lyrics!

 

Sample Code: https://github.com/TwilightLemon/Lemon-App/tree/master/Lemon%20App/Music

 

This tutorial is over now. I hope you will like it and support me a lot!

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.