Skip to content

Spirit55555/midnight-lyrics-bot

Repository files navigation

The Midnight Lyrics bot

This bot will post song lyrics from The Midnight on different social media platform.

The following platforms are currently supported:

  • Bluesky
  • Instagram
  • Threads

Special thanks to Carina for the design of the images. Based on Julia's original Node.js version.

Bluesky

Command line flag: -bluesky

Environment variables required:

  • BOTSKY_HANDLE
  • BOTSKY_APPKEY

Instagram

Command line flag: -instagram

Environment variables required:

  • INSTAGRAM_ACCESS_TOKEN
  • INSTAGRAM_IMAGES_URL

All images are saved in generated_images and a webserver serving these images is required.

The INSTAGRAM_IMAGES_URL needs to be a publicly accessible URL on the internet, so Instagram can fetch the images and post them.

If INSTAGRAM_IMAGES_URL is set to https://instagram.example.com then the image generated_images/album/song/sha1hash.jpg should be accessible on https://instagram.example.com/album/song/sha1hash.jpg

Threads

Command line flag: -threads

Environment variables required:

  • THREADS_ACCESS_TOKEN

Other command line flags

  • -refresh-tokens - Used to refresh and print new tokens for Threads and Instagram.
  • -generate-image - Used to generate the image for the selected (or random) lyric. Album and song number can be specified. Only useful for testing.
  • -generate-all-images - Used to generate all the images needed for the Instagram part of the bot. Only useful for testing, as the bot will generate images as needed.
  • -fake-midnight - Fake that the time is 00:00. Only useful for testing of the special post at midnight.

Specify album and song

If you want a specific album and (optionally) song selected when running the bot, it can take them as parameters like so:

midnight-lyrics-bot days_of_thunder 6

This will select a random lyric from the song Los Angeles from the Days of Thunder album.

Docker

Assuming you are in the source directory, the bot can be built and installed via Docker the following way:

docker buildx build -t midnight-lyrics-bot .

Running the bot

Running the bot requires the above mentioned environment variables set, which can be done via --env or (preferably) via --env-file:

docker run --env-file=socials.env midnight-lyrics-bot -bluesky

Example socials.env file for Bluesky:

[email protected]
BOTSKY_APPKEY=P@passw0rd

Instagram images

Running it for Instagram requires mounting of the generated_images directory to a directory where the images are served by a webserver on the host machine (see note above):

docker run --env-file=socials.env -v /opt/midnight-lyrics-bot/images:/generated_images midnight-lyrics-bot -instagram

Replace /opt/midnight-lyrics-bot/images with the path on the host machine.

Special post at midnight

In order to get the special post at midnight (00:00) at the expected time, the timezone has to be set to the the expected one.

The following line can be added to your socials.env file:

TZ=Europe/Copenhagen

A list of valid timezones can be found here.

About

This bot will post song lyrics from The Midnight on different social media platform.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •