122

GitHub - minimaxir/magic-the-gifening: A Twitter bot which tweets Magic: the Gat...

 6 years ago
source link: https://github.com/minimaxir/magic-the-gifening
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Magic: The GIFening

A Twitter bot which tweets Magic: the Gathering cards with appropriate GIFs superimposed onto them. Made in Python using the GIPHY API and MoviePy.

You can see the bot in action at the Twitter account @MTGIFening.

Some highlights:

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).

Usage

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.

Then run 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 /sbin/my_init:

docker run --rm -d magic /sbin/my_init

Notes

  • 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).

Requirements

moviepy, ffmpeg, twython, Pillow

Maintainer/Creator

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.

License


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK