This commit is contained in:
child_duckling 2022-01-17 19:09:02 -08:00
commit e6567d5f62
3 changed files with 3429 additions and 3316 deletions

View file

@ -82,9 +82,9 @@
} }
], ],
"build": { "build": {
"electronVersion": "16.0.6", "electronVersion": "16.0.7",
"electronDownload": { "electronDownload": {
"version": "16.0.6+wvcus", "version": "16.0.7+wvcus",
"mirror": "https://github.com/castlabs/electron-releases/releases/download/v" "mirror": "https://github.com/castlabs/electron-releases/releases/download/v"
}, },
"appId": "cider", "appId": "cider",

View file

@ -30,8 +30,10 @@ electron.app.on('ready', () => {
console.info('[Cider] Running in development mode.') console.info('[Cider] Running in development mode.')
require('vue-devtools').install() require('vue-devtools').install()
} }
electron.components.whenReady().then(() => {
Cider.createWindow(); Cider.createWindow();
})
}); });
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@ -52,23 +54,27 @@ electron.app.on('before-quit', () => {
console.warn(`${electron.app.getName()} exited.`); console.warn(`${electron.app.getName()} exited.`);
}); });
// //
// // @ts-ignore
// // Widevine Stuff // // Widevine Stuff
// app.on('widevine-ready', (version, lastVersion) => { // electron.app.on('widevine-ready', (version, lastVersion) => {
// if (null !== lastVersion) { // if (null !== lastVersion) {
// console.log('[Cider][Widevine] Widevine ' + version + ', upgraded from ' + lastVersion + ', is ready to be used!') // console.log('[Cider][Widevine] Widevine ' + version + ', upgraded from ' + lastVersion + ', is ready to be used!')
// } else { // } else {
// console.log('[Cider][Widevine] Widevine ' + version + ' is ready to be used!') // console.log('[Cider][Widevine] Widevine ' + version + ' is ready to be used!')
// } // }
// }) // })
//
// app.on('widevine-update-pending', (currentVersion, pendingVersion) => { // // @ts-ignore
// electron.app.on('widevine-update-pending', (currentVersion, pendingVersion) => {
// console.log('[Cider][Widevine] Widevine ' + currentVersion + ' is ready to be upgraded to ' + pendingVersion + '!') // console.log('[Cider][Widevine] Widevine ' + currentVersion + ' is ready to be upgraded to ' + pendingVersion + '!')
// }) // })
//
// app.on('widevine-error', (error) => { // // @ts-ignore
// electron.app.on('widevine-error', (error) => {
// console.log('[Cider][Widevine] Widevine installation encountered an error: ' + error) // console.log('[Cider][Widevine] Widevine installation encountered an error: ' + error)
// app.exit() // electron.app.exit()
// }) // })
// //
// //
// app.on('open-url', (event, url) => { // app.on('open-url', (event, url) => {

View file

