Skip to content

Commit

Permalink
Fix netease playlist (#318)
Browse files Browse the repository at this point in the history
* fix netease playlist only show 10 tracks

* Update manifest.json

* Update listen1.html

* Update package.json

* Update manifest_firefox.json

* Update README.md

* Update README_EN.md
  • Loading branch information
listen1 authored Jun 28, 2020
1 parent 1f8ec41 commit a126b0f
Show file tree
Hide file tree
Showing 7 changed files with 106 additions and 24 deletions.
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Listen 1 (Chrome Extension) V2.7.2
Listen 1 (Chrome Extension) V2.8.0
==========
最后更新于2020年04月30日
最后更新于2020年06月28日

[![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg)](LICENSE)

Expand Down Expand Up @@ -55,6 +55,9 @@ Firefox打包安装

更新日志
-------
`2020-06-28`
* 修复网易歌单仅显示10首歌曲的问题

`2020-04-30`
* 修复咪咕音质较差的问题

Expand Down
7 changes: 5 additions & 2 deletions README_EN.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Listen 1 (Chrome Extension) V2.7.2
Listen 1 (Chrome Extension) V2.8.0
==========
(Last Update April 27th, 2020)
(Last Update June 28th, 2020)

[![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg)](LICENSE)

Expand Down Expand Up @@ -42,6 +42,9 @@ Install (Firefox)

Changelog
-------
`2020-06-28`
* fix netease music only show 10 tracks bug

`2020-04-30`
* fix migu poor music quality bug

Expand Down
106 changes: 91 additions & 15 deletions js/provider/netease.js
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,83 @@ function build_netease() {
});
}

function async_process_list(data_list, handler, handler_extra_param_list, callback) {
const fnDict = {};
data_list.forEach((item, index) => {
fnDict[index] = cb => handler(index, item, handler_extra_param_list, cb);
});
async.parallel(fnDict,
(err, results) => callback(null, data_list.map((item, index) => results[index])));
}

function ng_render_playlist_result_item(index, item, params, callback) {
const hm = params[0];
const se = params[1];
const target_url = 'https://music.163.com/weapi/v3/song/detail';
const queryIds = [item.id, item.id];
const d = {
c: '[' + queryIds.map(id => ('{"id":' + id + '}')).join(',') + ']',
ids: '[' + queryIds.join(',') + ']'
}
const data = _encrypted_request(d);
hm({
url: target_url,
method: 'POST',
data: se(data),
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
},
}).then((response)=>{
track_json = response.data.songs[0];
const track = {
id: `netrack_${track_json.id}`,
title: track_json.name,
artist: track_json.ar[0].name,
artist_id: `neartist_${track_json.ar[0].id}`,
album: track_json.al.name,
album_id: `nealbum_${track_json.al.id}`,
source: 'netease',
source_url: `http://music.163.com/#/song?id=${track_json.id}`,
img_url: track_json.al.picUrl,
url: `netrack_${track_json.id}`,
};
return callback(null, track);
});
}

function ng_parse_playlist_tracks(playlist_tracks, hm, se, callback) {
const target_url = 'https://music.163.com/weapi/v3/song/detail';
const track_ids = playlist_tracks.map(i=>i.id);
const d = {
c: '[' + track_ids.map(id => ('{"id":' + id + '}')).join(',') + ']',
ids: '[' + track_ids.join(',') + ']'
}
const data = _encrypted_request(d);
hm({
url: target_url,
method: 'POST',
data: se(data),
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
},
}).then((response)=>{
const tracks = response.data.songs.map(track_json=>({
id: `netrack_${track_json.id}`,
title: track_json.name,
artist: track_json.ar[0].name,
artist_id: `neartist_${track_json.ar[0].id}`,
album: track_json.al.name,
album_id: `nealbum_${track_json.al.id}`,
source: 'netease',
source_url: `http://music.163.com/#/song?id=${track_json.id}`,
img_url: track_json.al.picUrl,
url: `netrack_${track_json.id}`,
}));

return callback(null, tracks);
});
}

