mirror of
https://github.com/informaticker/discord-jellyfin-bot.git
synced 2024-11-23 18:21:55 +01:00
implement basic debug logging
This commit is contained in:
parent
fb38c2b37d
commit
f75b978dd8
@ -5,5 +5,6 @@
|
|||||||
"jellyfin-password":"",
|
"jellyfin-password":"",
|
||||||
"discord-prefix":"?",
|
"discord-prefix":"?",
|
||||||
"jellyfin-app-name":"Jellyfin Discord Music Bot",
|
"jellyfin-app-name":"Jellyfin Discord Music Bot",
|
||||||
"interactive-seek-bar-update-intervall":2000
|
"interactive-seek-bar-update-intervall":2000,
|
||||||
|
"log-level":"info"
|
||||||
}
|
}
|
||||||
|
@ -28,6 +28,7 @@
|
|||||||
"@discordjs/opus": "^0.3.2",
|
"@discordjs/opus": "^0.3.2",
|
||||||
"discord.js": "^12.3.1",
|
"discord.js": "^12.3.1",
|
||||||
"jellyfin-apiclient": "1.4.1",
|
"jellyfin-apiclient": "1.4.1",
|
||||||
|
"loglevel": "^1.7.1",
|
||||||
"node-fetch": "^2.6.0",
|
"node-fetch": "^2.6.0",
|
||||||
"nodejs": "0.0.0",
|
"nodejs": "0.0.0",
|
||||||
"window": "^4.2.7",
|
"window": "^4.2.7",
|
||||||
|
@ -9,6 +9,7 @@ if (process.env.JELLYFIN_USERNAME) { configfile["jellyfin-username"] = process.e
|
|||||||
if (process.env.JELLYFIN_PASSWORD) { configfile["jellyfin-password"] = process.env.JELLYFIN_PASSWORD; }
|
if (process.env.JELLYFIN_PASSWORD) { configfile["jellyfin-password"] = process.env.JELLYFIN_PASSWORD; }
|
||||||
if (process.env.JELLYFIN_APP_NAME) { configfile["jellyfin-app-name"] = process.env.JELLYFIN_APP_NAME; }
|
if (process.env.JELLYFIN_APP_NAME) { configfile["jellyfin-app-name"] = process.env.JELLYFIN_APP_NAME; }
|
||||||
if (process.env.MESSAGE_UPDATE_INTERVAL) { configfile["interactive-seek-bar-update-intervall"] = parseInt(process.env.MESSAGE_UPDATE_INTERVAL); }
|
if (process.env.MESSAGE_UPDATE_INTERVAL) { configfile["interactive-seek-bar-update-intervall"] = parseInt(process.env.MESSAGE_UPDATE_INTERVAL); }
|
||||||
|
if (process.env.LOG_LEVEL) { configfile["log-level"] = process.env.LOG_LEVEL; }
|
||||||
|
|
||||||
fs.writeFile(filename, JSON.stringify(configfile, null, 1), (err) => {
|
fs.writeFile(filename, JSON.stringify(configfile, null, 1), (err) => {
|
||||||
if (err) return console.error(err);
|
if (err) return console.error(err);
|
||||||
|
@ -9,6 +9,9 @@ try {
|
|||||||
const {
|
const {
|
||||||
handleChannelMessage
|
handleChannelMessage
|
||||||
} = require("./messagehandler");
|
} = require("./messagehandler");
|
||||||
|
const log = require("loglevel");
|
||||||
|
|
||||||
|
log.setLevel(CONFIG["log-level"]);
|
||||||
|
|
||||||
jellyfinClientManager.init();
|
jellyfinClientManager.init();
|
||||||
// TODO Error Checking as the apiclients is inefficent
|
// TODO Error Checking as the apiclients is inefficent
|
||||||
|
@ -2,6 +2,8 @@
|
|||||||
const interactivemsghandler = require("./interactivemsghandler");
|
const interactivemsghandler = require("./interactivemsghandler");
|
||||||
const CONFIG = require("../config.json");
|
const CONFIG = require("../config.json");
|
||||||
const discordclientmanager = require("./discordclientmanager");
|
const discordclientmanager = require("./discordclientmanager");
|
||||||
|
const log = require("loglevel");
|
||||||
|
|
||||||
const {
|
const {
|
||||||
getAudioDispatcher,
|
getAudioDispatcher,
|
||||||
setAudioDispatcher
|
setAudioDispatcher
|
||||||
@ -29,6 +31,7 @@ function streamURLbuilder (itemID, bitrate) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function startPlaying (voiceconnection = discordclientmanager.getDiscordClient().user.client.voice.connections.first(), itemIDPlaylist = currentPlayingPlaylist, playlistIndex = currentPlayingPlaylistIndex, seekTo, disconnectOnFinish = _disconnectOnFinish) {
|
function startPlaying (voiceconnection = discordclientmanager.getDiscordClient().user.client.voice.connections.first(), itemIDPlaylist = currentPlayingPlaylist, playlistIndex = currentPlayingPlaylistIndex, seekTo, disconnectOnFinish = _disconnectOnFinish) {
|
||||||
|
log.debug("start playing ",playlistIndex, ". of list: ",itemIDPlaylist," in a voiceconnection?: ", voiceconnection=!undefined);
|
||||||
isPaused = false;
|
isPaused = false;
|
||||||
currentPlayingPlaylist = itemIDPlaylist;
|
currentPlayingPlaylist = itemIDPlaylist;
|
||||||
currentPlayingPlaylistIndex = playlistIndex;
|
currentPlayingPlaylistIndex = playlistIndex;
|
||||||
@ -74,6 +77,7 @@ function startPlaying (voiceconnection = discordclientmanager.getDiscordClient()
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function spawnPlayMessage (message) {
|
async function spawnPlayMessage (message) {
|
||||||
|
log.debug("spawned Play Message: ",message);
|
||||||
const itemIdDetails = await jellyfinClientManager.getJellyfinClient().getItem(jellyfinClientManager.getJellyfinClient().getCurrentUserId(), getItemId());
|
const itemIdDetails = await jellyfinClientManager.getJellyfinClient().getItem(jellyfinClientManager.getJellyfinClient().getCurrentUserId(), getItemId());
|
||||||
const imageURL = await jellyfinClientManager.getJellyfinClient().getImageUrl(itemIdDetails.AlbumId || getItemId(), { type: "Primary" });
|
const imageURL = await jellyfinClientManager.getJellyfinClient().getImageUrl(itemIdDetails.AlbumId || getItemId(), { type: "Primary" });
|
||||||
try {
|
try {
|
||||||
@ -107,6 +111,7 @@ async function updatePlayMessage () {
|
|||||||
* @param {Number} toSeek - where to seek in ticks
|
* @param {Number} toSeek - where to seek in ticks
|
||||||
*/
|
*/
|
||||||
function seek (toSeek = 0) {
|
function seek (toSeek = 0) {
|
||||||
|
log.debug("seek to: ", toSeek);
|
||||||
if (getAudioDispatcher()) {
|
if (getAudioDispatcher()) {
|
||||||
startPlaying(undefined, undefined, undefined, ticksToSeconds(toSeek), _disconnectOnFinish);
|
startPlaying(undefined, undefined, undefined, ticksToSeconds(toSeek), _disconnectOnFinish);
|
||||||
jellyfinClientManager.getJellyfinClient().reportPlaybackProgress(getProgressPayload());
|
jellyfinClientManager.getJellyfinClient().reportPlaybackProgress(getProgressPayload());
|
||||||
@ -119,10 +124,12 @@ function seek (toSeek = 0) {
|
|||||||
* @param {Array} itemID - array of itemIDs to be added
|
* @param {Array} itemID - array of itemIDs to be added
|
||||||
*/
|
*/
|
||||||
function addTracks (itemID) {
|
function addTracks (itemID) {
|
||||||
|
log.debug("added track: ",itemID);
|
||||||
currentPlayingPlaylist = currentPlayingPlaylist.concat(itemID);
|
currentPlayingPlaylist = currentPlayingPlaylist.concat(itemID);
|
||||||
}
|
}
|
||||||
|
|
||||||
function nextTrack () {
|
function nextTrack () {
|
||||||
|
log.debug("nextTrack");
|
||||||
if (!(currentPlayingPlaylist)) {
|
if (!(currentPlayingPlaylist)) {
|
||||||
throw Error("There is currently nothing playing");
|
throw Error("There is currently nothing playing");
|
||||||
} else if (currentPlayingPlaylistIndex + 1 >= currentPlayingPlaylist.length) {
|
} else if (currentPlayingPlaylistIndex + 1 >= currentPlayingPlaylist.length) {
|
||||||
@ -134,6 +141,7 @@ function nextTrack () {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function previousTrack () {
|
function previousTrack () {
|
||||||
|
log.debug("previousTrack");
|
||||||
if (ticksToSeconds(getPostitionTicks()) < 10) {
|
if (ticksToSeconds(getPostitionTicks()) < 10) {
|
||||||
if (!(currentPlayingPlaylist)) {
|
if (!(currentPlayingPlaylist)) {
|
||||||
throw Error("There is currently nothing playing");
|
throw Error("There is currently nothing playing");
|
||||||
@ -151,6 +159,7 @@ function previousTrack () {
|
|||||||
* @param {Object=} disconnectVoiceConnection - Optional The voice Connection do disconnect from
|
* @param {Object=} disconnectVoiceConnection - Optional The voice Connection do disconnect from
|
||||||
*/
|
*/
|
||||||
function stop (disconnectVoiceConnection, itemId = getItemId()) {
|
function stop (disconnectVoiceConnection, itemId = getItemId()) {
|
||||||
|
log.debug("stop playback and send following payload to the server: ",getStopPayload());
|
||||||
isPaused = true;
|
isPaused = true;
|
||||||
if (interactivemsghandler.hasMessage()) {
|
if (interactivemsghandler.hasMessage()) {
|
||||||
interactivemsghandler.destroy();
|
interactivemsghandler.destroy();
|
||||||
@ -170,12 +179,14 @@ function stop (disconnectVoiceConnection, itemId = getItemId()) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function pause () {
|
function pause () {
|
||||||
|
log.debug("pause");
|
||||||
isPaused = true;
|
isPaused = true;
|
||||||
jellyfinClientManager.getJellyfinClient().reportPlaybackProgress(getProgressPayload());
|
jellyfinClientManager.getJellyfinClient().reportPlaybackProgress(getProgressPayload());
|
||||||
getAudioDispatcher().pause(true);
|
getAudioDispatcher().pause(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
function resume () {
|
function resume () {
|
||||||
|
log.debug("resume");
|
||||||
isPaused = false;
|
isPaused = false;
|
||||||
jellyfinClientManager.getJellyfinClient().reportPlaybackProgress(getProgressPayload());
|
jellyfinClientManager.getJellyfinClient().reportPlaybackProgress(getProgressPayload());
|
||||||
getAudioDispatcher().resume();
|
getAudioDispatcher().resume();
|
||||||
|
Loading…
Reference in New Issue
Block a user