@ -366,9 +366,9 @@ const app = new Vue({
}, },
async showMenuPanel(data, event) { async showMenuPanel(data, event) {
app.menuPanel.visible = true; app.menuPanel.visible = true;
app.menuPanel.content.name = data.name || ""; app.menuPanel.content.name = data.name ? ? "";
app.menuPanel.content.items = data.items || {}; app.menuPanel.content.items = data.items ? ? {};
app.menuPanel.content.headerItems = data.headerItems || {}; app.menuPanel.content.headerItems = data.headerItems ? ? {};
if (event) { if (event) {
app.menuPanel.event = event; app.menuPanel.event = event;
} }
@ -646,8 +646,12 @@ const app = new Vue({
try { try {
a = a.item.attributes; a = a.item.attributes;
} catch (_) {} } catch (_) {} <<
let type = (self.mk.nowPlayingItem != null) ? self.mk.nowPlayingItem["type"] || '' : ''; << << < HEAD
let type = (self.mk.nowPlayingItem != null) ? self.mk.nowPlayingItem["type"] || '' : ''; ===
=== =
let type = (self.mk.nowPlayingItem != null) ? self.mk.nowPlayingItem["type"] ? ? '' : ''; >>>
>>> > c7f180daf8cf1b2cdc35e1afde3b6c3ae98b7916
if (type.includes("musicVideo") || type.includes("uploadedVideo") || type.includes("music-movie")) { if (type.includes("musicVideo") || type.includes("uploadedVideo") || type.includes("music-movie")) {
document.getElementById("apple-music-video-container").style.display = "block"; document.getElementById("apple-music-video-container").style.display = "block";
@ -1083,8 +1087,12 @@ const app = new Vue({
} }
let hash = route.split("/") let hash = route.split("/")
let page = hash[0] let page = hash[0]
let id = hash[1] let id = hash[1] <<
let isLibrary = hash[2] || false << << < HEAD
let isLibrary = hash[2] || false ===
=== =
let isLibrary = hash[2] ? ? false >>>
>>> > c7f180daf8cf1b2cdc35e1afde3b6c3ae98b7916
console.log(`page: ${page} id: ${id} isLibrary: ${isLibrary}`) console.log(`page: ${page} id: ${id} isLibrary: ${isLibrary}`)
this.routeView({ this.routeView({
kind: page, kind: page,
@ -1094,10 +1102,16 @@ const app = new Vue({
} }
}) })
}, },
routeView(item) { routeView(item) { <<
<< << < HEAD
let kind = (item.attributes.playParams ? (item.attributes.playParams.kind || (item.type || '')) : (item.type || '')); 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 id = (item.attributes.playParams ? (item.attributes.playParams.id || (item.id || '')) : (item.id || ''));;
let isLibrary = item.attributes.playParams ? (item.attributes.playParams.isLibrary || false) : false; let isLibrary = item.attributes.playParams ? (item.attributes.playParams.isLibrary || false) : false; ===
=== =
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
console.log(kind, id, isLibrary) console.log(kind, id, isLibrary)
if (true) { if (true) {
@ -1139,8 +1153,12 @@ const app = new Vue({
app.getTypeFromID((kind), (id), (isLibrary), params); app.getTypeFromID((kind), (id), (isLibrary), params);
window.location.hash = `${kind}/${id}${isLibrary ? "/" + isLibrary : ''}` window.location.hash = `${kind}/${id}${isLibrary ? "/" + isLibrary : ''}`
document.querySelector("#app-content").scrollTop = 0 document.querySelector("#app-content").scrollTop = 0
} else { } else { <<
app.playMediaItemById((id), (kind), (isLibrary), item.attributes.url || '') << << < HEAD
app.playMediaItemById((id), (kind), (isLibrary), item.attributes.url || '') ===
=== =
app.playMediaItemById((id), (kind), (isLibrary), item.attributes.url ? ? '') >>>
>>> > c7f180daf8cf1b2cdc35e1afde3b6c3ae98b7916
} }
} }
@ -1264,10 +1282,16 @@ const app = new Vue({
this.getArtistFromID(id) this.getArtistFromID(id)
//this.getTypeFromID("artist",id,isLibrary,query) //this.getTypeFromID("artist",id,isLibrary,query)
}, },
playMediaItem(item) { playMediaItem(item) { <<
<< << < HEAD
let kind = (item.attributes.playParams ? (item.attributes.playParams.kind || (item.type || '')) : (item.type || '')); 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 id = (item.attributes.playParams ? (item.attributes.playParams.id || (item.id || '')) : (item.id || ''));;
let isLibrary = item.attributes.playParams ? (item.attributes.playParams.isLibrary || false) : false; let isLibrary = item.attributes.playParams ? (item.attributes.playParams.isLibrary || false) : false; ===
=== =
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 truekind = (!kind.endsWith("s")) ? (kind + "s") : kind; let truekind = (!kind.endsWith("s")) ? (kind + "s") : kind;
console.log(kind, id, isLibrary) console.log(kind, id, isLibrary)
app.mk.stop().then(() => { app.mk.stop().then(() => {
@ -1342,8 +1366,12 @@ const app = new Vue({
// } // }
// }) // })
// } // }
else { else { <<
app.playMediaItemById((id), (kind), (isLibrary), item.attributes.url || '') << << < HEAD
app.playMediaItemById((id), (kind), (isLibrary), item.attributes.url || '') ===
=== =
app.playMediaItemById((id), (kind), (isLibrary), item.attributes.url ? ? '') >>>
>>> > c7f180daf8cf1b2cdc35e1afde3b6c3ae98b7916
} }
}) })
}, },
@ -1995,8 +2023,12 @@ const app = new Vue({
showSearch() { showSearch() {
this.page = "search" this.page = "search"
}, },
loadLyrics() { loadLyrics() { <<
const musicType = (MusicKit.getInstance().nowPlayingItem != null) ? MusicKit.getInstance().nowPlayingItem["type"] || '' : ''; << << < HEAD
const musicType = (MusicKit.getInstance().nowPlayingItem != null) ? MusicKit.getInstance().nowPlayingItem["type"] || '' : ''; ===
=== =
const musicType = (MusicKit.getInstance().nowPlayingItem != null) ? MusicKit.getInstance().nowPlayingItem["type"] ? ? '' : ''; >>>
>>> > c7f180daf8cf1b2cdc35e1afde3b6c3ae98b7916
console.log("mt", musicType) console.log("mt", musicType)
if (musicType === "musicVideo") { if (musicType === "musicVideo") {
this.loadYTLyrics(); this.loadYTLyrics();
@ -2008,8 +2040,12 @@ const app = new Vue({
} }
} }
}, },
loadAMLyrics() { loadAMLyrics() { <<
const songID = (this.mk.nowPlayingItem != null) ? this.mk.nowPlayingItem["_songId"] || -1 : -1; << << < 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
// this.getMXM( trackName, artistName, 'en', duration); // this.getMXM( trackName, artistName, 'en', duration);
if (songID != -1) { if (songID != -1) {
MusicKit.getInstance().api.lyric(songID) MusicKit.getInstance().api.lyric(songID)
@ -2036,15 +2072,25 @@ const app = new Vue({
self.getLibrarySongsFull(true) self.getLibrarySongsFull(true)
}) })
}, },
async loadYTLyrics() { async loadYTLyrics() { <<
<< << < HEAD
const track = (this.mk.nowPlayingItem != null) ? this.mk.nowPlayingItem.title || '' : ''; const track = (this.mk.nowPlayingItem != null) ? this.mk.nowPlayingItem.title || '' : '';
const artist = (this.mk.nowPlayingItem != null) ? this.mk.nowPlayingItem.artistName || '' : ''; 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; const time = (this.mk.nowPlayingItem != null) ? (Math.round((this.mk.nowPlayingItem.attributes["durationInMillis"] || -1000) / 1000) || -1) : -1; ===
=== =
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
ipcRenderer.invoke('getYTLyrics', track, artist).then((result) => { ipcRenderer.invoke('getYTLyrics', track, artist).then((result) => {
if (result.length > 0) { if (result.length > 0) {
let ytid = result[0]['id']['videoId']; let ytid = result[0]['id']['videoId'];
if (app.cfg.lyrics.enable_yt) { if (app.cfg.lyrics.enable_yt) { <<
loadYT(ytid, app.cfg.lyrics.mxm_language || "en") << << < HEAD
loadYT(ytid, app.cfg.lyrics.mxm_language || "en") ===
=== =
loadYT(ytid, app.cfg.lyrics.mxm_language ? ? "en") >>>
>>> > c7f180daf8cf1b2cdc35e1afde3b6c3ae98b7916
} else { } else {
app.loadMXM() app.loadMXM()
} }
@ -2100,11 +2146,18 @@ const app = new Vue({
}, },
loadMXM() { loadMXM() {
let attempt = 0; let attempt = 0; <<
<< << < HEAD
const track = encodeURIComponent((this.mk.nowPlayingItem != null) ? this.mk.nowPlayingItem.title || '' : ''); const track = encodeURIComponent((this.mk.nowPlayingItem != null) ? this.mk.nowPlayingItem.title || '' : '');
const artist = encodeURIComponent((this.mk.nowPlayingItem != null) ? this.mk.nowPlayingItem.artistName || '' : ''); 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 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 || '' : ''); const id = encodeURIComponent((this.mk.nowPlayingItem != null) ? app.mk.nowPlayingItem._songId || '' : ''); ===
=== =
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
let lrcfile = ""; let lrcfile = "";
let richsync = []; let richsync = [];
const lang = app.cfg.lyrics.mxm_language // translation language const lang = app.cfg.lyrics.mxm_language // translation language
@ -2126,8 +2179,12 @@ const app = new Vue({
req.onload = function() { req.onload = function() {
let jsonResponse = JSON.parse(this.responseText); let jsonResponse = JSON.parse(this.responseText);
let status2 = jsonResponse["message"]["header"]["status_code"]; let status2 = jsonResponse["message"]["header"]["status_code"];
if (status2 == 200) { if (status2 == 200) { <<
let token = jsonResponse["message"]["body"]["user_token"] || ''; << << < HEAD
let token = jsonResponse["message"]["body"]["user_token"] || ''; ===
=== =
let token = jsonResponse["message"]["body"]["user_token"] ? ? ''; >>>
>>> > c7f180daf8cf1b2cdc35e1afde3b6c3ae98b7916
if (token != "" && token != "UpgradeOnlyUpgradeOnlyUpgradeOnlyUpgradeOnly") { if (token != "" && token != "UpgradeOnlyUpgradeOnlyUpgradeOnlyUpgradeOnly") {
console.log('200 token', mode); console.log('200 token', mode);
// token good // token good
@ -2174,8 +2231,12 @@ const app = new Vue({
if (status1 == 200) { if (status1 == 200) {
let id = ''; let id = '';
try { 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) { 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"] || ''; << << < 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
lrcfile = jsonResponse["message"]["body"]["macro_calls"]["track.subtitles.get"]["message"]["body"]["subtitle_list"][0]["subtitle"]["subtitle_body"]; lrcfile = jsonResponse["message"]["body"]["macro_calls"]["track.subtitles.get"]["message"]["body"]["subtitle_list"][0]["subtitle"]["subtitle_body"];
try { try {
@ -2195,10 +2256,18 @@ const app = new Vue({
let u = app.lyricsMediaItem.split(/[\r\n]/); let u = app.lyricsMediaItem.split(/[\r\n]/);
let preLrc = [] let preLrc = []
for (var i = u.length - 1; i >= 0; i--) { for (var i = u.length - 1; i >= 0; i--) {
let xline = (/(\[[0-9.:\[\]]*\])+(.*)/).exec(u[i]) let xline = (/(\[[0-9.:\[\]]*\])+(.*)/).exec(u[i]) <<
<< << < HEAD
let end = (preLrc.length > 0) ? ((preLrc[preLrc.length - 1].startTime) || 99999) : 99999 let end = (preLrc.length > 0) ? ((preLrc[preLrc.length - 1].startTime) || 99999) : 99999
preLrc.push({ preLrc.push({
startTime: app.toMS(xline[1].substring(1, xline[1].length - 2)) || 0, startTime: app.toMS(xline[1].substring(1, xline[1].length - 2)) || 0,
===
=== =
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, endTime: end,
line: xline[2], line: xline[2],
translation: '' translation: ''
@ -2210,9 +2279,9 @@ const app = new Vue({
endTime: preLrc[preLrc.length - 1].startTime, endTime: preLrc[preLrc.length - 1].startTime,
line: "lrcInstrumental", line: "lrcInstrumental",
translation: '' translation: ''
}); }); app.lyrics = preLrc.reverse();
app.lyrics = preLrc.reverse(); }
} else { else {
preLrc = richsync.map(function(item) { preLrc = richsync.map(function(item) {
return { return {
startTime: item.ts, startTime: item.ts,
@ -2458,10 +2527,14 @@ const app = new Vue({
if (childIndex != -1) { if (childIndex != -1) {
app.mk.changeToMediaAtIndex(childIndex) app.mk.changeToMediaAtIndex(childIndex)
} else if (item) { } else if (item) {
app.mk.playNext({ app.mk.playNext({ <<
[item.attributes.playParams.kind || item.type]: item.attributes.playParams.id || item.id << << < HEAD[item.attributes.playParams.kind || item.type]: item.attributes.playParams.id || item.id
}).then(function() { }).then(function() {
app.mk.changeToMediaAtIndex(app.mk.queue._itemIDs.indexOf(item.id) || 1) 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.play() app.mk.play()
}) })
} else { } else {
@ -2472,10 +2545,14 @@ const app = new Vue({
} else { } else {
app.mk.stop().then(() => { app.mk.stop().then(() => {
if (truekind == "playlists" && (id.startsWith("p.") || id.startsWith("pl.u"))) { if (truekind == "playlists" && (id.startsWith("p.") || id.startsWith("pl.u"))) {
app.mk.setQueue({ app.mk.setQueue({ <<
[item.attributes.playParams.kind || item.type]: item.attributes.playParams.id || item.id << << < HEAD[item.attributes.playParams.kind || item.type]: item.attributes.playParams.id || item.id
}).then(function() { }).then(function() {
app.mk.changeToMediaAtIndex(app.mk.queue._itemIDs.indexOf(item.id) || 1).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
if ((app.showingPlaylist && app.showingPlaylist.id == id)) { if ((app.showingPlaylist && app.showingPlaylist.id == id)) {
let query = app.showingPlaylist.relationships.tracks.data.map(item => new MusicKit.MediaItem(item)); let query = app.showingPlaylist.relationships.tracks.data.map(item => new MusicKit.MediaItem(item));
let u = query; let u = query;
@ -2506,10 +2583,14 @@ const app = new Vue({
if (childIndex != -1) { if (childIndex != -1) {
app.mk.changeToMediaAtIndex(childIndex) app.mk.changeToMediaAtIndex(childIndex)
} else if (item) { } else if (item) {
app.mk.playNext({ app.mk.playNext({ <<
[item.attributes.playParams.kind || item.type]: item.attributes.playParams.id || item.id << << < HEAD[item.attributes.playParams.kind || item.type]: item.attributes.playParams.id || item.id
}).then(function() { }).then(function() {
app.mk.changeToMediaAtIndex(app.mk.queue._itemIDs.indexOf(item.id) || 1) 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.play() app.mk.play()
}) })
} else { } else {
@ -2519,12 +2600,17 @@ const app = new Vue({
} }
}) })
} }
} catch (err) { }
catch (err) {
console.log(err) console.log(err)
try { try {
app.mk.stop() app.mk.stop()
} catch (e) {} } catch (e) {} <<
this.playMediaItemById(item.attributes.playParams.id || item.id, item.attributes.playParams.kind || item.type, item.attributes.playParams.isLibrary || false, item.attributes.url) << << < 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
} }
}, },
@ -2621,8 +2707,12 @@ const app = new Vue({
if (type.slice(-1) != "s") { if (type.slice(-1) != "s") {
type += "s" type += "s"
} }
type = type.replace("library-", "") type = type.replace("library-", "") <<
let id = item.attributes.playParams.catalogId || item.id << << < HEAD
let id = item.attributes.playParams.catalogId || item.id ===
=== =
let id = item.attributes.playParams.catalogId ? ? item.id >>>
>>> > c7f180daf8cf1b2cdc35e1afde3b6c3ae98b7916
let index = types.findIndex(function(type) { let index = types.findIndex(function(type) {
return type.type == this return type.type == this
@ -2804,16 +2894,24 @@ const app = new Vue({
async getCurrentArtURL() { async getCurrentArtURL() {
try { try {
this.currentArtUrl = ''; 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 != '') { 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); << << < 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
try { try {
document.querySelector('.app-playback-controls .artwork').style.setProperty('--artwork', `url("${this.currentArtUrl}")`); document.querySelector('.app-playback-controls .artwork').style.setProperty('--artwork', `url("${this.currentArtUrl}")`);
} catch (e) {} } catch (e) {}
} else { } else {
let data = await this.mk.api.v3.music(`/v1/me/library/songs/${this.mk.nowPlayingItem.id}`); let data = await this.mk.api.v3.music(`/v1/me/library/songs/${this.mk.nowPlayingItem.id}`);
data = data.data.data[0]; data = data.data.data[0];
if (data != null && data !== "" && data.attributes != null && data.attributes.artwork != null) { if (data != null && data !== "" && data.attributes != null && data.attributes.artwork != null) { <<
this.currentArtUrl = (data["attributes"]["artwork"]["url"] || '').replace('{w}', 50).replace('{h}', 50); << << < 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
try { try {
document.querySelector('.app-playback-controls .artwork').style.setProperty('--artwork', `url("${this.currentArtUrl}")`); document.querySelector('.app-playback-controls .artwork').style.setProperty('--artwork', `url("${this.currentArtUrl}")`);
} catch (e) {} } catch (e) {}
@ -3013,9 +3111,14 @@ const app = new Vue({
// return Math.random().toString(36).replace(/[^a-z]+/g, '').substr(2, 10); // return Math.random().toString(36).replace(/[^a-z]+/g, '').substr(2, 10);
// } // }
let self = this let self = this
let data_type = this.mk.nowPlayingItem.playParams.kind let data_type = this.mk.nowPlayingItem.playParams.kind <<
<< << < HEAD
let item_id = this.mk.nowPlayingItem.attributes.playParams.id || this.mk.nowPlayingItem.id let item_id = this.mk.nowPlayingItem.attributes.playParams.id || this.mk.nowPlayingItem.id
let isLibrary = this.mk.nowPlayingItem.attributes.playParams.isLibrary || false let isLibrary = this.mk.nowPlayingItem.attributes.playParams.isLibrary || false ===
=== =
let item_id = this.mk.nowPlayingItem.attributes.playParams.id ? ? this.mk.nowPlayingItem.id
let isLibrary = this.mk.nowPlayingItem.attributes.playParams.isLibrary ? ? false >>>
>>> > c7f180daf8cf1b2cdc35e1afde3b6c3ae98b7916
let params = { "fields[songs]": "inLibrary", "fields[albums]": "inLibrary", "relate": "library", "t": "1" } let params = { "fields[songs]": "inLibrary", "fields[albums]": "inLibrary", "relate": "library", "t": "1" }
// let res = await app.mkapi(data_type, isLibrary , item_id, params); // 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) { // if (res && res.relationships && res.relationships.library && res.relationships.library.data && res.relationships.library.data.length > 0) {
@ -3172,8 +3275,12 @@ const app = new Vue({
numbers.push(parseInt(item, 16)) numbers.push(parseInt(item, 16))
} }
numbers.shift() numbers.shift() <<
let gain = Math.log10((Math.max(numbers[0], numbers[1]) || 1000) / 1000.0) * -10 << << < 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
let peak = Math.max(numbers[6], numbers[7]) / 32768.0 let peak = Math.max(numbers[6], numbers[7]) / 32768.0
return { return {
gain: gain, gain: gain,
@ -3215,9 +3322,9 @@ const app = new Vue({
}, },
} }
}) })
Vue.component('animated-number', { Vue.component('animated-number', {
template: "<div style='display: inline-block;'>{{ displayNumber }}</div>", template: "<div style='display: inline-block;'>{{ displayNumber }}</div>",
props: { 'number': { default: 0 } }, props: { 'number': { default: 0 } },
@ -3250,9 +3357,9 @@ Vue.component('animated-number', {
}, 20); }, 20);
} }
} }
}) })
Vue.component('sidebar-library-item', { Vue.component('sidebar-library-item', {
template: '#sidebar-library-item', template: '#sidebar-library-item',
props: { props: {
name: { name: {
@ -3285,29 +3392,29 @@ Vue.component('sidebar-library-item', {
} }
}, },
methods: {} methods: {}
}); });
// Key binds // Key binds
document.addEventListener('keydown', function(e) { document.addEventListener('keydown', function(e) {
if (e.keyCode === 70 && e.ctrlKey) { if (e.keyCode === 70 && e.ctrlKey) {
app.$refs.searchInput.focus() app.$refs.searchInput.focus()
app.$refs.searchInput.select() app.$refs.searchInput.select()
} }
}); });
// Hang Timer // Hang Timer
app.hangtimer = setTimeout(() => { app.hangtimer = setTimeout(() => {
if (confirm("Cider is not responding. Reload the app?")) { if (confirm("Cider is not responding. Reload the app?")) {
window.location.reload() window.location.reload()
} }
}, 10000) }, 10000)
// add event listener for when window.location.hash changes // add event listener for when window.location.hash changes
window.addEventListener("hashchange", function() { window.addEventListener("hashchange", function() {
app.appRoute(window.location.hash) app.appRoute(window.location.hash)
}); });
document.addEventListener('musickitloaded', function() { document.addEventListener('musickitloaded', function() {
// MusicKit global is now defined // MusicKit global is now defined
function initMusicKit() { function initMusicKit() {
let parsedJson = JSON.parse(this.responseText) let parsedJson = JSON.parse(this.responseText)
@ -3367,16 +3474,16 @@ document.addEventListener('musickitloaded', function() {
window.addEventListener("drmUnsupported", function() { window.addEventListener("drmUnsupported", function() {
initMusicKit() initMusicKit()
}); });
}); });
if ('serviceWorker' in navigator) { if ('serviceWorker' in navigator) {
// Use the window load event to keep the page load performant // Use the window load event to keep the page load performant
window.addEventListener('load', () => { window.addEventListener('load', () => {
navigator.serviceWorker.register('sw.js?v=1'); navigator.serviceWorker.register('sw.js?v=1');
}); });
} }
const getBase64FromUrl = async(url) => { const getBase64FromUrl = async(url) => {
const data = await fetch(url); const data = await fetch(url);
const blob = await data.blob(); const blob = await data.blob();
return new Promise((resolve) => { return new Promise((resolve) => {
@ -3387,28 +3494,28 @@ const getBase64FromUrl = async(url) => {
resolve(base64data); resolve(base64data);
} }
}); });
} }
function uuidv4() { function uuidv4() {
return ([1e7] + -1e3 + -4e3 + -8e3 + -1e11).replace(/[018]/g, c => return ([1e7] + -1e3 + -4e3 + -8e3 + -1e11).replace(/[018]/g, c =>
(c ^ crypto.getRandomValues(new Uint8Array(1))[0] & 15 >> c / 4).toString(16) (c ^ crypto.getRandomValues(new Uint8Array(1))[0] & 15 >> c / 4).toString(16)
); );
} }
function refreshFocus() { function refreshFocus() {
if (document.hasFocus() == false) { if (document.hasFocus() == false) {
app.windowFocus(false) app.windowFocus(false)
} else { } else {
app.windowFocus(true) app.windowFocus(true)
} }
setTimeout(refreshFocus, 200); setTimeout(refreshFocus, 200);
} }
app.getHTMLStyle() app.getHTMLStyle()
refreshFocus(); refreshFocus();
function xmlToJson(xml) { function xmlToJson(xml) {
// Create the return object // Create the return object
let obj = {}; let obj = {};
@ -3445,15 +3552,15 @@ function xmlToJson(xml) {
} }
console.log(obj); console.log(obj);
return obj; return obj;
}; };
async function asyncForEach(array, callback) { async function asyncForEach(array, callback) {
for (let index = 0; index < array.length; index++) { for (let index = 0; index < array.length; index++) {
await callback(array[index], index, array); await callback(array[index], index, array);
} }
} }
var checkIfScrollIsStatic = setInterval(() => { var checkIfScrollIsStatic = setInterval(() => {
try { try {
if (position === document.getElementsByClassName('lyric-body')[0].scrollTop) { if (position === document.getElementsByClassName('lyric-body')[0].scrollTop) {
clearInterval(checkIfScrollIsStatic) clearInterval(checkIfScrollIsStatic)
@ -3462,19 +3569,19 @@ var checkIfScrollIsStatic = setInterval(() => {
position = document.getElementsByClassName('lyric-body')[0].scrollTop position = document.getElementsByClassName('lyric-body')[0].scrollTop
} catch (e) {} } catch (e) {}
}, 50); }, 50);
// WebGPU Console Notification // WebGPU Console Notification
async function webGPU() { async function webGPU() {
try { try {
const currentGPU = await navigator.gpu.requestAdapter() const currentGPU = await navigator.gpu.requestAdapter()
console.log("WebGPU enabled on", currentGPU.name, "with feature ID", currentGPU.features.size) console.log("WebGPU enabled on", currentGPU.name, "with feature ID", currentGPU.features.size)
} catch (e) { } catch (e) {
console.log("WebGPU disabled / WebGPU initialization failed") console.log("WebGPU disabled / WebGPU initialization failed")
} }
} }
webGPU().then() webGPU().then()
let screenWidth = screen.width; let screenWidth = screen.width;
let screenHeight = screen.height; let screenHeight = screen.height;