Screens #
Screens is a bot rendering random screenshots of a television show and posting it to an ATProto repository. Currently Bluesky is supported.
Simpsons Screens is a running instance of this.
How it works is by compiling a database of television episodes in a folder, extracting the number of frames in each episode, extracting the name of the episode, and adding them to a database. The primary program is run on a timer which:
- Selects a random episode frame from the database;
- Fetches subtitles from the subtitles track;
- Renders an image of the frame with subtitles overlayed; and finally,
- Creates ATProto repository records, which services like Bluesky automatically pick up.
Want a bot for a show? #
You can set this up yourself if you're a bit technical. Or I might be able to set one up if I like the show and think it'd be a good fit for a bot. Make an issue!
Caveats / "Known Issues" #
(I might not fix these.)
- When initially compiling the database, the season and episode numbers in the filename must be in the format of "S03E04".
- When initially compiling the database, the episode title is extracted from the filename after the season and episode numbers. This will likely require manual fixing on your part because filenames don't usually have characters such as quotation marks.
- When initially compiling the database, paths are recorded in the database for
each episode relative to the videos directory. This means you can move the
overlying video folder, but can't move individual video files within it. For
example, if your videos are in
~/Videos/Some Show, and season 3 episode 4 is located at~/Videos/Some Show/Season 03/Some Show - S03E04 - Episode Title.mkv, then the database will recordSeason 03/Some Show - S03E04 - Episode Title.mkv. If you move them or rename them, then you'll have to re-compile episodes or manually update the database.
Usage #
Prerequisites:
- Cargo
- You should have a folder of videos prepared. It's recommended to name them in the fashion of something similar to "Show Name - S03E04 - Episode Title.mkv".
Running it:
Step 1: Compile the episodes into a database:
RUST_LOG=debug DATABASE_PATH="./state.fjall" FIRST_SEASON=NUMBER_HERE \
FIRST_EPISODE=NUMBER_HERE LAST_SEASON=NUMBER_HERE LAST_EPISODE=NUMBER_HERE \
VIDEOS_PATH="/path/to/the/show" cargo run -p screens-compile-episodes
Step 2: Run the oneshot program:
A Flake is available if you're running NixOS. A sample configuration is in
examples/timer.nix, or you can run it manually via nix run .#screens with
the environment variables listed below.
Alternatively, you can run it via Cargo: cargo run --release -p screens.
Required and optional environment variables are defined in
screens/.example.env.
License #
MIT.