Merge branch 'main' of https://github.com/ciderapp/Cider
This commit is contained in:
commit
761d8d60cb
4 changed files with 43 additions and 111 deletions
|
@ -243,7 +243,7 @@ export class Store {
|
|||
"maxContentScale": -1 // -1 default, anything else is a custom scale
|
||||
},
|
||||
"lyrics": {
|
||||
"enable_mxm": false,
|
||||
"enable_mxm": true,
|
||||
"mxm_karaoke": false,
|
||||
"mxm_language": "en",
|
||||
"enable_qq": false,
|
||||
|
|
|
@ -3065,67 +3065,13 @@ const app = new Vue({
|
|||
return Math.random().toString(36).replace(/[^a-z]+/g, '').slice(2, 10);
|
||||
}
|
||||
|
||||
/* get token */
|
||||
function getToken(mode, track, artist, songid, lang, time, id) {
|
||||
if (attempt > 2) {
|
||||
app.loadNeteaseLyrics();
|
||||
// app.loadAMLyrics();
|
||||
} else {
|
||||
attempt = attempt + 1;
|
||||
let url = "https://apic-desktop.musixmatch.com/ws/1.1/token.get?app_id=web-desktop-app-v1.0&t=" + revisedRandId();
|
||||
let req = new XMLHttpRequest();
|
||||
req.overrideMimeType("application/json");
|
||||
req.open('GET', url, true);
|
||||
req.setRequestHeader("authority", "apic-desktop.musixmatch.com");
|
||||
req.onload = function () {
|
||||
try {
|
||||
let jsonResponse = JSON.parse(this.responseText);
|
||||
let status2 = jsonResponse["message"]["header"]["status_code"];
|
||||
if (status2 == 200) {
|
||||
let token = jsonResponse["message"]["body"]["user_token"] ?? '';
|
||||
if (token != "" && token != "UpgradeOnlyUpgradeOnlyUpgradeOnlyUpgradeOnly") {
|
||||
console.debug('200 token', mode);
|
||||
// token good
|
||||
app.mxmtoken = token;
|
||||
|
||||
if (mode == 1) {
|
||||
getMXMSubs(track, artist, app.mxmtoken, lang, time, id);
|
||||
} else {
|
||||
getMXMTrans(songid, lang, app.mxmtoken);
|
||||
}
|
||||
} else {
|
||||
console.debug('fake 200 token');
|
||||
getToken(mode, track, artist, songid, lang, time)
|
||||
}
|
||||
} else {
|
||||
// console.log('token 4xx');
|
||||
getToken(mode, track, artist, songid, lang, time)
|
||||
}
|
||||
} catch (e) {
|
||||
console.log('error');
|
||||
app.loadQQLyrics();
|
||||
//app.loadAMLyrics();
|
||||
}
|
||||
};
|
||||
req.onerror = function () {
|
||||
console.log('error');
|
||||
app.loadQQLyrics();
|
||||
// app.loadAMLyrics();
|
||||
};
|
||||
req.send();
|
||||
}
|
||||
}
|
||||
|
||||
function getMXMSubs(track, artist, token, lang, time, id) {
|
||||
let usertoken = encodeURIComponent(token);
|
||||
let richsyncQuery = (app.cfg.lyrics.mxm_karaoke) ? "&optional_calls=track.richsync" : ""
|
||||
let timecustom = (!time || (time && time < 0)) ? '' : `&f_subtitle_length=${time}&q_duration=${time}&f_subtitle_length_max_deviation=40`;
|
||||
let itunesid = (id && id != "") ? `&track_itunes_id=${id}` : '';
|
||||
let url = "https://apic-desktop.musixmatch.com/ws/1.1/macro.subtitles.get?format=json&namespace=lyrics_richsynched" + richsyncQuery + "&subtitle_format=lrc&q_artist=" + artist + "&q_track=" + track + itunesid + "&usertoken=" + usertoken + timecustom + "&app_id=web-desktop-app-v1.0&t=" + revisedRandId();
|
||||
function getMXMSubs(track, artist, lang, time, id) {
|
||||
let richsyncQuery = app.cfg.lyrics.mxm_karaoke
|
||||
let itunesid = (id && id != "") ? id : ''; // Mode 1 -> Subs
|
||||
let url = "https://api.cider.sh/v1/lyrics?" + "mode=1" + "&richsyncQuery=" + richsyncQuery + "&track=" + track + "&artist=" + artist + "&songID=" + itunesid + "&source=mxm" + "&lang=" + lang + "&time=" + time;
|
||||
let req = new XMLHttpRequest();
|
||||
req.overrideMimeType("application/json");
|
||||
req.open('GET', url, true);
|
||||
req.setRequestHeader("authority", "apic-desktop.musixmatch.com");
|
||||
req.onload = function () {
|
||||
try {
|
||||
let jsonResponse = JSON.parse(this.responseText);
|
||||
|
@ -3152,7 +3098,7 @@ const app = new Vue({
|
|||
// app.loadAMLyrics()
|
||||
} else {
|
||||
if (richsync == [] || richsync.length == 0) {
|
||||
console.log("ok");
|
||||
console.log("musixmatch worki");
|
||||
// process lrcfile to json here
|
||||
app.lyricsMediaItem = lrcfile
|
||||
let u = app.lyricsMediaItem.split(/[\r\n]/);
|
||||
|
@ -3195,7 +3141,7 @@ const app = new Vue({
|
|||
}
|
||||
if (lrcfile != null && lrcfile != '') {
|
||||
// load translation
|
||||
getMXMTrans(id, lang, token);
|
||||
getMXMTrans(id, lang);
|
||||
} else {
|
||||
// app.loadAMLyrics()
|
||||
app.loadQQLyrics();
|
||||
|
@ -3206,9 +3152,7 @@ const app = new Vue({
|
|||
app.loadQQLyrics();
|
||||
// app.loadAMLyrics()
|
||||
}
|
||||
} else { //4xx rejected
|
||||
getToken(1, track, artist, '', lang, time);
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
app.loadQQLyrics();
|
||||
|
@ -3220,23 +3164,21 @@ const app = new Vue({
|
|||
console.log('error');
|
||||
// app.loadAMLyrics();
|
||||
};
|
||||
req.open('POST', url, true);
|
||||
req.send();
|
||||
}
|
||||
|
||||
function getMXMTrans(id, lang, token) {
|
||||
if (lang != "disabled" && id != '') {
|
||||
let usertoken = encodeURIComponent(token);
|
||||
let url2 = "https://apic-desktop.musixmatch.com/ws/1.1/crowd.track.translations.get?translation_fields_set=minimal&selected_language=" + lang + "&track_id=" + id + "&comment_format=text&part=user&format=json&usertoken=" + usertoken + "&app_id=web-desktop-app-v1.0&t=" + revisedRandId();
|
||||
function getMXMTrans(lang, id) {
|
||||
if (lang != "disabled" && id != '') { // Mode 2 -> Trans
|
||||
let url2 = "https://api.cider.sh/v1/lyrics?" + "mode=2" + "&richsyncQuery=false" + "&songID=" + id + "&source=mxm" + "&lang=" + lang + "&time=" + time;
|
||||
let req2 = new XMLHttpRequest();
|
||||
req2.overrideMimeType("application/json");
|
||||
req2.open('GET', url2, true);
|
||||
req2.setRequestHeader("authority", "apic-desktop.musixmatch.com");
|
||||
req2.onload = function () {
|
||||
try {
|
||||
let jsonResponse2 = JSON.parse(this.responseText);
|
||||
console.log(jsonResponse2);
|
||||
let status2 = jsonResponse2["message"]["header"]["status_code"];
|
||||
if (status2 == 200) {
|
||||
if (status2 === 200) {
|
||||
try {
|
||||
let preTrans = []
|
||||
let u = app.lyrics;
|
||||
|
@ -3256,23 +3198,19 @@ const app = new Vue({
|
|||
} catch (e) {
|
||||
/// not found trans -> ignore
|
||||
}
|
||||
} else { //4xx rejected
|
||||
getToken(2, '', '', id, lang, '');
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
}
|
||||
}
|
||||
req2.open('POST', url2, true);
|
||||
req2.send();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (track != "" & track != "No Title Found") {
|
||||
if (app.mxmtoken != null && app.mxmtoken != '') {
|
||||
getMXMSubs(track, artist, app.mxmtoken, lang, time, id)
|
||||
} else {
|
||||
getToken(1, track, artist, '', lang, time);
|
||||
}
|
||||
getMXMSubs(track, artist, lang, time, id)
|
||||
getMXMTrans(track, artist, lang, time, id)
|
||||
}
|
||||
},
|
||||
loadNeteaseLyrics() {
|
||||
|
@ -4015,8 +3953,7 @@ const app = new Vue({
|
|||
}
|
||||
try {
|
||||
// document.querySelector('.app-playback-controls .artwork').style.setProperty('--artwork', `url("${this.currentArtUrl}")`);
|
||||
} catch (e) {
|
||||
}
|
||||
} catch (e) {}
|
||||
} else {
|
||||
let data = await this.mk.api.v3.music(`/v1/me/library/songs/${this.mk.nowPlayingItem.id}`);
|
||||
data = data.data.data[0];
|
||||
|
|
|
@ -704,21 +704,18 @@
|
|||
<span>{{$root.getLz('settings.header.lyrics')}}</span>
|
||||
</div>
|
||||
<div class="settings-option-body">
|
||||
<div style="opacity: 0.5; pointer-events: none;">
|
||||
<div class="md-option-line">
|
||||
<div class="md-option-segment">
|
||||
{{$root.getLz('settings.option.lyrics.enableMusixmatch')}}
|
||||
</div>
|
||||
<div class="md-option-segment md-option-segment_auto">
|
||||
<label>
|
||||
<input type="checkbox" switch checked />
|
||||
</label>
|
||||
<!-- <input type="checkbox" v-model="app.cfg.lyrics.enable_mxm" switch /> -->
|
||||
</div>
|
||||
<div class="md-option-line">
|
||||
<div class="md-option-segment">
|
||||
{{$root.getLz('settings.option.lyrics.enableMusixmatch')}}
|
||||
</div>
|
||||
<div class="md-option-segment md-option-segment_auto">
|
||||
<label>
|
||||
<input type="checkbox" v-model="app.cfg.lyrics.enable_mxm" switch />
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="md-option-line">
|
||||
<!-- <div class="md-option-line" v-if="app.cfg.lyrics.enable_mxm"> -->
|
||||
<div class="md-option-line" v-if="app.cfg.lyrics.enable_mxm">
|
||||
<div class="md-option-segment">
|
||||
{{$root.getLz('settings.option.lyrics.enableMusixmatchKaraoke')}}
|
||||
</div>
|
||||
|
|
|
@ -613,29 +613,27 @@
|
|||
<div class="md-option-header">
|
||||
<span>{{$root.getLz('settings.header.lyrics')}}</span>
|
||||
</div>
|
||||
<div class="settings-option-body">
|
||||
<div style="opacity: 0.5; pointer-events: none;">
|
||||
<div class="md-option-line">
|
||||
<div class="md-option-segment">
|
||||
{{$root.getLz('settings.option.lyrics.enableMusixmatch')}}
|
||||
</div>
|
||||
<div class="md-option-segment md-option-segment_auto">
|
||||
<label>
|
||||
<input type="checkbox" switch checked/>
|
||||
</label>
|
||||
<!-- <input type="checkbox" v-model="app.cfg.lyrics.enable_mxm" switch /> -->
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="settings-option-body">
|
||||
<div class="md-option-line">
|
||||
<!-- <div class="md-option-line" v-if="app.cfg.lyrics.enable_mxm"> -->
|
||||
<div class="md-option-segment">
|
||||
{{$root.getLz('settings.option.lyrics.enableMusixmatchKaraoke')}}
|
||||
{{$root.getLz('settings.option.lyrics.enableMusixmatch')}}
|
||||
</div>
|
||||
<div class="md-option-segment md-option-segment_auto">
|
||||
<label>
|
||||
<input type="checkbox" v-model="app.cfg.lyrics.mxm_karaoke" switch/>
|
||||
</label>
|
||||
<input type="checkbox" v-model="app.cfg.lyrics.enable_mxm" switch />
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="md-option-line">
|
||||
<div class="md-option-line" v-if="app.cfg.lyrics.enable_mxm">
|
||||
<div class="md-option-segment">
|
||||
{{$root.getLz('settings.option.lyrics.enableMusixmatchKaraoke')}}
|
||||
</div>
|
||||
<div class="md-option-segment md-option-segment_auto">
|
||||
<label>
|
||||
<input type="checkbox" v-model="app.cfg.lyrics.mxm_karaoke" switch/>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="md-option-line">
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue