mirror of
https://github.com/informaticker/discord-jellyfin-bot.git
synced 2024-11-23 18:21:55 +01:00
fix lint
This commit is contained in:
parent
242ae2ffff
commit
212b9f658b
@ -15,6 +15,7 @@
|
|||||||
"quotes": ["error", "double"],
|
"quotes": ["error", "double"],
|
||||||
"indent": ["error", "tab"],
|
"indent": ["error", "tab"],
|
||||||
"no-unused-vars": ["error"],
|
"no-unused-vars": ["error"],
|
||||||
"no-tabs":["error",{"allowIndentationTabs":true}]
|
"no-tabs":["error",{"allowIndentationTabs":true}],
|
||||||
|
"no-console":["warn",{"allow":["error"]}]
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -10,5 +10,5 @@ if (!configfile["jellyfin-password"]) { configfile["jellyfin-password"] = proces
|
|||||||
if (!configfile["jellyfin-app-name"]) { configfile["jellyfin-app-name"] = process.env.JELLYFIN_APP_NAME; }
|
if (!configfile["jellyfin-app-name"]) { configfile["jellyfin-app-name"] = process.env.JELLYFIN_APP_NAME; }
|
||||||
|
|
||||||
fs.writeFile(filename, JSON.stringify(configfile, null, 1), (err) => {
|
fs.writeFile(filename, JSON.stringify(configfile, null, 1), (err) => {
|
||||||
if (err) return console.log(err);
|
if (err) return console.error(err);
|
||||||
});
|
});
|
||||||
|
@ -15,10 +15,6 @@ jellyfinClientManager.getJellyfinClient().authenticateUserByName(CONFIG["jellyfi
|
|||||||
jellyfinClientManager.getJellyfinClient().setAuthenticationInfo(response.AccessToken, response.SessionInfo.UserId);
|
jellyfinClientManager.getJellyfinClient().setAuthenticationInfo(response.AccessToken, response.SessionInfo.UserId);
|
||||||
});
|
});
|
||||||
|
|
||||||
discordClient.on("ready", () => {
|
|
||||||
console.log("connected to Discord");
|
|
||||||
});
|
|
||||||
|
|
||||||
discordClient.on("message", message => {
|
discordClient.on("message", message => {
|
||||||
handleChannelMessage(message);
|
handleChannelMessage(message);
|
||||||
});
|
});
|
||||||
|
@ -25,15 +25,14 @@ function startPlaying (voiceconnection = discordclientmanager.getDiscordClient()
|
|||||||
isPaused = false;
|
isPaused = false;
|
||||||
currentPlayingItemId = itemID;
|
currentPlayingItemId = itemID;
|
||||||
_disconnectOnFinish = disconnectOnFinish;
|
_disconnectOnFinish = disconnectOnFinish;
|
||||||
_seek=seekTo*1000;
|
_seek = seekTo * 1000;
|
||||||
async function playasync () {
|
async function playasync () {
|
||||||
const url = streamURLbuilder(itemID, voiceconnection.channel.bitrate);
|
const url = streamURLbuilder(itemID, voiceconnection.channel.bitrate);
|
||||||
setAudioDispatcher(voiceconnection.play(url ,{seek: seekTo}));
|
setAudioDispatcher(voiceconnection.play(url, { seek: seekTo }));
|
||||||
console.log(seekTo, ticksToSeconds(getPostitionTicks()));
|
if (seekTo) {
|
||||||
if(seekTo){
|
|
||||||
jellyfinClientManager.getJellyfinClient().reportPlaybackProgress(getProgressPayload());
|
jellyfinClientManager.getJellyfinClient().reportPlaybackProgress(getProgressPayload());
|
||||||
}else{
|
} else {
|
||||||
jellyfinClientManager.getJellyfinClient().reportPlaybackStart({ userID: `${jellyfinClientManager.getJellyfinClient().getCurrentUserId()}`, itemID: `${itemID}`, canSeek: true ,playSessionId: getPlaySessionId(), playMethod:getPlayMethod()});
|
jellyfinClientManager.getJellyfinClient().reportPlaybackStart({ userID: `${jellyfinClientManager.getJellyfinClient().getCurrentUserId()}`, itemID: `${itemID}`, canSeek: true, playSessionId: getPlaySessionId(), playMethod: getPlayMethod() });
|
||||||
}
|
}
|
||||||
|
|
||||||
getAudioDispatcher().on("finish", () => {
|
getAudioDispatcher().on("finish", () => {
|
||||||
@ -44,14 +43,14 @@ function startPlaying (voiceconnection = discordclientmanager.getDiscordClient()
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
playasync().catch((rsn) => { console.log(rsn); });
|
playasync().catch((rsn) => { console.error(rsn); });
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* @param {Number} toSeek - where to seek in ticks
|
* @param {Number} toSeek - where to seek in ticks
|
||||||
*/
|
*/
|
||||||
function seek(toSeek = 0){
|
function seek (toSeek = 0) {
|
||||||
if(getAudioDispatcher()){
|
if (getAudioDispatcher()) {
|
||||||
startPlaying(undefined,undefined,ticksToSeconds(toSeek),_disconnectOnFinish);
|
startPlaying(undefined, undefined, ticksToSeconds(toSeek), _disconnectOnFinish);
|
||||||
jellyfinClientManager.getJellyfinClient().reportPlaybackProgress(getProgressPayload());
|
jellyfinClientManager.getJellyfinClient().reportPlaybackProgress(getProgressPayload());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -64,14 +63,13 @@ function stop (disconnectVoiceConnection) {
|
|||||||
if (disconnectVoiceConnection) {
|
if (disconnectVoiceConnection) {
|
||||||
disconnectVoiceConnection.disconnect();
|
disconnectVoiceConnection.disconnect();
|
||||||
}
|
}
|
||||||
jellyfinClientManager.getJellyfinClient().reportPlaybackStopped({ userId: jellyfinClientManager.getJellyfinClient().getCurrentUserId(), itemId: currentPlayingItemId ,playSessionId: getPlaySessionId()});
|
jellyfinClientManager.getJellyfinClient().reportPlaybackStopped({ userId: jellyfinClientManager.getJellyfinClient().getCurrentUserId(), itemId: currentPlayingItemId, playSessionId: getPlaySessionId() });
|
||||||
if (getAudioDispatcher()) { getAudioDispatcher().destroy(); }
|
if (getAudioDispatcher()) { getAudioDispatcher().destroy(); }
|
||||||
setAudioDispatcher(undefined);
|
setAudioDispatcher(undefined);
|
||||||
clearInterval(progressInterval);
|
clearInterval(progressInterval);
|
||||||
}
|
}
|
||||||
function pause () {
|
function pause () {
|
||||||
isPaused = true;
|
isPaused = true;
|
||||||
console.log("here paused is changed", isPaused);
|
|
||||||
jellyfinClientManager.getJellyfinClient().reportPlaybackProgress(getProgressPayload());
|
jellyfinClientManager.getJellyfinClient().reportPlaybackProgress(getProgressPayload());
|
||||||
getAudioDispatcher().pause(true);
|
getAudioDispatcher().pause(true);
|
||||||
}
|
}
|
||||||
@ -86,7 +84,7 @@ function playPause () {
|
|||||||
|
|
||||||
function getPostitionTicks () {
|
function getPostitionTicks () {
|
||||||
// this is very sketchy but i dont know how else to do it
|
// this is very sketchy but i dont know how else to do it
|
||||||
return (_seek+getAudioDispatcher().streamTime - getAudioDispatcher().pausedTime) * 10000;
|
return (_seek + getAudioDispatcher().streamTime - getAudioDispatcher().pausedTime) * 10000;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getPlayMethod () {
|
function getPlayMethod () {
|
||||||
|
@ -3,8 +3,8 @@ function checkJellyfinItemIDRegex (strgintomatch) {
|
|||||||
return regexresult;
|
return regexresult;
|
||||||
}
|
}
|
||||||
|
|
||||||
function ticksToSeconds (ticks){
|
function ticksToSeconds (ticks) {
|
||||||
return ticks/10000000;
|
return ticks / 10000000;
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
const jellyfinClientManager = require("./jellyfinclientmanager");
|
const jellyfinClientManager = require("./jellyfinclientmanager");
|
||||||
const discordclientmanager = require("./discordclientmanager");
|
|
||||||
const playbackmanager = require("./playbackmanager");
|
const playbackmanager = require("./playbackmanager");
|
||||||
|
|
||||||
function openSocket () {
|
function openSocket () {
|
||||||
@ -11,21 +10,10 @@ function openSocket () {
|
|||||||
SupportedCommands: "Play,Playstate"
|
SupportedCommands: "Play,Playstate"
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
jellyfinClientManager.getJellyfinClient().ajax({
|
|
||||||
|
|
||||||
type: 'POST',
|
|
||||||
|
|
||||||
url: jellyfinClientManager.getJellyfinClient().getUrl('system/info/public'),
|
|
||||||
|
|
||||||
data: JSON.stringify({}),
|
|
||||||
|
|
||||||
contentType: 'application/json'
|
|
||||||
|
|
||||||
}).then((resp)=>{console.log(resp)})
|
|
||||||
jellyfinClientManager.getJellyfinEvents().on(jellyfinClientManager.getJellyfinClient(), "message", (type, data) => {
|
jellyfinClientManager.getJellyfinEvents().on(jellyfinClientManager.getJellyfinClient(), "message", (type, data) => {
|
||||||
if (data.MessageType === "Play") {
|
if (data.MessageType === "Play") {
|
||||||
if (data.Data.PlayCommand === "PlayNow") {
|
if (data.Data.PlayCommand === "PlayNow") {
|
||||||
playbackmanager.startPlaying(undefined, data.Data.ItemIds[data.Data.StartIndex || 0],0, false);
|
playbackmanager.startPlaying(undefined, data.Data.ItemIds[data.Data.StartIndex || 0], 0, false);
|
||||||
}
|
}
|
||||||
} else if (data.MessageType === "Playstate") {
|
} else if (data.MessageType === "Playstate") {
|
||||||
if (data.Data.Command === "PlayPause") {
|
if (data.Data.Command === "PlayPause") {
|
||||||
|
Loading…
Reference in New Issue
Block a user