Implement multiple group archiving

This commit is contained in:
ChronosX88 2022-07-04 23:11:44 +03:00
parent 43489a67bd
commit 497ead82d6
Signed by: ChronosXYZ
GPG Key ID: 52A90DE5862D8321
2 changed files with 15 additions and 13 deletions

View File

@ -1,24 +1,26 @@
import asyncio
from turtle import down
import vk_api
import argparse import argparse
from mastodon import Mastodon import sys
import dataset
import requests import requests
import toml import toml
import pathlib import vk_api
import sys from mastodon import Mastodon
import dataset
parser = argparse.ArgumentParser() parser = argparse.ArgumentParser()
parser.add_argument("-c", "--config", help="Config path") parser.add_argument("-c", "--config", help="Config path")
parser.add_argument("-g", "--group", help="VK group domain") parser.add_argument("-g", "--group", help="VK group to archive")
args = parser.parse_args() args = parser.parse_args()
config = toml.load(args.config) config = toml.load(args.config)
if config["mastodon"].get(args.group) is None:
print("invalid group")
sys.exit(1)
mastodon = Mastodon( mastodon = Mastodon(
access_token = config["mastodon"]["access_token"], access_token=config["mastodon"][args.group]["access_token"],
api_base_url = config["mastodon"]["instance"] api_base_url=config["mastodon"][args.group]["instance"]
) )
vk_session = vk_api.VkApi(token=config["vk"]["access_token"]) vk_session = vk_api.VkApi(token=config["vk"]["access_token"])
@ -57,7 +59,7 @@ else:
download_offset += 1 download_offset += 1
while download_count > 0: while download_count > 0:
to_download = 0 to_download = 0
if download_count-100 < 0: if download_count - 100 < 0:
to_download = download_count to_download = download_count
download_count = 0 download_count = 0
else: else:

View File

@ -1,6 +1,6 @@
[vk] [vk]
access_token = "***" access_token = "***"
[mastodon] [mastodon.group_name]
instance = "https://mastodon.ml" instance = "https://mastodon.social"
access_token = "***" access_token = "***"