rpc library images ( need api to work first)
This commit is contained in:
parent
802436e875
commit
2336b85291
4 changed files with 21 additions and 16 deletions
|
@ -202,22 +202,27 @@ export default class DiscordRichPresence {
|
||||||
* Runs on app ready
|
* Runs on app ready
|
||||||
*/
|
*/
|
||||||
onReady(_win: any): void {
|
onReady(_win: any): void {
|
||||||
|
let self = this
|
||||||
this.connect((DiscordRichPresence._store.general.discord_rpc == 1) ? '911790844204437504' : '886578863147192350');
|
this.connect((DiscordRichPresence._store.general.discord_rpc == 1) ? '911790844204437504' : '886578863147192350');
|
||||||
console.debug(`[Plugin][${this.name}] Ready.`);
|
console.debug(`[Plugin][${this.name}] Ready.`);
|
||||||
// ipcMain.on('updateRPCImage', (_event, imageurl) => {
|
ipcMain.on('updateRPCImage', (_event, imageurl) => {
|
||||||
// fetch('https://api.cider.sh/v1/images' ,{
|
fetch('https://api.cider.sh/v1/images' ,{
|
||||||
|
|
||||||
// method: 'POST',
|
method: 'POST',
|
||||||
// body: JSON.stringify({url : imageurl}),
|
body: JSON.stringify({url : imageurl}),
|
||||||
// headers: {
|
headers: {
|
||||||
// 'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
// 'User-Agent': 'Cider Development Environment'
|
'User-Agent': _win.webContents.getUserAgent()
|
||||||
// },
|
},
|
||||||
// })
|
})
|
||||||
// .then(res => res.text())
|
.then(res => res.json())
|
||||||
// .then(json => console.log(json))
|
.then(function(json){
|
||||||
|
self._activity['largeImageKey'] = json.url
|
||||||
|
console.log(json.url)
|
||||||
|
self._client.setActivity(self._activity);
|
||||||
|
})
|
||||||
|
|
||||||
// })
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -47,9 +47,9 @@ const MusicKitInterop = {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const id = nowPlayingItem?._songId ?? (nowPlayingItem?.songId ?? nowPlayingItem?.id)
|
const id = nowPlayingItem?._songId ?? (nowPlayingItem?.songId ?? nowPlayingItem?.id)
|
||||||
if (id != null) {
|
if (id != null && id != -1) {
|
||||||
try{
|
try{
|
||||||
const query = await mk.api.v3.music(`/v1${((nowPlayingItem?._songId ?? nowPlayingItem?.songId) != null) ? `/catalog/${mk.storefrontId}/` : `/me/library/`}songs/${id}?l=${app.mklang}`);
|
const query = await mk.api.v3.music(`/v1${(((nowPlayingItem?._songId ?? nowPlayingItem?.songId) != null) && ((nowPlayingItem?._songId ?? nowPlayingItem?.songId) != -1)) ? `/catalog/${mk.storefrontId}/` : `/me/library/`}songs/${id}?l=${app.mklang}`);
|
||||||
if (query?.data?.data[0]){
|
if (query?.data?.data[0]){
|
||||||
let attrs = query?.data?.data[0]?.attributes;
|
let attrs = query?.data?.data[0]?.attributes;
|
||||||
if (attrs?.name) { nowPlayingItem.attributes.name = attrs?.name ?? ''}
|
if (attrs?.name) { nowPlayingItem.attributes.name = attrs?.name ?? ''}
|
||||||
|
|
|
@ -746,7 +746,7 @@ const app = new Vue({
|
||||||
previewURL = app.mk.nowPlayingItem.previewURL
|
previewURL = app.mk.nowPlayingItem.previewURL
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
}
|
}
|
||||||
if (!previewURL) {
|
if (previewURL == null && ((app.mk.nowPlayingItem?._songId ?? (app.mk.nowPlayingItem["songId"] ?? app.mk.nowPlayingItem.relationships.catalog.data[0].id)) != -1)) {
|
||||||
app.mk.api.v3.music(`/v1/catalog/${app.mk.storefrontId}/songs/${app.mk.nowPlayingItem?._songId ?? (app.mk.nowPlayingItem["songId"] ?? app.mk.nowPlayingItem.relationships.catalog.data[0].id)}`).then((response) => {
|
app.mk.api.v3.music(`/v1/catalog/${app.mk.storefrontId}/songs/${app.mk.nowPlayingItem?._songId ?? (app.mk.nowPlayingItem["songId"] ?? app.mk.nowPlayingItem.relationships.catalog.data[0].id)}`).then((response) => {
|
||||||
previewURL = response.data.data[0].attributes.previews[0].url
|
previewURL = response.data.data[0].attributes.previews[0].url
|
||||||
if (previewURL)
|
if (previewURL)
|
||||||
|
|
|
@ -124,7 +124,7 @@
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
this.$root.inLibrary([this.item]).then(res => {
|
this.$root.inLibrary([this.item]).then(res => {
|
||||||
this.addedToLibrary = res[0].attributes.inLibrary
|
this.addedToLibrary = res[0]?.attributes?.inLibrary ?? false
|
||||||
})
|
})
|
||||||
return this.addedToLibrary
|
return this.addedToLibrary
|
||||||
},
|
},
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue