Skip to content

Commit

Permalink
Merge pull request #4 from foamzou/feature/qmkg
Browse files Browse the repository at this point in the history
Qmkg, fix douyin and chore
  • Loading branch information
foamzou committed Aug 19, 2022
2 parents dae08cb + 8d9964a commit 65baa5a
Show file tree
Hide file tree
Showing 29 changed files with 1,752 additions and 55 deletions.
3 changes: 2 additions & 1 deletion .golangci.yml
Expand Up @@ -401,11 +401,12 @@ linters:
- govet
- gofmt
- goimports
- lll
- megacheck
- misspell
- revive
disable:
- gosec
- lll
- maligned
- prealloc
- scopelint
Expand Down
2 changes: 1 addition & 1 deletion LATEST_VERSION
@@ -1 +1 @@
0.2.6
0.2.7
4 changes: 3 additions & 1 deletion README.md
Expand Up @@ -69,7 +69,7 @@ Search Options:
--searchArtist= 歌手名
--searchAlbum= 专辑名
--searchType= 暂时只支持: song, 默认: song
--sources= 在指定的网站中搜索,使用英文逗号隔开. 目前支持: bilibili,douyin,kugou,kuwo,migu,netease,qq,youtube. 默认在全部网站中搜索
--sources= 在指定的网站中搜索,使用英文逗号隔开. 目前支持: bilibili,douyin,kugou,kuwo,migu,netease,qq,youtube,qmkg. 默认在全部网站中搜索
--excludeSource= 排除指定的网站,使用英文逗号隔开

Help Options:
Expand All @@ -92,7 +92,9 @@ Site | Source Name | Audio | Video | Search
[咪咕音乐](https://music.migu.cn/) |migu | ✅ | ⌛ | ✅
[酷狗](https://www.kugou.com/) |kugou | ✅ | ⌛ | ✅
[酷我](https://www.kuwo.cn/) | kuwo |✅ | ⌛ | ✅
[全民K歌](https://kg.qq.com/) | qmkg |✅ | ⌛ | ⌛


## 致谢
- DouYin XB: https://www.jianshu.com/p/4db4f4d6a536
- Netease Encrypt Method: https://github.com/872409/music-get
5 changes: 4 additions & 1 deletion README_en.md
Expand Up @@ -69,7 +69,7 @@ Search Options:
--searchArtist= artist name
--searchAlbum= album name
--searchType= Support: song, Default: song
--sources= Search in the specific source, separate with comma. Support: bilibili,douyin,kugou,kuwo,migu,netease,qq,youtube. Default search in all
--sources= Search in the specific source, separate with comma. Support: bilibili,douyin,kugou,kuwo,migu,netease,qq,youtube,qmkg. Default search in all
--excludeSource= Search not in the specific source, separate with comma

Help Options:
Expand All @@ -93,6 +93,9 @@ Site | Source Name | Audio | Video | Search
[migu music](https://music.migu.cn/) |migu |||
[kugou](https://www.kugou.com/) |kugou |||
[kuwo](https://www.kuwo.cn/) | kuwo |||
[qmkg](https://kg.qq.com/) | qmkg |||
## Thanks
- DouYin XB: https://www.jianshu.com/p/4db4f4d6a536
- Netease Encrypt Method: https://github.com/872409/music-get
6 changes: 3 additions & 3 deletions args/checkAndParse_test.go
Expand Up @@ -39,7 +39,7 @@ func Test_parseSearchSource(t *testing.T) {
name: "all field not specified, should use default: all",
args: args{opt: &Options{Search: Search{Sources: "", ExcludeSources: ""}}},
wantSources: []string{
"bilibili", "douyin", "kugou", "kuwo", "migu", "netease", "qq", "youtube",
"bilibili", "douyin", "kugou", "kuwo", "migu", "netease", "qq", "youtube", "qmkg",
},
},
{
Expand Down Expand Up @@ -67,14 +67,14 @@ func Test_parseSearchSource(t *testing.T) {
name: "excludeSources specified but not sources",
args: args{opt: &Options{Search: Search{Sources: "", ExcludeSources: "kuwo,qq"}}},
wantSources: []string{
"bilibili", "douyin", "kugou", "migu", "netease", "youtube",
"bilibili", "douyin", "kugou", "migu", "netease", "youtube", "qmkg",
},
},
{
name: "excludeSources with space specified but not sources",
args: args{opt: &Options{Search: Search{Sources: "", ExcludeSources: "kuwo , qq"}}},
wantSources: []string{
"bilibili", "douyin", "kugou", "migu", "netease", "youtube",
"bilibili", "douyin", "kugou", "migu", "netease", "youtube", "qmkg",
},
},
{
Expand Down
2 changes: 1 addition & 1 deletion args/option.go
Expand Up @@ -21,7 +21,7 @@ type Search struct {
Artist string `long:"searchArtist" description:"artist name" required:"false"`
Album string `long:"searchAlbum" description:"album name" required:"false"`
Type string `long:"searchType" description:"Support: song, Default: song" required:"false"`
Sources string `long:"sources" description:"Search in the specific source, separate with comma. Support: bilibili,douyin,kugou,kuwo,migu,netease,qq,youtube. Default: All" required:"false"`
Sources string `long:"sources" description:"Search in the specific source, separate with comma. Support: bilibili,douyin,kugou,kuwo,migu,netease,qq,youtube,qmkg. Default: All" required:"false"`
ExcludeSources string `long:"excludeSource" description:"Search not in the specific source, separate with comma" required:"false"`

SourcesWillBeSearch []string
Expand Down
2 changes: 2 additions & 0 deletions consts/source.go
Expand Up @@ -9,6 +9,7 @@ const (
SourceNameNetease = "netease"
SourceNameQq = "qq"
SourceNameYoutube = "youtube"
SourceNameQMKG = "qmkg"
)

func GetAllSourceName() []string {
Expand All @@ -21,5 +22,6 @@ func GetAllSourceName() []string {
SourceNameNetease,
SourceNameQq,
SourceNameYoutube,
SourceNameQMKG,
}
}
1 change: 1 addition & 0 deletions go.mod
Expand Up @@ -7,6 +7,7 @@ require (
github.com/ApesPlan/prefixtree-OpenCC v0.0.1 // indirect
github.com/ApesPlan/prefixtree-core v0.0.0-20200724072454-be92dad4a8df // indirect
github.com/dexyk/stringosim v0.0.0-20170922105913-9d0b3e91a842
github.com/dop251/goja v0.0.0-20220815083517-0c74f9139fd6
github.com/go-resty/resty/v2 v2.7.0
github.com/jessevdk/go-flags v1.5.0
)
26 changes: 26 additions & 0 deletions go.sum
Expand Up @@ -4,12 +4,30 @@ github.com/ApesPlan/prefixtree-OpenCC v0.0.1 h1:IUkCLgeeR4KthhTVyvebFhTtAL/2AFWa
github.com/ApesPlan/prefixtree-OpenCC v0.0.1/go.mod h1:SiIhatLsC76OcNp+8FWyte/UJVSlQOfSyGP/A67Thz0=
github.com/ApesPlan/prefixtree-core v0.0.0-20200724072454-be92dad4a8df h1:DQezQoeXUVrwqRyzb7HTpY/do7sPWRVVzVYaeDBDEPw=
github.com/ApesPlan/prefixtree-core v0.0.0-20200724072454-be92dad4a8df/go.mod h1:VRdzaC6I1RuPNF2EQl/dnXx19SXmZsnfc/Qv4cBNMUU=
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
github.com/dexyk/stringosim v0.0.0-20170922105913-9d0b3e91a842 h1:FWXGhOthNyZKdK0YVyDrkg5dCXOfKvexcRG37U1v6AQ=
github.com/dexyk/stringosim v0.0.0-20170922105913-9d0b3e91a842/go.mod h1:PfVoEMbmPGFArz22/wIefW9CzuQhdnE+C9ikEzJvb9Q=
github.com/dlclark/regexp2 v1.4.1-0.20201116162257-a2a8dda75c91/go.mod h1:2pZnwuY/m+8K6iRw6wQdMtk+rH5tNGR1i55kozfMjCc=
github.com/dlclark/regexp2 v1.7.0 h1:7lJfhqlPssTb1WQx4yvTHN0uElPEv52sbaECrAQxjAo=
github.com/dlclark/regexp2 v1.7.0/go.mod h1:DHkYz0B9wPfa6wondMfaivmHpzrQ3v9q8cnmRbL6yW8=
github.com/dop251/goja v0.0.0-20211022113120-dc8c55024d06/go.mod h1:R9ET47fwRVRPZnOGvHxxhuZcbrMCuiqOz3Rlrh4KSnk=
github.com/dop251/goja v0.0.0-20220815083517-0c74f9139fd6 h1:xHdUVG+c8SWJnct16Z3QJOVlaYo3OwoJyamo6kR6OL0=
github.com/dop251/goja v0.0.0-20220815083517-0c74f9139fd6/go.mod h1:yRkwfj0CBpOGre+TwBsqPV0IH0Pk73e4PXJOeNDboGs=
github.com/dop251/goja_nodejs v0.0.0-20210225215109-d91c329300e7/go.mod h1:hn7BA7c8pLvoGndExHudxTDKZ84Pyvv+90pbBjbTz0Y=
github.com/dop251/goja_nodejs v0.0.0-20211022123610-8dd9abb0616d/go.mod h1:DngW8aVqWbuLRMHItjPUyqdj+HWPvnQe8V8y1nDpIbM=
github.com/go-resty/resty/v2 v2.7.0 h1:me+K9p3uhSmXtrBZ4k9jcEAfJmuC8IivWHwaLZwPrFY=
github.com/go-resty/resty/v2 v2.7.0/go.mod h1:9PWDzw47qPphMRFfhsyk0NnSgvluHcljSMVIq3w7q0I=
github.com/go-sourcemap/sourcemap v2.1.3+incompatible h1:W1iEw64niKVGogNgBN3ePyLFfuisuzeidWPMPWmECqU=
github.com/go-sourcemap/sourcemap v2.1.3+incompatible/go.mod h1:F8jJfvm2KbVjc5NqelyYJmf/v5J0dwNLS2mL4sNA1Jg=
github.com/jessevdk/go-flags v1.5.0 h1:1jKYvbxEjfUl0fmqTCOfonvskHHXMjBySTLW4y9LFvc=
github.com/jessevdk/go-flags v1.5.0/go.mod h1:Fw0T6WPc1dYxT4mKEZRfG5kJhaTDP9pj1c2EWnYs/m4=
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI=
github.com/kr/pretty v0.3.0/go.mod h1:640gp4NfQd8pI5XOwp5fnNeVWj67G7CFk/SaSQn7NBk=
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc=
golang.org/x/net v0.0.0-20211029224645-99673261e6eb h1:pirldcYWx7rx7kE5r+9WsOXPXK0+WH5+uZ7uPmJ44uM=
golang.org/x/net v0.0.0-20211029224645-99673261e6eb/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
Expand All @@ -18,4 +36,12 @@ golang.org/x/sys v0.0.0-20210423082822-04245dca01da h1:b3NXsE2LusjYGGjL5bxEVZZOR
golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk=
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI=
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
4 changes: 2 additions & 2 deletions processor/bilibili/search_test.go
Expand Up @@ -23,8 +23,8 @@ func TestCore_SearchSong(t *testing.T) {
name: "Test search video",
fields: fields{Opts: &args.Options{Search: args.Search{Keyword: "珊瑚海 周杰伦", Type: "song"}}},
wantSongItem: &meta.SearchSongItem{
Name: "珊瑚海-周杰伦",
Artist: "cb林师傅",
Name: "【1080P修复】周杰伦 梁心颐 - 珊瑚海MV 修复版",
Artist: "zyl2012",
Url: "bilibili",
Source: consts.SourceNameBilibili,
},
Expand Down
1 change: 0 additions & 1 deletion processor/douyin/douyin_test.go
Expand Up @@ -44,7 +44,6 @@ func TestCore_FetchMetaAndResourceInfo(t *testing.T) {
Description: "七朵花《我只想要》是多少人的回忆#音乐推荐 #经典音乐#情感音乐#热门歌曲#抖音热歌#音乐mv#音乐 ",
Duration: 260,
CoverUrl: "jpeg",
Artist: "音乐而动(激光炮)",
Album: "抖音Video",
Audios: []meta.Audio{{
Url: ".mp3",
Expand Down
712 changes: 712 additions & 0 deletions processor/douyin/gen-xb-js/ascii-base64.js.go

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions processor/douyin/gen-xb-js/crypto-min.js.go

Large diffs are not rendered by default.

179 changes: 179 additions & 0 deletions processor/douyin/gen-xb-js/dy.js.go
@@ -0,0 +1,179 @@
package gen_xb_js

const XB_JS = `
function _0x237a87(_0x5c3d2a) {
// console.log('_0x237a87-param', _0x5c3d2a)
var _0x50ff23 = [null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,0,1,2,3,4,5,6,7,8,9,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,10,11,12,13,14,15]
for (var _0x1204d6 = _0x5c3d2a['length'] >> 0xa1e * -0x2 + 0x1937 + 0x4fa * -0x1, _0x700552 = _0x1204d6 << 0x68 + -0xa29 + 0x9c2, _0x1673dd = new Uint8Array(_0x1204d6), _0x19eb71 = 0xe9e + -0x167 + -0xd37, _0x249396 = 0x1 * 0x104a + 0xaa9 + 0x1af3 * -0x1; _0x249396 < _0x700552;)
_0x1673dd[_0x19eb71++] = _0x50ff23[_0x5c3d2a['charCodeAt'](_0x249396++)] << -0x1938 + 0x10c4 * -0x1 + 0x2a00 | _0x50ff23[_0x5c3d2a['charCodeAt'](_0x249396++)];
return _0x1673dd;
}
function _0x238632(_0x4cdef5, _0x268c9c) {
let _0x2b4641, _0xbb44d8 = [], _0x138ea3 = 0x140 + -0x2038 + -0x7be * -0x4, _0xc9f8ff = '';
for (let _0x332e7e = 0x17 * -0x8 + -0x910 + 0x2 * 0x4e4; _0x332e7e < 0x24e + -0x2533 + 0xbf7 * 0x3; _0x332e7e++)
_0xbb44d8[_0x332e7e] = _0x332e7e;
// console.log("FIRST", JSON.stringify(_0xbb44d8))
// console.log("LEN OF", _0x4cdef5, _0x4cdef5.length)
let intArr = [];
for (let _0x369701 = 0x77a * -0x5 + -0x3 * 0x689 + -0x12ff * -0x3; _0x369701 < 0x1b3 * 0x12 + -0x1e3 + 0x3f5 * -0x7; _0x369701++)
_0x138ea3 = (_0x138ea3 + _0xbb44d8[_0x369701] + _0x4cdef5['charCodeAt'](_0x369701 % _0x4cdef5['length'])) % (0x16d0 + 0x12 * -0xf4 + 0x254 * -0x2),
intArr.push(_0x4cdef5['charCodeAt'](_0x369701 % _0x4cdef5['length'])),
_0x2b4641 = _0xbb44d8[_0x369701],
_0xbb44d8[_0x369701] = _0xbb44d8[_0x138ea3],
_0xbb44d8[_0x138ea3] = _0x2b4641;
// console.log("intArr", JSON.stringify(intArr))
// console.log('_0xbb44d8', JSON.stringify(_0xbb44d8)) //PASS
let _0x1a0256 = 0x1ca3 + 0x1a34 + -0x36d7;
_0x138ea3 = 0xdc * 0x28 + -0x15d * 0x1 + 0x3ab * -0x9;
var aa = [];
for (let _0x1b288d = 0x9 * 0x349 + 0x1e7f + -0x3c10 * 0x1; _0x1b288d < _0x268c9c['length']; _0x1b288d++)
_0x1a0256 = (_0x1a0256 + (0x14ef * -0x1 + -0x1752 + -0x37 * -0xce)) % (-0x312 + 0x171d + -0x130b),
_0x138ea3 = (_0x138ea3 + _0xbb44d8[_0x1a0256]) % (0x3 * 0x66d + -0x3 * -0x13d + -0x15fe),
_0x2b4641 = _0xbb44d8[_0x1a0256],
_0xbb44d8[_0x1a0256] = _0xbb44d8[_0x138ea3],
_0xbb44d8[_0x138ea3] = _0x2b4641,
aa.push(_0x268c9c['charCodeAt'](_0x1b288d) ^ _0xbb44d8[(_0xbb44d8[_0x1a0256] + _0xbb44d8[_0x138ea3]) % (-0x1db3 + 0x1 * -0x733 + -0x15 * -0x1ce)]),
_0xc9f8ff += String['fromCharCode'](_0x268c9c['charCodeAt'](_0x1b288d) ^ _0xbb44d8[(_0xbb44d8[_0x1a0256] + _0xbb44d8[_0x138ea3]) % (-0x1db3 + 0x1 * -0x733 + -0x15 * -0x1ce)]);
// console.log("aa", JSON.stringify(aa));
return _0xc9f8ff;
}
function md5(str) {
var str = CryptoJS.enc.Utf8.parse(str);
var str = CryptoJS.MD5(str).toString();
return str
}
function hex_md5(str) {
var str = CryptoJS.enc.Hex.parse(str);
var str = CryptoJS.MD5(str).toString();
return str
}
function get_one_list(url_para) {
var str_1 = md5(url_para);
// console.log("get_one_list,url_para", url_para)
// console.log("get_one_list", str_1)
str_1 = hex_md5(str_1);
return _0x237a87(str_1)
}
function get_two_list() {
var str_2 = hex_md5("d41d8cd98f00b204e9800998ecf8427e");
return _0x237a87(str_2)
}
function get_three_list(ua) {
var str_3= _0x238632("\u0001\u0001\b", ua);
//str_3 = Buffer.from(str_3, 'ASCII').toString('base64');
str_3 = ethereumjs.Buffer.Buffer.from(str_3,'ascii').toString('base64');
// console.log('base64', str_3)
str_3 = md5(str_3);
// console.log("md5", str_3)
str_3 = _0x237a87(str_3);
return str_3
}
function get_time_sign(time_now) {
var list_time = [];
for (var i of [24, 16, 8, 0]){
var num_1 = time_now >> i;
list_time = list_time.concat(num_1 & 255)
}
return list_time
}
function get_num_sign() {
var num = 3963386674;
var list_time = [];
for (var i of [24, 16, 8, 0]){
var num_1 = num >> i;
list_time = list_time.concat(num_1 & 255)
}
return list_time
}
function get_last_sign(index_list) {
var num = 0;
for (var i of index_list){
if (num == 0){
num = i;
continue
}
num = num^i;
}
return num
}
function get_index_str(url_para, ua, time_now) {
var get_one_list_list = get_one_list(url_para);
var get_two_list_list = get_two_list();
var get_three_list_list = get_three_list(ua);
var index_list_1 = [64,1.00390625,1,8,get_one_list_list[14], get_one_list_list[15],get_two_list_list[14], get_two_list_list[15],get_three_list_list[14], get_three_list_list[15]];
var index_list_2 = get_time_sign(time_now);
var index_list_3 = get_num_sign();
// console.log("index_list_1:", index_list_1)
// console.log("index_list_2:", index_list_2)
// console.log("index_list_3:", index_list_3)
var index_list = index_list_1.concat(index_list_2,index_list_3);
var index_list_last = get_last_sign(index_list);
index_list = index_list.concat(index_list_last);
var last_str = ""
for (var i of index_list){
last_str += String.fromCharCode(i);
}
last_str = "\u0002ÿ" + _0x238632("ÿ", last_str);
return last_str
}
function all_num(last_str){
var num_list = [];
for (var i=0;i<last_str.length;i++) {
var num_list = num_list.concat(last_str.charCodeAt(i));
}
var result = [];
for (var i=0;i<num_list.length;i+=3) {
result.push(num_list.slice(i, i+3))
}
var result_list = [];
for (var i of result){
var num_1 = i[0]<<16;
var num_2 = i[1]<<8;
var num_3 = num_1^num_2;
var num_4 = num_3^i[2];
result_list.push(num_4)
}
return result_list
}
function get_xb(all_num_list) {
var _str = "Dkdpgh4ZKsQB80/Mfvw36XI1R25-WUAlEi7NLboqYTOPuzmFjJnryx9HVGcaStCe=";
var result_str = "";
for (var i of all_num_list){
for (var j of [[16515072,18],[258048,12],[4032,6],[63,0]]) {
var num_1 = i & j[0];
var num_2 = num_1>>j[1];
result_str += _str[num_2];
}
}
return result_str
}
function xb_main(url_para, ua) {
var time_now = (new Date().getTime()/1000).toFixed(3);
var last_str = get_index_str(url_para, ua, time_now);
var all_num_list = all_num(last_str);
var xb = get_xb(all_num_list);
return xb
}
`

0 comments on commit 65baa5a

Please sign in to comment.