mirror of
https://github.com/pseudbot/pseudbot.git
synced 2026-05-26 14:05:07 +00:00
95c8726cbb
On startup, the code now initializes MEDIA with suitable media files found in the `media` directory that satisfy Twitter's media file requirements. The `filetype` Python module has been added as a dependency to ensure that files in `media` are what they claim to be. In the bot class I added a new _parse_mention method, broke up the pasta chain builder method, and added a new recursive _tweet_media method. The _parse_mention method had to have some `stupid_emoji` hackery thanks to the way the 🖼 emoji gets encoded in some tweets. A new fetch-media script has been added along with a new util function named `download_tweet_media` See media/README.md for more information on how to use the newly-added multimedia superpowers.
61 lines
2.8 KiB
Python
Executable File
61 lines
2.8 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
import argparse
|
|
import json as j
|
|
from pseudbot.util import download_tweet_media
|
|
from sys import argv as ARGV
|
|
import typing
|
|
|
|
|
|
def parse_args(args: [str], name: str):
|
|
parser = argparse.ArgumentParser(prog=name)
|
|
|
|
parser.add_argument(
|
|
"json_dump",
|
|
type=argparse.FileType("r"),
|
|
help="JSON File containing a Twitter info dictionary dump",
|
|
)
|
|
|
|
return parser.parse_args(args=args)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
prog_name = ARGV.pop(0)
|
|
print(
|
|
""
|
|
+ " ,▄▄▄▄▄,\n"
|
|
+ " ▄▄ ▄███████████▄▄▄▄█▀\n"
|
|
+ " ▐███▌ ,█████████████████▄▄▄\n"
|
|
+ " ▐██████▄ ███████████████████▀\n"
|
|
+ " ██████████▌▄, █████████████████\n"
|
|
+ " ▓█████████████████████████████████\n"
|
|
+ " ▐██████████████████████████████████▓\n"
|
|
+ " ██████████████████████████████████\n"
|
|
+ " ▀███████████████████████████████▌\n"
|
|
+ " ,▐▓███████████████████████████▌\n"
|
|
+ " ████████████████████████████▀\n"
|
|
+ " ╙█████████████████████████`\n"
|
|
+ " `▀▓██████████████████▀\n"
|
|
+ " ,▄▓██████████████████▓└\n"
|
|
+ "`▀██████████████████████▀└\n"
|
|
+ " ╙▀▌▓████████▓▌▀└\n"
|
|
+ " _ _\n"
|
|
+ " _ __ ___ ___ __| (_) __ _\n"
|
|
+ " | '_ ` _ \ / _ \/ _` | |/ _` |\n"
|
|
+ " | | | | | | __/ (_| | | (_| |\n"
|
|
+ " |_| |_| |_|\___|\__,_|_|\__,_|\n"
|
|
+ " _\n"
|
|
+ " __| |_ _ _ __ ___ _ __ ___ _ __\n"
|
|
+ " / _` | | | | '_ ` _ \| '_ \ / _ \ '__|\n"
|
|
+ "| (_| | |_| | | | | | | |_) | __/ |\n"
|
|
+ " \__,_|\__,_|_| |_| |_| .__/ \___|_|\n"
|
|
+ " |_|\n"
|
|
)
|
|
|
|
opts = parse_args(args=ARGV, name=prog_name)
|
|
|
|
tweets = j.loads(opts.json_dump.read())
|
|
for tweet in tweets:
|
|
download_tweet_media(tweet)
|
|
|
|
opts.json_dump.close()
|