-- Leo's gemini proxy

-- Connecting to lantashifiles.com:1965...

-- Connected

-- Sending request

-- Meta line: 20 text/gemini;lang=en-US

Viewing Mastodon Art from the Terminal


entry written by Lantashi


Scripting Mastodon


The Player and I (Lantashi) are continuing to use the Terminal as much as possible, and that includes using Mastodon. We use Toot (link below) to interact with Mastodon. Use "toot timeline" to read your timeline, or "toot tui" to bring up an ncurses interface.


If you see an image in your timeline, you can wget the image - "wget myurl/mypic.jpeg", and thus if you want to grab the images from your timeline, or from a tag search, you can grab them individually that way.


As a Sylvan adventurer, defending the Wood Sea from the evil about, I don't have time to individually wget images when I want them! I'd rather grab them all at once, and them "fim *" (link below) through them all, quickly!


So, how do I do this?


Well, the player put together a script for this. Let's say I want to first search on the tag "art", just one page worth, and then pull down all the images returned on that page. The script below is slightly simplified, as we do some image processing.


The script (downloadArt.sh) is in the "scripts/imageScripts" directory.


cd ~/scripts/imageScripts  # Make sure I am in the directory, good for cron jobs
toot timeline -1 --tag art > imageFiles.txt # Download 1 page of posts with the "art" tag, output to imagesFiles.txt
grep "\.jpeg" imageFiles.txt > images.txt # grab the lines with .jpeg, put it in images.txt
grep "\.jpg" imageFiles.txt >> images.txt # grab the lines with .jpg, put it in images.txt
grep "\.png" imageFiles.txt >> images.txt # grab the lines with .png, put it in images.txt


LINES=$(cat images.txt)  # Load list of images into array
for LINE in $LINES
do
    echo "$LINE"          # print the image link to Terminal
    LINE=${LINE%?}        # remove trailing ? on the line
    wget $LINE            # get the image!
done
echo "" > imageFiles.txt  # reset imageFiles.txt for next run
mv *.png art/newImages    # Move each image type to newImages
mv *.jpg art/newImages
mv *.jpeg art/newImages

You can use the script to grab different tags, maybe using a variable for the tag. You could also just grab your timeline (toot timeline -1). Up to you!


When you run the script, all your images will be in art/newImages (make sure the directories already exist).


Doing it this way, you can also create cron jobs to run the script at certain times of the day/week/month/etc. *This* script grabs images, but you could also search for tags, do different types of processing on the data returned (maybe using Python), and create summary reports of what the fediverse is talking about!


By using Mastodon in text mode, you can set up a lot of automated processing, scouring Mastodon for the information *you* are interested in, create cron jobs to do it at certain times of the day, and having it ready for a Sylvan (or Dwarf, Orc, Dragon, etc) ready to read/view!


Links


Lantashi Files, main section

Toot - TUI Mastdon Client

FIM (Fbi IMproved)

-- Response ended

-- Page fetched on Thu Jun 13 18:12:35 2024