Added VK module

This commit is contained in:
houndvoyager 2022-11-08 20:02:58 +01:00
parent 3524d24f69
commit e707594eb8
4 changed files with 18 additions and 3 deletions

3
.gitignore vendored
View File

@ -1,4 +1,5 @@
__pycache__/
test.py
.env
venv/
venv/
vk_config.v2.json

View File

@ -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=
```

View File

@ -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:

View File

@ -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"])
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"]}))