mirror of
https://github.com/informaticker/discord-jellyfin-bot.git
synced 2024-11-23 18:21:55 +01:00
added direct album and playlist play
This commit is contained in:
parent
e97c3f6a83
commit
2964b4a7e0
@ -34,7 +34,7 @@ function getMaxWidthString (string) {
|
||||
|
||||
class InterActivePlayMessage {
|
||||
// musicplayermessage
|
||||
// probably should have done events instead of.
|
||||
// probably should have done events instead of callbacks
|
||||
/**
|
||||
*
|
||||
* @param {Object} message
|
||||
@ -125,6 +125,8 @@ class InterActivePlayMessage {
|
||||
}
|
||||
|
||||
updateProgress (ticks) {
|
||||
if(typeof this.musicplayermessage !== "undefined" && typeof this.musicplayermessage.embeds[0] !== "undefined" && typeof this.musicplayermessage.embeds[0].fields[0] !== "undefined"){
|
||||
|
||||
this.musicplayermessage.embeds[0].fields[0] = {
|
||||
name: getProgressString(ticks / this.ticksLength),
|
||||
value: `${secondsToHms(ticksToSeconds(ticks))} / ${secondsToHms(ticksToSeconds(this.ticksLength))}`,
|
||||
@ -134,6 +136,7 @@ class InterActivePlayMessage {
|
||||
this.musicplayermessage.timestamp = new Date();
|
||||
this.musicplayermessage.edit(this.musicplayermessage.embeds[0]);
|
||||
}
|
||||
}
|
||||
|
||||
updateCurrentSongMessage (title, artist, imageURL, itemURL, ticksLength, playlistIndex, playlistLenth) {
|
||||
this.musicplayermessage.embeds[0].url = itemURL;
|
||||
|
@ -38,10 +38,12 @@ function hasMessage () {
|
||||
* @param {Function} callback function to retrieve current ticks
|
||||
*/
|
||||
function startUpate (callback) {
|
||||
if(typeof CONFIG["interactive-seek-bar-update-intervall"] === "number" && CONFIG["interactive-seek-bar-update-intervall"] > 0){
|
||||
updateInterval = setInterval(() => {
|
||||
iapm.updateProgress(callback());
|
||||
}, CONFIG["interactive-seek-bar-update-intervall"]);
|
||||
}
|
||||
}
|
||||
|
||||
function updateCurrentSongMessage (title, artist, imageURL, itemURL, ticksLength, playlistIndex, playlistLenth) {
|
||||
if (typeof iapm !== "undefined") {
|
||||
|
@ -47,13 +47,26 @@ function getRandomDiscordColor () {
|
||||
async function searchForItemID (searchString) {
|
||||
const response = await jellyfinClientManager.getJellyfinClient().getSearchHints({
|
||||
searchTerm: searchString,
|
||||
includeItemTypes: "Audio"
|
||||
includeItemTypes: "Audio,MusicAlbum,Playlist"
|
||||
});
|
||||
|
||||
if (response.TotalRecordCount < 1) {
|
||||
throw Error("Found no Song");
|
||||
throw Error("Found nothing");
|
||||
} else {
|
||||
return response.SearchHints[0].ItemId;
|
||||
console.log(response);
|
||||
switch(response.SearchHints[0].Type){
|
||||
case "Audio":
|
||||
return [response.SearchHints[0].ItemId];
|
||||
case "Playlist":
|
||||
case "MusicAlbum":
|
||||
console.log("Hey its a Music Album")
|
||||
let resp = await jellyfinClientManager.getJellyfinClient().getItems(jellyfinClientManager.getJellyfinClient().getCurrentUserId(),{sortBy:"SortName", sortOrder:"Ascending",parentId:response.SearchHints[0].ItemId});
|
||||
let itemArray = [];
|
||||
resp.Items.forEach(element => {
|
||||
itemArray.push(element.Id)
|
||||
});
|
||||
return itemArray;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -88,7 +101,7 @@ async function playThis (message) {
|
||||
// check if play command was used with itemID
|
||||
const regexresults = checkJellyfinItemIDRegex(argument);
|
||||
if (regexresults) {
|
||||
itemID = regexresults[0];
|
||||
itemID = regexresults;
|
||||
} else {
|
||||
try {
|
||||
itemID = await searchForItemID(argument);
|
||||
@ -101,7 +114,7 @@ async function playThis (message) {
|
||||
}
|
||||
|
||||
discordClient.user.client.voice.connections.forEach((element) => {
|
||||
playbackmanager.startPlaying(element, [itemID], 0, 0, isSummendByPlay);
|
||||
playbackmanager.startPlaying(element, itemID, 0, 0, isSummendByPlay);
|
||||
playbackmanager.spawnPlayMessage(message);
|
||||
});
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user