mstdn-now-playing
A simple bot built on Mastodon.py and the Now Playing in Texts VLC extension.
Prerequisites
Install the VLC extension and make sure it works.
Installation
- Set up a Python venv:
python3 -m venv ~/.venv/mstdn_now_playing - Install
Mastodon.pyin the venv:
~/.venv/mstdn_now_playing/bin/pip3 install Mastodon.py - Check out the repo:
git clone https://code.opensuse.org/fl4nn/mstdn-now-playing.git
cd mstdn-now-playing - Copy the Python script into the venv:
cp mstdn_now_playing.py ~/.venv/mstdn_now_playing/ - Copy the SystemD files into your users config directory and modify the
paths and environment settings to match your local setup:
mkdir -p ~/.config/systemd/user
cp systemd/* ~/.config/systemd/user/
vim ~/.config/systemd/user/{now_playing.*,bot_failure.*} - Enable the SystemD service:
systemctl --user enable --now now_playing.path
That's it, if everything is working you should see posts appearing on Fedi!
Adjusting post visibility
If you want to set the visibility of the posts to something other than your
accounts' default you can use the --visibility flag, see --help for
possible values.
Including links in the posts
It is possible to include links for example to the artist' Bandcamp in the post.
To use this function enable the extraction of the Track Description in the VLC
extension like this:
echo '{description}' > ~/.local/share/vlc/np_custom42.txt
The bot will then check if the description contains a URL and add everything
after http to the posts.
Warning: This is making assumptions how the Track Description is structured!
If there is any text after the URL it will be included in the post!
Customizing the included links
In addition to appending the link from the file metadata it is possible to
provide Artist URLs by placing a file called source.txt in the directory of
the file being played, for example the album folder. The content of this file
is then appended to the post instead of the URL found in the Description tag.
This is useful for example if your collection contains a lot of tracks ripped from physical media or with dead URLs in the tags, but you don't want to re-tag everything.
To use this function, enable extraction of the file path in the VLC extension
like this:
echo '{filepath}' > ~/.local/share/vlc/np_custom21.txt
Preventing certain album covers from being posted
If your collection contains album covers that would require CWs to be posted you can prevent them from being attached.
To use this functionality first ensure that file path extraction is enabled in
the VLC extension:
echo '{filepath}' > ~/.local/share/vlc/np_custom21.txt
Then simply create a file called .dnp in the folders of the albums whose cover
shouldn't be posted.