No description
Find a file
2024-02-22 07:11:57 -06:00
.env.example Oh yeah that's it. Get his ass jsdom 2024-02-22 05:50:55 -06:00
.gitignore this shouldn't be committed lmao 2024-02-19 17:18:49 -06:00
index.js Allow disabling last song check, for testing purposes 2024-02-22 07:11:57 -06:00
LICENSE License software. 2024-02-21 14:51:22 -06:00
notification-client.js implement notification server and client 2024-02-19 18:26:31 -06:00
notification-server.js implement notification server and client 2024-02-19 18:26:31 -06:00
package.json Oh yeah that's it. Get his ass jsdom 2024-02-22 05:50:55 -06:00
README.md Seperate update and setup script !!! Fuck !!! 2024-02-22 06:14:49 -06:00
setup.sh Seperate update and setup script !!! Fuck !!! 2024-02-22 06:14:49 -06:00
update.sh Seperate update and setup script !!! Fuck !!! 2024-02-22 06:14:49 -06:00

LastFMDownloader

Downloader from Last.fm scrobble to MP3 file. Uploads to Nextcloud because it can.

Setup

Installation & running

To install LastFMDownloader, you need to run git clone in the path you desire. The program does not require root privileges, so your user's home folder will suffice.

After you have cloned the application, run ./setup.sh in order to install the required npm packages. Now, LastFMDownloader can be set up.

.env file

Here's .env.example in its entirety. We will go through each section, filling out each variable as we go.

# Last.fm

LASTFM_INSTANCE= # ws.audioscrobbler.com

LASTFM_USERNAME= # meowcatheorange
LASTFM_API_KEY= # cccccccccccccccccc...

# Cobalt

COBALT_INSTANCE= # co.wuk.sh

# Nextcloud

NEXTCLOUD_INSTANCE= # next.abtmtr.link

NEXTCLOUD_USERNAME= # meowcatheorange
NEXTCLOUD_PASSWORD= # ccccc-ccccc-ccccc-ccccc-ccccc

NEXTCLOUD_FOLDER= # /Music/LastFMDownloader/

# Notifications

NOTIFICATION_SERVER_INSTANCE= # localhost
NOTIFICATION_SERVER_PORT= # 80
NOTIFICATION_SERVER_PASSWORD= # password123

NOTIFICATION_CLIENT_INSTANCE= # secret.abtmtr.link
NOTIFICATION_CLIENT_PORT= # 80
NOTIFICATION_CLIENT_PROTOCOL= # https

LASTFM_INSTANCE

You can simply replace the comment with ws.audioscrobbler.com.

LASTFM_USERNAME

If you have a Last.fm account (you really should), this is where you will put the username of your account so it knows who to get scrobbles from.

LASTFM_API_KEY

Go to https://www.last.fm/api, and click on Get an API account under Getting Started. Fill out the form. All you need is a contact email and an application name.

After that, you will be sent to a page with your new API account info on it. Replace the comment with the API key.

COBALT_INSTANCE

If you run an instance of the Cobalt API (the tool that LastFMDownloader uses to download YouTube videos), you can input its URL here. Otherwise, replace the comment with an instance of your choosing, or co.wuk.sh.

NEXTCLOUD_INSTANCE

If you use Nextcloud (or any other WebDAV-compatible software), you can put its domain here.

NEXTCLOUD_USERNAME

The username of your Nextcloud / WebDAV account.

NEXTCLOUD_PASSWORD

The HTTP Basic password of your Nextcloud / WebDAV account. If you use Nextcloud specifically, you most likely have access to App Passwords within [profile picture] > Personal settings > Security > Devices & sessions. Make sure to use these! Put the App Password or account password here.

NEXTCLOUD_FOLDER

The folder that LastFMDownloader will use to store its music, if you're categorically inclined. Otherwise, you can use /, /LastFMDownloader/, or /Music/LastFMDownloader/.

Run on Linux

This setup guide will mainly focus on Linux.

To run LastFMDownloader properly, you can set it up on a cronjob.

Install the crontab command if you haven't already, then run crontab -e.

Edit the crontab to contain this line (make sure to change it accordingly):

*/1 * * * * cd <LastFMDownloader path> && <Path to Node.js binary ("which node")> index.js

This will run LastFMDownloader's main application every single minute.

Delivering notifications

If you want to know when LastFMDownloader is downloading a song, you can run the notification daemon on both your server computer and client computer.

.env file

Here's the variables we left out when setting up .env.example for the first time. We're going to fill them out right now.

# Notifications

NOTIFICATION_SERVER_INSTANCE= # localhost
NOTIFICATION_SERVER_PORT= # 80
NOTIFICATION_SERVER_PASSWORD= # password123

NOTIFICATION_CLIENT_INSTANCE= # secret.abtmtr.link
NOTIFICATION_CLIENT_PORT= # 80
NOTIFICATION_CLIENT_PROTOCOL= # https
NOTIFICATION_SERVER_INSTANCE

Mostly for testing, but if you're running your notification server seperate from LastFMDownloader (you shouldn't be, in production), fill this with your server's domain. Otherwise, use localhost.

NOTIFICATION_SERVER_PORT

This will be the port that your notification server runs on. Set this to any port but 80 or 443 - you will need to use a reverse proxy like nginx or Apache in order to properly run this application.

NOTIFICATION_SERVER_PASSWORD

This will be the password that LastFMDownloader will use to communicate messages to the notification server. Set it to something secure, or random. You won't have to type this in, so it can be as long as you want.

Systemd

Run your text editor of choice with the file /etc/systemd/system/lfmdns.service.

Edit the file to this block of configuration code (make sure to change it accordingly):

[Unit]
Description=LastFMDownloader Notification Server

[Service]
ExecStart=<Path to Node.js binary ("which node")> <LastFMDownloader path>/notification-server.js
User=<user>
RestartSec=1
Restart=always
Environment=PATH=<LastFMDownloader path>
WorkingDirectory=<LastFMDownloader path>

[Install]
WantedBy=multi-user.target

Save the file, then run this command as root:

systemctl daemon-reload

And then, once again as root:

systemctl enable lfmdns --now

The notification server should now be running. If you run

systemctl status lfmdns

you should be able to see the message "A client connected!" pop up on the minute, every minute. This is LastFMDownloader connecting to the notification server.

Recieving notifications

To recieve LastFMDownloader notifications, you have to install LastFMDownloader somewhere on your host computer. Feel free to follow the directions in Installation & running.

.env file

Here's the variables we left out when setting up .env.example in Delivering notifications. We're going to fill them out right now.

NOTIFICATION_CLIENT_INSTANCE= # secret.abtmtr.link
NOTIFICATION_CLIENT_PORT= # 80
NOTIFICATION_CLIENT_PROTOCOL= # https
NOTIFICATION_CLIENT_INSTANCE

The domain that your notification server is running on. This can either be localhost, [ip address of the machine running LastFMDownloader], or [web domain].

NOTIFICATION_CLIENT_PORT

The port that your notification server occupies. Can either be 80, 443 or the same as what you set NOTIFICATION_SERVER_PORT to on your server.

NOTIFICATION_CLIENT_PROTOCOL

The protocol that your notification server uses. If NOTIFICATION_CLIENT_PORT is 443, this has to be https. If it is 80, it can be either https or http. Otherwise, if it is neither, it has to be http.

Script

Then, all you need to do is create a script on your computer that will run for as long as you are logged in.

On Linux, the script (lfmdnc.sh) should look like this:

#!/bin/bash
while true
do
  cd <LastFMDownloader client path> && node notification-client.js
done

Running this script should notify you when you are connected to the server. If it sends a notification saying so, congratulations! You have successfully set up LastFMDownloader.