Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
m0_66418769
NeteaseCloudMusicApi
提交
ac66ae33
N
NeteaseCloudMusicApi
项目概览
m0_66418769
/
NeteaseCloudMusicApi
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
N
NeteaseCloudMusicApi
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
ac66ae33
编写于
9月 24, 2018
作者:
N
Nzix
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
optimize base cookie for multiple users
上级
fbd969e3
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
44 addition
and
23 deletion
+44
-23
router/login_status.js
router/login_status.js
+1
-1
util/init.js
util/init.js
+11
-3
util/util.js
util/util.js
+32
-19
未找到文件。
router/login_status.js
浏览文件 @
ac66ae33
...
...
@@ -13,7 +13,7 @@ module.exports = (req, res, createWebAPIRequest, request) => {
var
bindings
=
(
/var GBinds=
([^
;
]
+
)
;/g
).
exec
(
music_req
)[
1
];
profile
=
eval
(
`(
${
profile
}
)`
);
bindings
=
eval
(
`(
${
bindings
}
)`
);
res
.
send
({
code
:
200
,
profile
:
profile
,
bindings
:
bindings
});
res
.
send
({
code
:
200
,
profile
:
profile
,
bindings
:
bindings
});
}
catch
(
error
)
{
res
.
status
(
502
).
send
(
"
fetch error
"
);
}
...
...
util/init.js
浏览文件 @
ac66ae33
...
...
@@ -2,7 +2,15 @@ function randomString(pattern, length){
return
Array
.
apply
(
null
,
{
length
:
length
}).
map
(()
=>
(
pattern
[
Math
.
floor
(
Math
.
random
()
*
pattern
.
length
)])).
join
(
''
);
}
const
jsessionid
=
randomString
(
'
0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKMNOPQRSTUVWXYZ
\\
/+
'
,
176
)
+
'
:
'
+
(
new
Date
).
getTime
();
const
nuid
=
randomString
(
'
0123456789abcdefghijklmnopqrstuvwxyz
'
,
32
);
function
generateCookie
(){
const
jsessionid
=
randomString
(
'
0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKMNOPQRSTUVWXYZ
\\
/+
'
,
176
)
+
'
:
'
+
(
new
Date
).
getTime
();
const
nuid
=
randomString
(
'
0123456789abcdefghijklmnopqrstuvwxyz
'
,
32
);
return
{
'
JSESSIONID-WYYY
'
:
jsessionid
,
'
_iuqxldmzr_
'
:
32
,
'
_ntes_nnid
'
:
nuid
+
'
,
'
+
(
new
Date
).
getTime
(),
'
_ntes_nuid
'
:
nuid
}
}
module
.
exports
=
`JSESSIONID-WYYY=
${
jsessionid
}
; _iuqxldmzr_=32; _ntes_nnid=
${
nuid
}
,
${(
new
Date
).
getTime
()}
; _ntes_nuid=
${
nuid
}
`
;
\ No newline at end of file
module
.
exports
=
generateCookie
\ No newline at end of file
util/util.js
浏览文件 @
ac66ae33
const
Encrypt
=
require
(
"
./crypto.js
"
);
const
request
=
require
(
"
request
"
);
const
query
s
tring
=
require
(
"
querystring
"
);
const
base
Cookie
=
require
(
"
./init.js
"
);
const
query
S
tring
=
require
(
"
querystring
"
);
const
random
Cookie
=
require
(
"
./init.js
"
);
request
.
debug
=
true
;
...
...
@@ -38,31 +38,43 @@ function createWebAPIRequest(
data
,
cookie
,
callback
,
error
c
allback
error
C
allback
)
{
// console.log(cookie);
if
(
cookie
.
match
(
/_csrf=
[^
(;|$)
]
+/g
))
data
.
csrf_token
=
cookie
.
match
(
/_csrf=
[^
(;|$)
]
+/g
)[
0
].
slice
(
6
);
else
data
.
csrf_token
=
""
;
const
csrfToken
=
cookie
.
match
(
/_csrf=
([^
(;|$)
]
+
)
/
);
if
(
csrfToken
)
data
.
csrf_token
=
csrfToken
[
1
];
else
data
.
csrf_token
=
""
;
const
proxy
=
cookie
.
split
(
"
__proxy__
"
)[
1
];
cookie
=
cookie
.
split
(
"
__proxy__
"
)[
0
];
const
cryptoreq
=
Encrypt
(
data
);
const
jsCookie
=
randomCookie
();
const
missingCookie
=
[];
for
(
let
key
in
jsCookie
){
if
(
cookie
.
indexOf
(
key
)
==
-
1
){
missingCookie
.
push
(
`
${
key
}
=
${
jsCookie
[
key
]}
`
);
}
}
cookie
=
cookie
.
split
(
/;
\s
*/
).
concat
(
missingCookie
).
join
(
"
;
"
);
const
encryptedData
=
Encrypt
(
data
);
const
options
=
{
url
:
`http://
${
host
}${
path
}
`
,
method
:
method
,
headers
:
{
Accept
:
"
*/*
"
,
"
Accept
"
:
"
*/*
"
,
"
Accept-Language
"
:
"
zh-CN,zh;q=0.8,gl;q=0.6,zh-TW;q=0.4
"
,
Connection
:
"
keep-alive
"
,
"
Connection
"
:
"
keep-alive
"
,
"
Content-Type
"
:
"
application/x-www-form-urlencoded
"
,
Referer
:
"
http://music.163.com
"
,
Host
:
"
music.163.com
"
,
Cookie
:
baseCookie
+
(
cookie
?
"
;
"
:
""
)
+
cookie
,
"
Referer
"
:
"
http://music.163.com
"
,
"
Host
"
:
"
music.163.com
"
,
"
Cookie
"
:
cookie
,
"
User-Agent
"
:
randomUserAgent
()
},
body
:
query
s
tring
.
stringify
({
params
:
cryptoreq
.
params
,
encSecKey
:
cryptoreq
.
encSecKey
body
:
query
S
tring
.
stringify
({
params
:
encryptedData
.
params
,
encSecKey
:
encryptedData
.
encSecKey
}),
proxy
:
proxy
};
...
...
@@ -73,7 +85,7 @@ function createWebAPIRequest(
request
(
options
,
function
(
error
,
res
,
body
)
{
if
(
error
)
{
console
.
error
(
error
);
error
c
allback
(
error
);
error
C
allback
(
error
);
}
else
{
//解决 网易云 cookie 添加 .music.163.com 域设置。
//如: Domain=.music.163.com
...
...
@@ -82,6 +94,7 @@ function createWebAPIRequest(
cookie
=
cookie
.
map
(
x
=>
x
.
replace
(
/.music.163.com/g
,
""
))
.
sort
((
a
,
b
)
=>
a
.
length
-
b
.
length
);
cookie
=
cookie
.
concat
(
missingCookie
.
map
(
x
=>
x
+
'
; Expires=
'
+
(
new
Date
((
new
Date
).
getTime
()
+
157680000000
)).
toGMTString
()));
}
callback
(
body
,
cookie
);
}
...
...
@@ -94,8 +107,8 @@ function createRequest(path, method, data) {
url
:
`http://music.163.com
${
path
}
`
,
method
:
method
,
headers
:
{
Referer
:
"
http://music.163.com
"
,
Cookie
:
"
appver=1.5.2
"
,
"
Referer
"
:
"
http://music.163.com
"
,
"
Cookie
"
:
"
appver=1.5.2
"
,
"
Content-Type
"
:
"
application/x-www-form-urlencoded
"
,
"
User-Agent
"
:
randomUserAgent
()
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录