Added VK module
This commit is contained in:
parent
3524d24f69
commit
e707594eb8
|
@ -2,3 +2,4 @@ __pycache__/
|
|||
test.py
|
||||
.env
|
||||
venv/
|
||||
vk_config.v2.json
|
|
@ -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=
|
||||
```
|
3
main.py
3
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:
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
from mastodon import Mastodon
|
||||
import pytumblr2
|
||||
import vk_api
|
||||
import mimetypes
|
||||
import httpx
|
||||
import os
|
||||
|
@ -35,3 +36,10 @@ def tumblr(post):
|
|||
)
|
||||
|
||||
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"]}))
|
Loading…
Reference in New Issue