Remove manual scrobbling (lmao)
This commit is contained in:
parent
eb9263972e
commit
3104f0932f
1 changed files with 15 additions and 39 deletions
54
index.js
54
index.js
|
@ -8,7 +8,6 @@ const { createClient } = require("fix-esm").require("webdav");
|
||||||
const path = require("path");
|
const path = require("path");
|
||||||
const { readFileSync, writeFileSync } = require("fs");
|
const { readFileSync, writeFileSync } = require("fs");
|
||||||
const io = require('socket.io-client');
|
const io = require('socket.io-client');
|
||||||
const { program } = require('commander');
|
|
||||||
const NodeID3 = require('node-id3');
|
const NodeID3 = require('node-id3');
|
||||||
|
|
||||||
function pathGenerator({ url, name, channelName }) {
|
function pathGenerator({ url, name, channelName }) {
|
||||||
|
@ -27,33 +26,21 @@ function writeLastSong({ name, channelName }) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
async function getVideo({ msName, msArtist }) {
|
async function getVideo() {
|
||||||
let trackData;
|
const trackData = await fetch(
|
||||||
let tags;
|
`https://${process.env.LASTFM_INSTANCE}/2.0/?method=user.getrecenttracks&user=${process.env.LASTFM_USERNAME}&api_key=${process.env.LASTFM_API_KEY}&format=json&limit=1&extended=1`
|
||||||
|
).then(x => x.json()).then(data => data.recenttracks.track[0]);
|
||||||
|
|
||||||
if (msName != null && msArtist != null) {
|
const tags = {
|
||||||
trackData = {
|
title: trackData.name,
|
||||||
name: msName,
|
artist: trackData.artist.name,
|
||||||
artist: {
|
album: trackData.album["#text"],
|
||||||
name: msArtist
|
APIC: "./cover.png",
|
||||||
}
|
userDefinedUrl: [{
|
||||||
};
|
description: "Last.FM page",
|
||||||
} else {
|
url: trackData.url
|
||||||
trackData = await fetch(
|
}]
|
||||||
`https://${process.env.LASTFM_INSTANCE}/2.0/?method=user.getrecenttracks&user=${process.env.LASTFM_USERNAME}&api_key=${process.env.LASTFM_API_KEY}&format=json&limit=1&extended=1`
|
};
|
||||||
).then(x => x.json()).then(data => data.recenttracks.track[0]);
|
|
||||||
|
|
||||||
tags = {
|
|
||||||
title: trackData.name,
|
|
||||||
artist: trackData.artist.name,
|
|
||||||
album: trackData.album["#text"],
|
|
||||||
APIC: "./cover.png",
|
|
||||||
userDefinedUrl: [{
|
|
||||||
description: "Last.FM page",
|
|
||||||
url: trackData.url
|
|
||||||
}]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (checkLastSong({
|
if (checkLastSong({
|
||||||
name: trackData.name,
|
name: trackData.name,
|
||||||
|
@ -192,24 +179,13 @@ async function uploadToNextcloud({ fileStream, url, name, channelName, tags, alb
|
||||||
}
|
}
|
||||||
|
|
||||||
async function main() {
|
async function main() {
|
||||||
program
|
|
||||||
.option('-s, --song <value>', 'Look up a song', null)
|
|
||||||
.option('-a, --artist <value>', 'Look up an artist', null);
|
|
||||||
|
|
||||||
program.parse(process.argv);
|
|
||||||
|
|
||||||
const options = program.opts();
|
|
||||||
|
|
||||||
const socket = io.connect(`http://localhost:${process.env.NOTIFICATION_SERVER_PORT}`, {reconnect: true});
|
const socket = io.connect(`http://localhost:${process.env.NOTIFICATION_SERVER_PORT}`, {reconnect: true});
|
||||||
|
|
||||||
socket.on('connect', function (s) {
|
socket.on('connect', function (s) {
|
||||||
console.log('Successfully connected to notification server');
|
console.log('Successfully connected to notification server');
|
||||||
});
|
});
|
||||||
|
|
||||||
const video = await getVideo({
|
const video = await getVideo();
|
||||||
msName: options.song,
|
|
||||||
msArtist: options.artist
|
|
||||||
});
|
|
||||||
|
|
||||||
if (video == null) return dismantle(socket);
|
if (video == null) return dismantle(socket);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue