scripts/derpibooru: refactor