auto format my ass

This commit is contained in:
child_duckling 2022-01-17 19:54:17 -08:00
parent e6567d5f62
commit ac9c537c3c
2 changed files with 3311 additions and 3413 deletions

View file

@ -0,0 +1,5 @@
{
"js": {
"beautify.ignore": "src/renderer/index.js"
}
}

View file

@ -646,12 +646,8 @@ const app = new Vue({
try {
a = a.item.attributes;
} catch (_) {} <<
<< << < HEAD
let type = (self.mk.nowPlayingItem != null) ? self.mk.nowPlayingItem["type"] || '' : ''; ===
=== =
let type = (self.mk.nowPlayingItem != null) ? self.mk.nowPlayingItem["type"] ? ? '' : ''; >>>
>>> > c7f180daf8cf1b2cdc35e1afde3b6c3ae98b7916
} catch (_) {}
let type = (self.mk.nowPlayingItem != null) ? self.mk.nowPlayingItem["type"] ?? '' : '';
if (type.includes("musicVideo") || type.includes("uploadedVideo") || type.includes("music-movie")) {
document.getElementById("apple-music-video-container").style.display = "block";
@ -1087,12 +1083,8 @@ const app = new Vue({
}
let hash = route.split("/")
let page = hash[0]
let id = hash[1] <<
<< << < HEAD
let isLibrary = hash[2] || false ===
=== =
let isLibrary = hash[2] ? ? false >>>
>>> > c7f180daf8cf1b2cdc35e1afde3b6c3ae98b7916
let id = hash[1]
let isLibrary = hash[2] ?? false
console.log(`page: ${page} id: ${id} isLibrary: ${isLibrary}`)
this.routeView({
kind: page,
@ -1102,16 +1094,10 @@ const app = new Vue({
}
})
},
routeView(item) { <<
<< << < HEAD
let kind = (item.attributes.playParams ? (item.attributes.playParams.kind || (item.type || '')) : (item.type || ''));
let id = (item.attributes.playParams ? (item.attributes.playParams.id || (item.id || '')) : (item.id || ''));;
let isLibrary = item.attributes.playParams ? (item.attributes.playParams.isLibrary || false) : false; ===
=== =
routeView(item) {
let kind = (item.attributes.playParams ? (item.attributes.playParams.kind ?? (item.type ?? '')) : (item.type ?? ''));
let id = (item.attributes.playParams ? (item.attributes.playParams.id ?? (item.id ?? '')) : (item.id ?? ''));;
let isLibrary = item.attributes.playParams ? (item.attributes.playParams.isLibrary ? ? false) : false; >>>
>>> > c7f180daf8cf1b2cdc35e1afde3b6c3ae98b7916
let isLibrary = item.attributes.playParams ? (item.attributes.playParams.isLibrary ?? false) : false;
console.log(kind, id, isLibrary)
if (true) {
@ -1153,12 +1139,8 @@ const app = new Vue({
app.getTypeFromID((kind), (id), (isLibrary), params);
window.location.hash = `${kind}/${id}${isLibrary ? "/" + isLibrary : ''}`
document.querySelector("#app-content").scrollTop = 0
} else { <<
<< << < HEAD
app.playMediaItemById((id), (kind), (isLibrary), item.attributes.url || '') ===
=== =
app.playMediaItemById((id), (kind), (isLibrary), item.attributes.url ? ? '') >>>
>>> > c7f180daf8cf1b2cdc35e1afde3b6c3ae98b7916
} else {
app.playMediaItemById((id), (kind), (isLibrary), item.attributes.url ?? '')
}
}
@ -1282,16 +1264,10 @@ const app = new Vue({
this.getArtistFromID(id)
//this.getTypeFromID("artist",id,isLibrary,query)
},
playMediaItem(item) { <<
<< << < HEAD
let kind = (item.attributes.playParams ? (item.attributes.playParams.kind || (item.type || '')) : (item.type || ''));
let id = (item.attributes.playParams ? (item.attributes.playParams.id || (item.id || '')) : (item.id || ''));;
let isLibrary = item.attributes.playParams ? (item.attributes.playParams.isLibrary || false) : false; ===
=== =
playMediaItem(item) {
let kind = (item.attributes.playParams ? (item.attributes.playParams.kind ?? (item.type ?? '')) : (item.type ?? ''));
let id = (item.attributes.playParams ? (item.attributes.playParams.id ?? (item.id ?? '')) : (item.id ?? ''));;
let isLibrary = item.attributes.playParams ? (item.attributes.playParams.isLibrary ? ? false) : false; >>>
>>> > c7f180daf8cf1b2cdc35e1afde3b6c3ae98b7916
let isLibrary = item.attributes.playParams ? (item.attributes.playParams.isLibrary ?? false) : false;
let truekind = (!kind.endsWith("s")) ? (kind + "s") : kind;
console.log(kind, id, isLibrary)
app.mk.stop().then(() => {
@ -1366,12 +1342,8 @@ const app = new Vue({
// }
// })
// }
else { <<
<< << < HEAD
app.playMediaItemById((id), (kind), (isLibrary), item.attributes.url || '') ===
=== =
app.playMediaItemById((id), (kind), (isLibrary), item.attributes.url ? ? '') >>>
>>> > c7f180daf8cf1b2cdc35e1afde3b6c3ae98b7916
else {
app.playMediaItemById((id), (kind), (isLibrary), item.attributes.url ?? '')
}
})
},
@ -2023,12 +1995,8 @@ const app = new Vue({
showSearch() {
this.page = "search"
},
loadLyrics() { <<
<< << < HEAD
const musicType = (MusicKit.getInstance().nowPlayingItem != null) ? MusicKit.getInstance().nowPlayingItem["type"] || '' : ''; ===
=== =
const musicType = (MusicKit.getInstance().nowPlayingItem != null) ? MusicKit.getInstance().nowPlayingItem["type"] ? ? '' : ''; >>>
>>> > c7f180daf8cf1b2cdc35e1afde3b6c3ae98b7916
loadLyrics() {
const musicType = (MusicKit.getInstance().nowPlayingItem != null) ? MusicKit.getInstance().nowPlayingItem["type"] ?? '' : '';
console.log("mt", musicType)
if (musicType === "musicVideo") {
this.loadYTLyrics();
@ -2040,12 +2008,8 @@ const app = new Vue({
}
}
},
loadAMLyrics() { <<
<< << < HEAD
const songID = (this.mk.nowPlayingItem != null) ? this.mk.nowPlayingItem["_songId"] || -1 : -1; ===
=== =
const songID = (this.mk.nowPlayingItem != null) ? this.mk.nowPlayingItem["_songId"] ? ? -1 : -1; >>>
>>> > c7f180daf8cf1b2cdc35e1afde3b6c3ae98b7916
loadAMLyrics() {
const songID = (this.mk.nowPlayingItem != null) ? this.mk.nowPlayingItem["_songId"] ?? -1 : -1;
// this.getMXM( trackName, artistName, 'en', duration);
if (songID != -1) {
MusicKit.getInstance().api.lyric(songID)
@ -2072,25 +2036,15 @@ const app = new Vue({
self.getLibrarySongsFull(true)
})
},
async loadYTLyrics() { <<
<< << < HEAD
const track = (this.mk.nowPlayingItem != null) ? this.mk.nowPlayingItem.title || '' : '';
const artist = (this.mk.nowPlayingItem != null) ? this.mk.nowPlayingItem.artistName || '' : '';
const time = (this.mk.nowPlayingItem != null) ? (Math.round((this.mk.nowPlayingItem.attributes["durationInMillis"] || -1000) / 1000) || -1) : -1; ===
=== =
async loadYTLyrics() {
const track = (this.mk.nowPlayingItem != null) ? this.mk.nowPlayingItem.title ?? '' : '';
const artist = (this.mk.nowPlayingItem != null) ? this.mk.nowPlayingItem.artistName ?? '' : '';
const time = (this.mk.nowPlayingItem != null) ? (Math.round((this.mk.nowPlayingItem.attributes["durationInMillis"] ? ? -1000) / 1000) ? ? -1) : -1; >>>
>>> > c7f180daf8cf1b2cdc35e1afde3b6c3ae98b7916
const time = (this.mk.nowPlayingItem != null) ? (Math.round((this.mk.nowPlayingItem.attributes["durationInMillis"] ?? -1000) / 1000) ?? -1) : -1;
ipcRenderer.invoke('getYTLyrics', track, artist).then((result) => {
if (result.length > 0) {
let ytid = result[0]['id']['videoId'];
if (app.cfg.lyrics.enable_yt) { <<
<< << < HEAD
loadYT(ytid, app.cfg.lyrics.mxm_language || "en") ===
=== =
loadYT(ytid, app.cfg.lyrics.mxm_language ? ? "en") >>>
>>> > c7f180daf8cf1b2cdc35e1afde3b6c3ae98b7916
if (app.cfg.lyrics.enable_yt) {
loadYT(ytid, app.cfg.lyrics.mxm_language ?? "en")
} else {
app.loadMXM()
}
@ -2146,18 +2100,11 @@ const app = new Vue({
},
loadMXM() {
let attempt = 0; <<
<< << < HEAD
const track = encodeURIComponent((this.mk.nowPlayingItem != null) ? this.mk.nowPlayingItem.title || '' : '');
const artist = encodeURIComponent((this.mk.nowPlayingItem != null) ? this.mk.nowPlayingItem.artistName || '' : '');
const time = encodeURIComponent((this.mk.nowPlayingItem != null) ? (Math.round((this.mk.nowPlayingItem.attributes["durationInMillis"] || -1000) / 1000) || -1) : -1);
const id = encodeURIComponent((this.mk.nowPlayingItem != null) ? app.mk.nowPlayingItem._songId || '' : ''); ===
=== =
let attempt = 0;
const track = encodeURIComponent((this.mk.nowPlayingItem != null) ? this.mk.nowPlayingItem.title ?? '' : '');
const artist = encodeURIComponent((this.mk.nowPlayingItem != null) ? this.mk.nowPlayingItem.artistName ?? '' : '');
const time = encodeURIComponent((this.mk.nowPlayingItem != null) ? (Math.round((this.mk.nowPlayingItem.attributes["durationInMillis"] ?? -1000) / 1000) ?? -1) : -1);
const id = encodeURIComponent((this.mk.nowPlayingItem != null) ? app.mk.nowPlayingItem._songId ? ? '' : ''); >>>
>>> > c7f180daf8cf1b2cdc35e1afde3b6c3ae98b7916
const id = encodeURIComponent((this.mk.nowPlayingItem != null) ? app.mk.nowPlayingItem._songId ?? '' : '');
let lrcfile = "";
let richsync = [];
const lang = app.cfg.lyrics.mxm_language // translation language
@ -2179,12 +2126,8 @@ const app = new Vue({
req.onload = function() {
let jsonResponse = JSON.parse(this.responseText);
let status2 = jsonResponse["message"]["header"]["status_code"];
if (status2 == 200) { <<
<< << < HEAD
let token = jsonResponse["message"]["body"]["user_token"] || ''; ===
=== =
let token = jsonResponse["message"]["body"]["user_token"] ? ? ''; >>>
>>> > c7f180daf8cf1b2cdc35e1afde3b6c3ae98b7916
if (status2 == 200) {
let token = jsonResponse["message"]["body"]["user_token"] ?? '';
if (token != "" && token != "UpgradeOnlyUpgradeOnlyUpgradeOnlyUpgradeOnly") {
console.log('200 token', mode);
// token good
@ -2231,12 +2174,8 @@ const app = new Vue({
if (status1 == 200) {
let id = '';
try {
if (jsonResponse["message"]["body"]["macro_calls"]["matcher.track.get"]["message"]["header"]["status_code"] == 200 && jsonResponse["message"]["body"]["macro_calls"]["track.subtitles.get"]["message"]["header"]["status_code"] == 200) { <<
<< << < HEAD
id = jsonResponse["message"]["body"]["macro_calls"]["matcher.track.get"]["message"]["body"]["track"]["track_id"] || ''; ===
=== =
id = jsonResponse["message"]["body"]["macro_calls"]["matcher.track.get"]["message"]["body"]["track"]["track_id"] ? ? ''; >>>
>>> > c7f180daf8cf1b2cdc35e1afde3b6c3ae98b7916
if (jsonResponse["message"]["body"]["macro_calls"]["matcher.track.get"]["message"]["header"]["status_code"] == 200 && jsonResponse["message"]["body"]["macro_calls"]["track.subtitles.get"]["message"]["header"]["status_code"] == 200) {
id = jsonResponse["message"]["body"]["macro_calls"]["matcher.track.get"]["message"]["body"]["track"]["track_id"] ?? '';
lrcfile = jsonResponse["message"]["body"]["macro_calls"]["track.subtitles.get"]["message"]["body"]["subtitle_list"][0]["subtitle"]["subtitle_body"];
try {
@ -2256,18 +2195,10 @@ const app = new Vue({
let u = app.lyricsMediaItem.split(/[\r\n]/);
let preLrc = []
for (var i = u.length - 1; i >= 0; i--) {
let xline = (/(\[[0-9.:\[\]]*\])+(.*)/).exec(u[i]) <<
<< << < HEAD
let end = (preLrc.length > 0) ? ((preLrc[preLrc.length - 1].startTime) || 99999) : 99999
preLrc.push({
startTime: app.toMS(xline[1].substring(1, xline[1].length - 2)) || 0,
===
=== =
let xline = (/(\[[0-9.:\[\]]*\])+(.*)/).exec(u[i])
let end = (preLrc.length > 0) ? ((preLrc[preLrc.length - 1].startTime) ?? 99999) : 99999
preLrc.push({
startTime: app.toMS(xline[1].substring(1, xline[1].length - 2)) ?? 0,
>>>
>>> > c7f180daf8cf1b2cdc35e1afde3b6c3ae98b7916
endTime: end,
line: xline[2],
translation: ''
@ -2279,9 +2210,9 @@ const app = new Vue({
endTime: preLrc[preLrc.length - 1].startTime,
line: "lrcInstrumental",
translation: ''
}); app.lyrics = preLrc.reverse();
}
else {
});
app.lyrics = preLrc.reverse();
} else {
preLrc = richsync.map(function(item) {
return {
startTime: item.ts,
@ -2527,14 +2458,10 @@ const app = new Vue({
if (childIndex != -1) {
app.mk.changeToMediaAtIndex(childIndex)
} else if (item) {
app.mk.playNext({ <<
<< << < HEAD[item.attributes.playParams.kind || item.type]: item.attributes.playParams.id || item.id
app.mk.playNext({
[item.attributes.playParams.kind ?? item.type]: item.attributes.playParams.id ?? item.id
}).then(function() {
app.mk.changeToMediaAtIndex(app.mk.queue._itemIDs.indexOf(item.id) || 1) ===
=== = [item.attributes.playParams.kind ? ? item.type]: item.attributes.playParams.id ? ? item.id
}).then(function() {
app.mk.changeToMediaAtIndex(app.mk.queue._itemIDs.indexOf(item.id) ? ? 1) >>>
>>> > c7f180daf8cf1b2cdc35e1afde3b6c3ae98b7916
app.mk.changeToMediaAtIndex(app.mk.queue._itemIDs.indexOf(item.id) ?? 1)
app.mk.play()
})
} else {
@ -2545,14 +2472,10 @@ const app = new Vue({
} else {
app.mk.stop().then(() => {
if (truekind == "playlists" && (id.startsWith("p.") || id.startsWith("pl.u"))) {
app.mk.setQueue({ <<
<< << < HEAD[item.attributes.playParams.kind || item.type]: item.attributes.playParams.id || item.id
app.mk.setQueue({
[item.attributes.playParams.kind ?? item.type]: item.attributes.playParams.id ?? item.id
}).then(function() {
app.mk.changeToMediaAtIndex(app.mk.queue._itemIDs.indexOf(item.id) || 1).then(function() { ===
=== = [item.attributes.playParams.kind ? ? item.type]: item.attributes.playParams.id ? ? item.id
}).then(function() {
app.mk.changeToMediaAtIndex(app.mk.queue._itemIDs.indexOf(item.id) ? ? 1).then(function() { >>>
>>> > c7f180daf8cf1b2cdc35e1afde3b6c3ae98b7916
app.mk.changeToMediaAtIndex(app.mk.queue._itemIDs.indexOf(item.id) ?? 1).then(function() {
if ((app.showingPlaylist && app.showingPlaylist.id == id)) {
let query = app.showingPlaylist.relationships.tracks.data.map(item => new MusicKit.MediaItem(item));
let u = query;
@ -2583,14 +2506,10 @@ const app = new Vue({
if (childIndex != -1) {
app.mk.changeToMediaAtIndex(childIndex)
} else if (item) {
app.mk.playNext({ <<
<< << < HEAD[item.attributes.playParams.kind || item.type]: item.attributes.playParams.id || item.id
app.mk.playNext({
[item.attributes.playParams.kind ?? item.type]: item.attributes.playParams.id ?? item.id
}).then(function() {
app.mk.changeToMediaAtIndex(app.mk.queue._itemIDs.indexOf(item.id) || 1) ===
=== = [item.attributes.playParams.kind ? ? item.type]: item.attributes.playParams.id ? ? item.id
}).then(function() {
app.mk.changeToMediaAtIndex(app.mk.queue._itemIDs.indexOf(item.id) ? ? 1) >>>
>>> > c7f180daf8cf1b2cdc35e1afde3b6c3ae98b7916
app.mk.changeToMediaAtIndex(app.mk.queue._itemIDs.indexOf(item.id) ?? 1)
app.mk.play()
})
} else {
@ -2600,17 +2519,12 @@ const app = new Vue({
}
})
}
}
catch (err) {
} catch (err) {
console.log(err)
try {
app.mk.stop()
} catch (e) {} <<
<< << < HEAD
this.playMediaItemById(item.attributes.playParams.id || item.id, item.attributes.playParams.kind || item.type, item.attributes.playParams.isLibrary || false, item.attributes.url) ===
=== =
this.playMediaItemById(item.attributes.playParams.id ? ? item.id, item.attributes.playParams.kind ? ? item.type, item.attributes.playParams.isLibrary ? ? false, item.attributes.url) >>>
>>> > c7f180daf8cf1b2cdc35e1afde3b6c3ae98b7916
} catch (e) {}
this.playMediaItemById(item.attributes.playParams.id ?? item.id, item.attributes.playParams.kind ?? item.type, item.attributes.playParams.isLibrary ?? false, item.attributes.url)
}
},
@ -2707,12 +2621,8 @@ const app = new Vue({
if (type.slice(-1) != "s") {
type += "s"
}
type = type.replace("library-", "") <<
<< << < HEAD
let id = item.attributes.playParams.catalogId || item.id ===
=== =
let id = item.attributes.playParams.catalogId ? ? item.id >>>
>>> > c7f180daf8cf1b2cdc35e1afde3b6c3ae98b7916
type = type.replace("library-", "")
let id = item.attributes.playParams.catalogId ?? item.id
let index = types.findIndex(function(type) {
return type.type == this
@ -2894,24 +2804,16 @@ const app = new Vue({
async getCurrentArtURL() {
try {
this.currentArtUrl = '';
if (app.mk.nowPlayingItem != null && app.mk.nowPlayingItem.attributes != null && app.mk.nowPlayingItem.attributes.artwork != null && app.mk.nowPlayingItem.attributes.artwork.url != null && app.mk.nowPlayingItem.attributes.artwork.url != '') { <<
<< << < HEAD
this.currentArtUrl = (this.mk["nowPlayingItem"]["attributes"]["artwork"]["url"] || '').replace('{w}', 50).replace('{h}', 50); ===
=== =
this.currentArtUrl = (this.mk["nowPlayingItem"]["attributes"]["artwork"]["url"] ? ? '').replace('{w}', 50).replace('{h}', 50); >>>
>>> > c7f180daf8cf1b2cdc35e1afde3b6c3ae98b7916
if (app.mk.nowPlayingItem != null && app.mk.nowPlayingItem.attributes != null && app.mk.nowPlayingItem.attributes.artwork != null && app.mk.nowPlayingItem.attributes.artwork.url != null && app.mk.nowPlayingItem.attributes.artwork.url != '') {
this.currentArtUrl = (this.mk["nowPlayingItem"]["attributes"]["artwork"]["url"] ?? '').replace('{w}', 50).replace('{h}', 50);
try {
document.querySelector('.app-playback-controls .artwork').style.setProperty('--artwork', `url("${this.currentArtUrl}")`);
} catch (e) {}
} else {
let data = await this.mk.api.v3.music(`/v1/me/library/songs/${this.mk.nowPlayingItem.id}`);
data = data.data.data[0];
if (data != null && data !== "" && data.attributes != null && data.attributes.artwork != null) { <<
<< << < HEAD
this.currentArtUrl = (data["attributes"]["artwork"]["url"] || '').replace('{w}', 50).replace('{h}', 50); ===
=== =
this.currentArtUrl = (data["attributes"]["artwork"]["url"] ? ? '').replace('{w}', 50).replace('{h}', 50); >>>
>>> > c7f180daf8cf1b2cdc35e1afde3b6c3ae98b7916
if (data != null && data !== "" && data.attributes != null && data.attributes.artwork != null) {
this.currentArtUrl = (data["attributes"]["artwork"]["url"] ?? '').replace('{w}', 50).replace('{h}', 50);
try {
document.querySelector('.app-playback-controls .artwork').style.setProperty('--artwork', `url("${this.currentArtUrl}")`);
} catch (e) {}
@ -3111,14 +3013,9 @@ const app = new Vue({
// return Math.random().toString(36).replace(/[^a-z]+/g, '').substr(2, 10);
// }
let self = this
let data_type = this.mk.nowPlayingItem.playParams.kind <<
<< << < HEAD
let item_id = this.mk.nowPlayingItem.attributes.playParams.id || this.mk.nowPlayingItem.id
let isLibrary = this.mk.nowPlayingItem.attributes.playParams.isLibrary || false ===
=== =
let data_type = this.mk.nowPlayingItem.playParams.kind
let item_id = this.mk.nowPlayingItem.attributes.playParams.id ?? this.mk.nowPlayingItem.id
let isLibrary = this.mk.nowPlayingItem.attributes.playParams.isLibrary ? ? false >>>
>>> > c7f180daf8cf1b2cdc35e1afde3b6c3ae98b7916
let isLibrary = this.mk.nowPlayingItem.attributes.playParams.isLibrary ?? false
let params = { "fields[songs]": "inLibrary", "fields[albums]": "inLibrary", "relate": "library", "t": "1" }
// let res = await app.mkapi(data_type, isLibrary , item_id, params);
// if (res && res.relationships && res.relationships.library && res.relationships.library.data && res.relationships.library.data.length > 0) {
@ -3275,12 +3172,8 @@ const app = new Vue({
numbers.push(parseInt(item, 16))
}
numbers.shift() <<
<< << < HEAD
let gain = Math.log10((Math.max(numbers[0], numbers[1]) || 1000) / 1000.0) * -10 ===
=== =
let gain = Math.log10((Math.max(numbers[0], numbers[1]) ? ? 1000) / 1000.0) * -10 >>>
>>> > c7f180daf8cf1b2cdc35e1afde3b6c3ae98b7916
numbers.shift()
let gain = Math.log10((Math.max(numbers[0], numbers[1]) ?? 1000) / 1000.0) * -10
let peak = Math.max(numbers[6], numbers[7]) / 32768.0
return {
gain: gain,