diff --git a/.gitignore b/.gitignore index aab923d..93e4254 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ __pycache__/ test.py .env -venv/ \ No newline at end of file +venv/ +vk_config.v2.json \ No newline at end of file diff --git a/README.md b/README.md index 58d8b11..763c0e1 100644 --- a/README.md +++ b/README.md @@ -3,6 +3,7 @@ # Supported platforms: - [x] Mastodon (Come check it out at [@wownero](https://mastodon.social/@wownero)) - [x] Tumblr (only posts image due to the package limitations. Check out the feed here: [wownero](https://wownero.tumblr.com/) + - [X] VK (Here's the profile [suchmeme](https://vk.com/suchmeme) - [ ] XMPP - [ ] IRC @@ -25,4 +26,8 @@ consumer_key= consumer_secret= oauth_token= oauth_secret= + +VK: +vk_phone= +vk_pass= ``` \ No newline at end of file diff --git a/main.py b/main.py index 836b7a4..471f927 100644 --- a/main.py +++ b/main.py @@ -20,7 +20,7 @@ def scraper(): for item in api_list: try: supabase.table("suchmeme").insert(item).execute() - print(f'Inserted meme {item["id"]} to Supabase DB') + print(f'Inserted meme {item["id"]} to Supabase DB, posting it to social medias...') post(item) except Exception as e: if 'duplicate key value violates unique constraint' in str(e): @@ -34,6 +34,7 @@ def scraper(): def post(item): modules.masto(item) modules.tumblr(item) + modules.vk(item) while True: diff --git a/modules.py b/modules.py index 9d3b8b6..1547677 100644 --- a/modules.py +++ b/modules.py @@ -1,5 +1,6 @@ from mastodon import Mastodon import pytumblr2 +import vk_api import mimetypes import httpx import os @@ -34,4 +35,11 @@ def tumblr(post): 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"]) \ No newline at end of file + 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"]) + print(f'Posted meme {post["id"]} to Tumblr') + +def vk(post): + vk_session = vk_api.VkApi(os.environ.get("vk_phone"), os.environ.get("vk_pass")) + vk_session.auth() + vk = vk_session.get_api() + print("VK: ", vk.wall.post(message=f'New meme by {post["submitter"]}!\n{post["title"]} - {post["text"]}', attachments={post["href"]})) \ No newline at end of file