diff --git a/.gitignore b/.gitignore index b6e4761..6347765 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,10 @@ +#secrets +.env + +#logs etc +tweets.txt +tweets.log + # Byte-compiled / optimized / DLL files __pycache__/ *.py[cod] @@ -20,110 +27,8 @@ parts/ sdist/ var/ wheels/ -pip-wheel-metadata/ share/python-wheels/ *.egg-info/ .installed.cfg *.egg MANIFEST - -# PyInstaller -# Usually these files are written by a python script from a template -# before PyInstaller builds the exe, so as to inject date/other infos into it. -*.manifest -*.spec - -# Installer logs -pip-log.txt -pip-delete-this-directory.txt - -# Unit test / coverage reports -htmlcov/ -.tox/ -.nox/ -.coverage -.coverage.* -.cache -nosetests.xml -coverage.xml -*.cover -*.py,cover -.hypothesis/ -.pytest_cache/ - -# Translations -*.mo -*.pot - -# Django stuff: -*.log -local_settings.py -db.sqlite3 -db.sqlite3-journal - -# Flask stuff: -instance/ -.webassets-cache - -# Scrapy stuff: -.scrapy - -# Sphinx documentation -docs/_build/ - -# PyBuilder -target/ - -# Jupyter Notebook -.ipynb_checkpoints - -# IPython -profile_default/ -ipython_config.py - -# pyenv -.python-version - -# pipenv -# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. -# However, in case of collaboration, if having platform-specific dependencies or dependencies -# having no cross-platform support, pipenv may install dependencies that don't work, or not -# install all needed dependencies. -#Pipfile.lock - -# PEP 582; used by e.g. github.com/David-OConnor/pyflow -__pypackages__/ - -# Celery stuff -celerybeat-schedule -celerybeat.pid - -# SageMath parsed files -*.sage.py - -# Environments -.env -.venv -env/ -venv/ -ENV/ -env.bak/ -venv.bak/ - -# Spyder project settings -.spyderproject -.spyproject - -# Rope project settings -.ropeproject - -# mkdocs documentation -/site - -# mypy -.mypy_cache/ -.dmypy.json -dmypy.json - -# Pyre type checker -.pyre/ diff --git a/tweet.py b/tweet.py index 79629bf..6a3051a 100755 --- a/tweet.py +++ b/tweet.py @@ -4,7 +4,12 @@ import tweepy from dotenv import load_dotenv import os import sys +import argparse +parser = argparse.ArgumentParser() +parser.add_argument("--filename", type=str) +parser.add_argument("--prompt", type=str) +args = parser.parse_args() load_dotenv() # Authenticate to Twitter @@ -15,8 +20,8 @@ auth.set_access_token(os.getenv("TOKEN"), os.getenv("TOKENSECRET")) api = tweepy.API(auth) # Create a tweet -media = api.media_upload(sys.argv[1]) - +media = api.media_upload(args.filename) +alt_text = api.create_media_metadata(media.media_id, args.prompt) tweet = "" api.update_status(status=tweet, media_ids=[media.media_id]) diff --git a/tweet.sh b/tweet.sh index b223227..8caf992 100755 --- a/tweet.sh +++ b/tweet.sh @@ -3,5 +3,6 @@ CONTAINER=$(/snap/bin/docker ps | grep miniconda | awk '{print $1}') /snap/bin/docker exec -i $CONTAINER /sd/run.sh IMAGE="$(ls /home/gabe/stable-diffusion/outputs/*.png -t | head -n1)" +PROMPT="$(echo $IMAGE | awk -F/ '{ print $6 }' | sed 's/.\{4\}$//')" /home/gabe/realesrgan/realesrgan-ncnn-vulkan -i "$IMAGE" -o /tmp/upscaled.png -python3 /home/gabe/lofi-imgen/tweet.py /tmp/upscaled.png +python3 /home/gabe/lofi-imgen/tweet.py --filename /tmp/upscaled.png --prompt "$PROMPT"