Skip to content
This repository has been archived by the owner on Dec 21, 2023. It is now read-only.
/ hot-this-week Public archive

๐Ÿ”ฅ Posts last.fm details to a Mastodon account.

License

Notifications You must be signed in to change notification settings

soup-bowl/hot-this-week

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿ”ฅ soup-bowl's Hot This Week

CodeFactor

A view of a Mastodon post showing a 5-picture collage, 1 larger image on the left and 4 small images in a grid orientation

An experimental bot that posts a rundown of your musical week on Mastodon and/or Twitter.

โš ๏ธ The Twitter integration will be phased out as Twitter has taken an agressive stance against automatic tweeting. My development account has been suspended, so I'm no longer able to develop the integration. Mastodon will be the sole focus going forward.

๐Ÿค” What does this do?

This clever bot does the following:

  • Phones the last.fm API ๐Ÿ“ฒ, exchanges pleasantries, asks how their cat is doing ๐Ÿˆ...
  • Oh yeah, "can you tell me what has listened to this week?" ๐ŸŽถ
  • API kindly hands over the info (or gives us a whack of the handbag if we have no API key).
  • We sneakily scrape the last.fm website for the artist pictures ๐Ÿคซ (better solutions welcome).
  • We do some arts and crafts wizardary ๐Ÿช„ to formulate a collage picture.
  • Lastly, the app phones up Mastodon ๐Ÿ“ž, asks how their turtle is hanging ๐Ÿข, and posts the info and picture.

โญ Collage is made using the power of Python using Pillow for image manipulation, Twython/Mastodon and urllib3 for API communication, and lxml for scraping the internet.

๐Ÿš€ Set-up

There's no official service or method of usage yet! Watch this space ๐Ÿ‘€

๐Ÿ‹ Docker/Podman

docker run -v ${PWD}/config.json:/opt/app/config.json soupbowl/hot-this-week:latest

The command above uses the Dockerhub image. You can swap soupbowl out for ghcr.io/soup-bowl for GitHub container registry.

Append -h right at the end to see usage instructions. Change 'latest' for 'edge' to get the latest development version (possibly unstable).

Natively

The project depends on having Python 3 installed, and don't forget to run pip3 install -r requirements.txt to grab the project dependencies.

See the configuration example to see how to setup the tool. The following configurations are required for this to work in your own environment:

  • last.fm: global LASTFM_KEY, LASTFM_SECRET, and per-user LASTFM_SCAN_USER_NAME.
  • Mastodon: global MASTODON_URL, MASTODON_KEY and MASTODON_SECRET.
    • Easily register an application in Preferences, then Development.
    • Permissions needed are write:media and write:statuses.
  • Twitter: global TWITTER_CONSUMER_KEY, TWITTER_CONSUMER_SECRET, and per-user TWITTER_ACCESS_TOKEN, and TWITTER_ACCESS_TOKEN.

With everything set, you can just run python3 -m htw from CLI, and all the magic should happen. You can see the optional arguments by running python3 -m htw --help.

This uses pytest for Unit Testing, and pylint for linting.