Skip to content

Instantly share code, notes, and snippets.

@researcx
Created December 11, 2023 13:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save researcx/5463cadf82e0060f9b4de87525c81e11 to your computer and use it in GitHub Desktop.
Save researcx/5463cadf82e0060f9b4de87525c81e11 to your computer and use it in GitHub Desktop.
import json, shlex, sys
from subprocess import Popen
caption = sys.argv[1]
image_caption = ""
if len(sys.argv) == 4:
image_caption = sys.argv[3]
social_media = sys.argv[2].split(',')
is_image = False
print(sys.argv)
# usage: do_social_media_post.py "<message/image>" twitter,mastodon,bluesky,facebook,instagram
if caption.endswith(('jpg', 'png', 'gif', 'jpeg')):
is_image = True
for site in social_media:
if is_image == False:
if site != "instagram":
command = "/opt/homebrew/bin/python3 /Users/researcx/Development/social_media_bots/"+site+"/posters/"+site+"_text.py " + json.dumps(caption)
print(command)
proc = Popen(shlex.split(command)) #, shell=True)
proc.communicate()
else:
print("instagram does not support text posting")
else:
command = "/opt/homebrew/bin/python3 /Users/researcx/Development/social_media_bots/"+site+"/posters/"+site+"_image.py " + caption + " " + json.dumps(image_caption)
print(command)
proc = Popen(shlex.split(command)) #, shell=True)
proc.communicate()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment