A Python bot to post every frame of a TV show in order to Twitter with a set interval between tweets.
I would like to thank Every SpongeBob Frame In Order for the inspiration.
- Computer that will run 24/7 - I run this bot through Linux and even though I briefly tested it on Windows, I can't guarantee long-term Windows compatibility
- Frames from your chosen TV show in
jpg
format - I recommend ffmpeg to extract frames from episodes tweepy
installed with pip -pip install -U tweepy
discord-webhook
installed with pip -pip install -U discord-webhook
- Twitter account signed up on the Twitter Developer Portal with generated API key and secret, access token and secret with write permissions
- Discord account with admin privileges to a server to create a webhook to receive bot error notifications
- Download
main.py
ormain_four_frames_per_tweet.py
andallEPs.txt
from this repo. - Create a folder to store both of these files, this folder will then store the
frames
folder,log.txt
andconfig.json
after they have been generated. - Run
main.py
once to generateconfig.json
and theframes
folder, theframes
folder will be used to store frames from your chosen TV show. If you want to use a different name for the frames folder, you can edit theframe_dir
variable on line 22 inmain.py
.
Your bot folder should now look like this:
- Edit
allEPs.txt
so it contains each season and episode number based on the frame folder structure on each line just like the example inside the file. Ensure you follow the example and enter an additional line at the end of the file with any text inside it, in the example I wroteEnd
, this is needed so the bot picks up the actual last episode of your show. For example, for my instance of the bot I post frames of the show South Park which currently has 319 episodes and a movie that my bot will also post so my localallEPs.txt
contains 321 lines, one more than the number of episodes including the movie. This method of storing the season and episode names means you don't have to have every future episode stored even though the bot may be months away from needing it and allows you to add episode frame filled folders while the bot is running and can delete episode folders after the bot has posted them, this is useful for longer shows where you don't want to store hundreds of episodes as frames at a time. - Edit
config.json
with your generated Twitter API key and secret, access token and secret ensuring write permissions were enabled for the access token and secret. Also enter your Discord webhook URL, Discord user ID, TV show name and delay between tweets in seconds. - Extract frames from your chosen TV show with ffmpeg and store them inside your
frames
folder, each season with a dedicated folder and each episode with a dedicated folder inside its associated season folder, in your ffmpeg command ensure the file output isframe-%d.jpg
, this will extract frames in order named asframe-1.jpg
,frame-2.jpg
, etc. After extraction, your frames should be stored like this exampleframes/Season 1/Episode 1/frame-1.jpg
. - Finally you can run
main.py
and the bot should start posting frames to your Twitter!
- Download
EPnames.txt
from this repo into the bot's folder. - Edit
EPnames.txt
so it contains each episode's name on the same line number that episode appears inallEPs.txt
. Just likeallEPs.txt
ensure there is an additional line at the end of the file with any text inside it. - Edit
config.json
by changingenableEPname
from0
to1
.
With the recent Twitter API changes, I've uploaded a new main_four_frames_per_tweet.py
script which uploads four frames in one tweet at a default time interval of every 30 minutes instead of the original script's one frame per tweet at a default time interval of every 3 minutes. While this is not a perfect solution, this should just stay inside the 1500 tweets per month limit for a free API account so I wouldn't recommend changing this in the config. I will keep both versions of the script on this repo for both free and paid API users to use.
Just to reiterate: Free API Users Use main_four_frames_per_tweet.py
| Paid API Users Use main.py
Please contact me through the @SPFramesInOrder Twitter DM's if you are using this script for your Twitter bot, I would love to add your account to this list!
Show: South Park
Twitter: @SPFramesInOrder