Create README and appropriate files

This commit is contained in:
MeowcaTheoRange 2024-02-21 15:57:09 -06:00
parent 6ac45c52c0
commit 7f08db6aa8
3 changed files with 207 additions and 1 deletions

View file

@ -4,7 +4,6 @@ LASTFM_INSTANCE= # ws.audioscrobbler.com
LASTFM_USERNAME= # meowcatheorange
LASTFM_API_KEY= # cccccccccccccccccc...
LASTFM_SHARED_SECRET= # cccccccccccccccccc...
# Cobalt

203
README.md Normal file
View file

@ -0,0 +1,203 @@
# 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 `./update.sh` in order to pull the latest version and 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.
```conf
# 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_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.
```conf
# Notifications
NOTIFICATION_SERVER_PORT= # 80
NOTIFICATION_SERVER_PASSWORD= # password123
NOTIFICATION_CLIENT_INSTANCE= # secret.abtmtr.link
NOTIFICATION_CLIENT_PORT= # 80
NOTIFICATION_CLIENT_PROTOCOL= # https
```
##### 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):
```conf
[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](#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.
```conf
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.

4
update.sh Executable file
View file

@ -0,0 +1,4 @@
#!/bin/bash
touch last_song.txt
mv .env.example .env
git pull && npm i