From 497ead82d663b9567ffe56d5138b894423724436 Mon Sep 17 00:00:00 2001 From: ChronosX88 Date: Mon, 4 Jul 2022 23:11:44 +0300 Subject: [PATCH] Implement multiple group archiving --- archive.py | 24 +++++++++++++----------- config.example.toml | 4 ++-- 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/archive.py b/archive.py index 1830ac5..b7e1416 100644 --- a/archive.py +++ b/archive.py @@ -1,24 +1,26 @@ -import asyncio -from turtle import down -import vk_api import argparse -from mastodon import Mastodon +import sys + +import dataset import requests import toml -import pathlib -import sys -import dataset +import vk_api +from mastodon import Mastodon parser = argparse.ArgumentParser() 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() config = toml.load(args.config) +if config["mastodon"].get(args.group) is None: + print("invalid group") + sys.exit(1) + mastodon = Mastodon( - access_token = config["mastodon"]["access_token"], - api_base_url = config["mastodon"]["instance"] + access_token=config["mastodon"][args.group]["access_token"], + api_base_url=config["mastodon"][args.group]["instance"] ) vk_session = vk_api.VkApi(token=config["vk"]["access_token"]) @@ -57,7 +59,7 @@ else: download_offset += 1 while download_count > 0: to_download = 0 - if download_count-100 < 0: + if download_count - 100 < 0: to_download = download_count download_count = 0 else: diff --git a/config.example.toml b/config.example.toml index 80ad293..4fa22b1 100644 --- a/config.example.toml +++ b/config.example.toml @@ -1,6 +1,6 @@ [vk] access_token = "***" -[mastodon] -instance = "https://mastodon.ml" +[mastodon.group_name] +instance = "https://mastodon.social" access_token = "***" \ No newline at end of file