/*----------------------------------------------
Date: 2018/08/09
Original Author: btx258、cimoc
----------------------------------------------*/
var QM_CFG = {
DEBUG: true,
E_SRV: "http://y.qq.com/portal/player.html",
S_SRV: "http://c.y.qq.com/soso/fcgi-bin/client_search_cp",
L_SRV: "http://c.y.qq.com/lyric/fcgi-bin/fcg_query_lyric_new.fcg",
G_PRM: "&format=json&inCharset=utf8&outCharset=utf-8",
P_MAX: 3,
P_NUM: 30,
L_LOW: 5,
L_MAX: 10,
RETRY: 1,
};
//更改lrc_order内标识顺序,设置歌词输出顺序,删除即不获取
//old_merge:并排合并歌词,newtype:并列合并,tran:翻译,origin:原版歌词,
/*
new_merge:并排合并歌词,在卡拉OK模式下仅高亮原语言歌词
不推荐使用,仅能即时获取歌词即时使用,不能保存,且若原词为全英文或英文符号则翻译前会显示时间轴
*/
var lrc_order = [
"origin",
"old_merge",
"newtype",
"tran",
//"new_merge"
];
//更改或删除翻译外括号
//提供一些括号〔 〕〈 〉《 》「 」『 』〖 〗【 】( ) [ ] { }
var bracket = [
"「", //左括号
"」" //右括号
];
//修复newtype歌词保存 翻译提前秒数 设为0则取消 如果翻译歌词跳的快看的难过,蕴情设为0.4-1.0
var savefix = 0.01;
//new_merge歌词翻译时间轴滞后秒数,防闪
var timefix = 0.41;
//当timefix有效时设置offset(毫秒),防闪
var offset=-20;
var qm_http = {
handle: null,
type: null
};
var qm_abort = {
handle: null,
isvalid: true
};
function get_my_name() {
return "QQMusic|QQ音乐";
}
function get_version() {
return "0.0.3";
}
function get_author() {
return "Anonymous";
}
function start_search(info, callback) {
var json_text = null, new_lyric = null;
var song = null, lyric = null, i = null, j = null;
var page = null, count = null;
qm_abort.handle = callback;
qm_abort.isvalid = true;
for (var page = 0, count = 0; page < QM_CFG.P_MAX && count < QM_CFG.L_LOW; page++) {
if (qm_is_aborting()) {
break;
}
json_text = qm_download(QM_CFG.S_SRV,
"w=" + qm_normalize(info.Title) + "+" + qm_normalize(info.Artist)
+ "&p=" + (page + 1)
+ "&n=" + QM_CFG.P_NUM
+ "&new_json=1&cr=1"
+ QM_CFG.G_PRM
);
if (json_text) {
try {
song = qm_json(json_text);
} catch (e) {
song = null;
}
}
if (song && !song.code) {
if (song.subcode || !song.data.song.totalnum) {
break;
}
new_lyric = fb.CreateLyric();
for (i = 0; i < song.data.song.list.length && count < QM_CFG.L_MAX; i++) {
if (qm_is_aborting()) {
break;
}
json_text = qm_download(QM_CFG.L_SRV,
"songmid=" + song.data.song.list[i].mid
+ "&g_tk=5381"
+ QM_CFG.G_PRM
);
if (json_text) {
try {
lyric = qm_json(json_text.replace(/(^\w+\()|(\)$)/g, ""));
} catch (e) {
lyric = null;
}
}
if (lyric && !lyric.code) {
if ((lyric.lyric.length > 128) && (lyric.trans.length > 128)) {
fb.trace(Base64.decode(lyric.lyric), Base64.decode(lyric.trans));
}
if (!lrc_order.length) lrc_order = ["new_merge", "newtype", "origin", "tran"];
for (var key in lrc_order) {
switch (lrc_order[key]) {
case "new_merge" :
if ((lyric.lyric.length > 128) && (lyric.trans.length > 128)) {
new_lyric.LyricText = lrc_newtype(Base64.decode(lyric.lyric), Base64.decode(lyric.trans), false);
new_lyric.Title = song.data.song.list[i].title + " (并排)";
for (j = 0, new_lyric.Artist = ""; j < song.data.song.list[i].singer.length; j++) {
new_lyric.Artist += (j === 0 ? "" : ",") + song.data.song.list[i].singer[j].title;
}
new_lyric.Album = song.data.song.list[i].album.title;
new_lyric.Source = get_my_name();
fb.trace(Base64.decode(lyric.lyric));
fb.trace(Base64.decode(lyric.trans));
callback.AddLyric(new_lyric);
}
break;
case "origin" :
if (lyric.lyric.length > 128) {
new_lyric.LyricText = Base64.decode(lyric.lyric);
new_lyric.Title = song.data.song.list[i].title + ((lyric.trans.length > 128) ? " (原词)" : "");
for (j = 0, new_lyric.Artist = ""; j < song.data.song.list[i].singer.length; j++) {
new_lyric.Artist += (j === 0 ? "" : ",") + song.data.song.list[i].singer[j].title;
}
new_lyric.Album = song.data.song.list[i].album.title;
new_lyric.Source = get_my_name();
callback.AddLyric(new_lyric);
}
break;
case "tran" :
if (lyric.trans.length > 128) {
new_lyric.LyricText = Base64.decode(lyric.trans);
new_lyric.Title = song.data.song.list[i].title + " (翻译)";
for (j = 0, new_lyric.Artist = ""; j < song.data.song.list[i].singer.length; j++) {
new_lyric.Artist += (j === 0 ? "" : ",") + song.data.song.list[i].singer[j].title;
}
new_lyric.Album = song.data.song.list[i].album.title;
new_lyric.Source = get_my_name();
callback.AddLyric(new_lyric);
}
break;
case "newtype":
if ((lyric.lyric.length > 128) && (lyric.trans.length > 128)) {
new_lyric.LyricText = lrc_newtype(Base64.decode(lyric.lyric), Base64.decode(lyric.trans), true);
new_lyric.Title = song.data.song.list[i].title + " (并列)";
for (j = 0, new_lyric.Artist = ""; j < song.data.song.list[i].singer.length; j++) {
new_lyric.Artist += (j === 0 ? "" : ",") + song.data.song.list[i].singer[j].title;
}
new_lyric.Album = song.data.song.list[i].album.title;
new_lyric.Source = get_my_name();
callback.AddLyric(new_lyric);
}
break;
case "old_merge" :
if ((lyric.lyric.length > 128) && (lyric.trans.length > 128)) {
new_lyric.LyricText = lrc_merge(Base64.decode(lyric.lyric), Base64.decode(lyric.trans));
new_lyric.Title = song.data.song.list[i].title + " (并排-旧)";
for (j = 0, new_lyric.Artist = ""; j < song.data.song.list[i].singer.length; j++) {
new_lyric.Artist += (j === 0 ? "" : ",") + song.data.song.list[i].singer[j].title;
}
new_lyric.Album = song.data.song.list[i].album.title;
new_lyric.Source = get_my_name();
callback.AddLyric(new_lyric);
}
break;
}
}
}
count++;
if (count % 2 === 0) {
callback.Refresh();
}
}
new_lyric.Dispose();
}
}
}
function qm_download(url, param) {
QM_CFG.DEBUG && qm_trace("INFO-qm_download-url: " + url + ", param: " + param);
// retry several times at most
var i = null, xml_text = null;
for (i = 0; i < QM_CFG.RETRY; i++) {
if (!qm_http.handle) {
try {
qm_http.handle = utils.CreateHttpClient();
qm_http.type = "u_c";
} catch (e) {
QM_CFG.DEBUG && qm_trace("ERROR-qm_download-CreateHttpClient message: " + e.message);
try {
qm_http.handle = utils.CreateHttpRequest("GET");
qm_http.type = "u_r";
} catch (err) {
QM_CFG.DEBUG && qm_trace("ERROR-qm_download-CreateHttpRequest message: " + err.message);
try {
qm_http.handle = new ActiveXObject("Microsoft.XMLHTTP");
qm_http.type = "ie";
} catch (error) {
QM_CFG.DEBUG && qm_trace("ERROR-qm_download-ActiveXObject message: " + error.message);
qm_http.handle = null;
qm_http.type = null;
continue;
}
}
}
QM_CFG.DEBUG && qm_trace("INFO-qm_download-qm_http.type: " + qm_http.type);
}
try {
if (param) {
url += "?" + encodeURI(param);
}
if (qm_http.type == "u_c") {
qm_http.handle.addHttpHeader("Referer", QM_CFG.E_SRV);
xml_text = qm_http.handle.Request(url, "GET");
if (qm_http.handle.StatusCode == 200) {
re
ESLyric、ui_columns、uie_wsh_panel_mod_plus foobar2k显示歌词所需几个插件
需积分: 39 30 浏览量
2022-02-05
10:10:48
上传
评论
收藏 2.17MB ZIP 举报
lovefengchenlove
- 粉丝: 17
- 资源: 29
评论0