parent
b234b9be64
commit
c686dafb37
@ -1,20 +1,38 @@
|
||||
from mastodon import Mastodon
|
||||
import mimetypes, httpx, os
|
||||
import pytumblr2
|
||||
import mimetypes
|
||||
import httpx
|
||||
import os
|
||||
from dotenv import load_dotenv
|
||||
|
||||
load_dotenv()
|
||||
|
||||
def mastodon(post):
|
||||
mastodon = Mastodon(
|
||||
access_token = os.environ.get("MAST_TOKEN"),
|
||||
api_base_url = 'https://mastodon.social'
|
||||
)
|
||||
try:
|
||||
i = httpx.get(post["image"]).content
|
||||
mime = mimetypes.guess_type(post["image"], strict=True)[0]
|
||||
media_ids = mastodon.media_post(i, mime, description=f'{post["title"]}')["id"]
|
||||
media_ids = [media_ids]
|
||||
content = f'New meme by {post["submitter"]}!\n{post["title"]} - {post["text"]}\n{post["href"]}'
|
||||
mastodon.status_post(content, media_ids=media_ids)
|
||||
print(f'Posted {post["id"]} to Mastodon @wownero')
|
||||
except Exception as e:
|
||||
print(e)
|
||||
|
||||
def masto(post):
|
||||
mastodon = Mastodon(
|
||||
access_token=os.environ.get("MAST_TOKEN"),
|
||||
api_base_url='https://mastodon.social'
|
||||
)
|
||||
try:
|
||||
i = httpx.get(post["image"]).content
|
||||
mime = mimetypes.guess_type(post["image"], strict=True)[0]
|
||||
media_ids = mastodon.media_post(i, mime, description=f'{post["title"]}')["id"]
|
||||
media_ids = [media_ids]
|
||||
content = f'New meme by {post["submitter"]}!\n{post["title"]} - {post["text"]}\n{post["href"]}'
|
||||
mastodon.status_post(content, media_ids=media_ids)
|
||||
print(f'Posted {post["id"]} to Mastodon @wownero')
|
||||
except Exception as e:
|
||||
print(e)
|
||||
|
||||
|
||||
|
||||
def tumblr(post):
|
||||
client = pytumblr2.TumblrRestClient(
|
||||
os.environ.get("consumer_key"),
|
||||
os.environ.get("consumer_secret"),
|
||||
os.environ.get("oauth_token"),
|
||||
os.environ.get("oauth_secret"),
|
||||
)
|
||||
|
||||
client.legacy_create_photo("wownero", state="published", tags=["wownero", "such", "meme", "wow", "memes"], caption=f'New meme by {post["submitter"]}!\n{post["title"]} - {post["text"]}', link=f'{post["href"]}',
|
||||
source=post["image"])
|
Loading…
Reference in new issue