function ne_get_playlist(url, hm, se) {
// special thanks for @Binaryify
// https://github.com/Binaryify/NeteaseCloudMusicApi
Expand Down Expand Up @@ -192,22 +269,21 @@ function build_netease() {
title: res_data.playlist.name,
source_url: `http://music.163.com/#/playlist?id=${list_id}`,
};
const tracks = res_data.playlist.tracks.map(track_json => ({
id: `netrack_${track_json.id}`,
title: track_json.name,
artist: track_json.ar[0].name,
artist_id: `neartist_${track_json.ar[0].id}`,
album: track_json.al.name,
album_id: `nealbum_${track_json.al.id}`,
source: 'netease',
source_url: `http://music.163.com/#/song?id=${track_json.id}`,
img_url: track_json.al.picUrl,
url: `netrack_${track_json.id}`,
}));
return fn({
info,

// request all tracks to fetch song info
ng_parse_playlist_tracks(res_data.playlist.trackIds, hm, se,
(err, tracks) => fn({
tracks,
});
info,
}));

// request every tracks to fetch song info
// async_process_list(res_data.playlist.trackIds, ng_render_playlist_result_item, [hm, se],
// (err, tracks) => fn({
// tracks,
// info,
// }));

});
});
},
Expand Down
2 changes: 1 addition & 1 deletion listen1.html
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ <h2> {{ backup.id }} {{backup.description}}</h2>
<p> Listen 1 {{_HOMEPAGE}}: <a open-url="'http://listen1.github.io/listen1/'"> http://listen1.github.io/listen1/ </a> </p>
<p> Listen 1 {{_EMAIL}}: [email protected] </p>
<p> {{_DESIGNER}}: iparanoid </p>
<p> {{_VERSION}}: 2.7.2 {{_LICENSE_NOTICE}}</p>
<p> {{_VERSION}}: 2.8.0 {{_LICENSE_NOTICE}}</p>
</div>
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"manifest_version": 2,
"name": "Listen 1",
"permissions": [ "notifications", "unlimitedStorage", "downloads", "storage", "contextMenus", "tabs", "cookies", "*://music.163.com/*", "*://*.xiami.com/*", "*://*.qq.com/*", "*://*.kugou.com/", "*://*.kuwo.cn/", "*://*.bilibili.com/*", "*://*.migu.cn/*", "*://api.github.com/*", "*://github.com/*", "*://gist.githubusercontent.com/*", "webRequest", "webRequestBlocking"],
"version": "2.7.2",
"version": "2.8.0",
"web_accessible_resources": [ "images/*" ],
"commands": {
"play_next": {
Expand Down
2 changes: 1 addition & 1 deletion manifest_firefox.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"manifest_version": 2,
"name": "Listen 1",
"permissions": [ "notifications", "unlimitedStorage", "downloads", "storage", "contextMenus", "tabs", "cookies", "*://music.163.com/*", "*://*.xiami.com/*", "*://*.qq.com/*", "*://*.kugou.com/", "*://*.kuwo.cn/", "*://*.bilibili.com/*", "*://*.migu.cn/*", "*://api.github.com/*", "*://github.com/*", "*://gist.githubusercontent.com/*", "webRequest", "webRequestBlocking"],
"version": "2.7.2",
"version": "2.8.0",
"web_accessible_resources": [ "images/*" ],
"content_scripts": [{
"matches": ["https://listen1.github.io/listen1/*"],
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "listen1_chrome_extension",
"version": "2.1.1",
"description": "Listen 1 (Chrome Extension) V2.1.1 ========== (最后更新于2018年12月24日)",
"version": "2.8.0",
"description": "one for all free music in china",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
Expand Down

0 comments on commit a126b0f

Please sign in to comment.