My friend Noe Rodriguez wanted to make a social experiment. We would take an old mexican movie and cut it second by second and then post it to Twitter. I found it interesting so we divided the workload, I made the bot while he got the frames. This is the resulting code and experiences. You can look at the experiment here @RisaNvacaciones. First I must say this is some pretty simple Twitter Bot. It is some basic code, but I think is a good starting point for more complex bots (or some interesting experiments). If you want to know how to cut a film second by second using ffmpeg go here.
First let’s get the basics installed. If you have a Mac you should already have python installed, if you have windows you can download python 2.7 for the code below. Personally I use ActivePython. It was the first one I found and works really well.
After that just run
pip install twython
Now everything we need in our computer for the code below to work is done. But now we need to get the keys from Twitter so we can post in our accounts.
After you have finished your APP registration go to the app page. It should look something like this
To get the keys you need for the bot go to the API keys tab and generate the needed keys (API keys and Access tokens). Then add your personal keys and tokens to the code above.
After that you can go and change the APP permissions depending on your needs. To do this go to the Permissions tab in your Twitter APP page. For us, we needed to make it able to post so we changed them to Read and Write.
So finally to start the bot you just have to run
python bot.py pasitotuntun.txt
Where pasitotuntun.txt is the name of our text file where we have the song for the flavor text and is completely optional.
And that should be all. If you have any question leave it in the comments.