You can see the bot in action at the Twitter account @MTGIFening.
In order to tweet on a regular schedule, the Dockerfile contains a cronjob which runs the script at the specified interval of time (currently set at 4 times a day/every 6 hours).
First, create a
secrets.py with the appropriate GIPHY and Twitter API Keys:
GIPHY_API_KEY='<FILL IN>' CONSUMER_KEY='<FILL IN>' CONSUMER_SECRET='<FILL IN>' ACCESS_KEY='<FILL IN>' ACCESS_SECRET='<FILL IN>'
The current list of cards used to generate images is derived from
cards.csv. If you want to update the list, use
get_cardlist.py and the
AllSets.json file from MTG JSON.
mtgifening.py and it should save and tweet a random GIF!
To run as a Twitter bot on the schedule, after you've added your
secrets.py file, build the Docker container. Then run the container in detached mode, starting it up using
docker run --rm -d magic /sbin/my_init
- The files generated are actually videos, not proper GIFs. Videos are created much faster, take less disk space, and on Twitter, functionally identical to GIFs (videos less than 6 seconds will also autoloop).
moviepy, ffmpeg, twython, Pillow
Max Woolf (@minimaxir)
Max's open-source projects are supported by his Patreon. If you found this project helpful, any monetary contributions to the Patreon are appreciated and will be put to good creative use.