Skip to content

Commit 1dacc59

Browse files
author
GreenDiscord
committed
Woop! Introducing Multiple Artwork Sources!!
1 parent d8fd4ec commit 1dacc59

File tree

5 files changed

+115
-15
lines changed

5 files changed

+115
-15
lines changed

config/config.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,30 @@
1+
const { appendFile } = require("fs");
2+
13
module.exports = {
24

35
// The full path to your VLC executable
46
// If left blank, typical defaults are used
57
vlcPath: "E:/Programs/VLC/vlc.exe",
8+
9+
debug : "false",
610

711
rpc: {
12+
13+
// Set the text for the large image, this accepts, title, album, volume, artist and fetched.
14+
largeImageText: "fetched",
815

916
// The Discord application ID for the rich presence
1017
id: '1032293686098272316',
1118

1219
// How frequently in milliseconds to check for updates
1320
updateInterval: 1000,
1421

22+
// Change where to fetch the album artwork (spotify and apple only supported)
23+
whereToFetchOnline: "apple",
24+
25+
// Change the provider for the rpc button (youtube and apple only, not yet implemented)
26+
changeButtonProvider: "apple",
27+
1528
// When playback is paused, wait this many milliseconds
1629
// before removing your rich presence
1730
sleepTime: 30000,

config/config.json

Lines changed: 0 additions & 9 deletions
This file was deleted.

package-lock.json

Lines changed: 55 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@
44
"description": "Discord rich presence for VLC media player.",
55
"main": "index.js",
66
"dependencies": {
7+
"album-art": "^2.0.2",
8+
"axios": "^1.1.3",
79
"discord-rpc": "^3.1.1",
810
"form-data": "^4.0.0",
9-
"album-art": "^2.0.2",
1011
"vlc.js": "^3.1.0"
1112
},
1213
"scripts": {

src/rpc/format.js

Lines changed: 45 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@
33
*/
44

55

6-
6+
const fs = require('fs')
77
const log = require('../helpers/lager.js');
88
const config = require('../../config/config.js');
9+
const axios = require('axios')
910
const albumArt = require('album-art');
1011

1112

@@ -23,21 +24,60 @@ module.exports = async (status) => {
2324
const { meta } = status.information.category;
2425

2526

27+
const fetchArtworkApple = async (searchQuery) => {
28+
const params = {
29+
media: "music",
30+
term: searchQuery,
31+
};
32+
return axios.get("https://itunes.apple.com/search", {
33+
params,
34+
});
35+
};
2636

2737
const artist = String(meta.artist);
2838
const options = {
2939
album: String(encodeURIComponent(meta.album))
3040
}
3141

32-
const art = await albumArt(artist, options).then((data) => data);
3342

34-
console.log(art);
35-
console.log(status.state)
43+
if (config.rpc.whereToFetchOnline === 'apple') {
44+
var appleresponse = await fetchArtworkApple(`${meta.title} ${meta.artist}`);
45+
var artwork = appleresponse.data.results[0].artworkUrl100;
46+
var fetched = "Apple";
47+
if (artwork === undefined) {
48+
var artwork = await albumArt(artist, options).then((data) => data);
49+
var fetched = "Spotify";
50+
}
51+
} else {
52+
var artwork = await albumArt(artist, options).then((data) => data);
53+
var fetched = "Spotify";
54+
}
55+
56+
if (config.debug === 'true') {
57+
console.log(artwork),
58+
console.log(status.state),
59+
console.log(fetched)
60+
}
61+
62+
if (config.rpc.largeImageText === "artist"){
63+
var largeImageTextIs = meta.artist
64+
} else if (config.rpc.largeImageText === "album") {
65+
var largeImageTextIs = meta.album
66+
} else if (config.rpc.largeImageText === "volume") {
67+
var largeImageTextIs = `Volume: ${Math.round(status.volume / 2.56)}%`
68+
} else if (config.rpc.largeImageText === "title") {
69+
var largeImageTextIs = meta.title
70+
} else if (config.rpc.largeImageText === "fetched") {
71+
var largeImageTextIs = `Artwork fetched from ${fetched}`
72+
}
73+
74+
3675

3776

3877
const output = {
3978
details: meta.title || meta.filename || "Playing something..",
40-
largeImageKey: `${await albumArt(artist, options).then((data) => data)}` || "https://i.pinimg.com/originals/67/f6/cb/67f6cb14f862297e3c145014cdd6b635.jpg",
79+
largeImageText: largeImageTextIs,
80+
largeImageKey: artwork || "https://i.pinimg.com/originals/67/f6/cb/67f6cb14f862297e3c145014cdd6b635.jpg",
4181
smallImageKey: status.state,
4282
smallImageText: `Volume: ${Math.round(status.volume / 2.56)}%`,
4383
instance: true,

0 commit comments

Comments
 (0)