64 lines
2.0 KiB
Python
Executable File
64 lines
2.0 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
# Copyright (C) 2024 fl4nn@posteo.de
|
|
# SPDX-License-Identifier: AGPL-3.0-or-later
|
|
#
|
|
# This program is free software: you can redistribute it and/or modify
|
|
# it under the terms of the GNU Affero General Public License as published by
|
|
# the Free Software Foundation, either version 3 of the License, or
|
|
# (at your option) any later version.
|
|
#
|
|
# This program is distributed in the hope that it will be useful,
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
# GNU Affero General Public License for more details.
|
|
#
|
|
# You should have received a copy of the GNU Affero General Public License
|
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
import os
|
|
import csv
|
|
from mastodon import Mastodon
|
|
import argparse
|
|
parser = argparse.ArgumentParser()
|
|
parser.add_argument("-f", "--file", type=str,
|
|
help="Path to the list of posts to boost")
|
|
args = parser.parse_args()
|
|
|
|
if not args.file:
|
|
print("Missing required argument: --file")
|
|
quit()
|
|
|
|
if os.path.isfile(args.file) and (os.path.getsize(args.file) > 1):
|
|
with open(args.file, 'r+', newline='') as f:
|
|
posts = csv.reader(f)
|
|
to_post = next(posts)
|
|
data = f.read()
|
|
f.seek(0)
|
|
f.write(data)
|
|
f.truncate()
|
|
else:
|
|
print("File is empty or does not exist")
|
|
quit()
|
|
|
|
bot = Mastodon(
|
|
access_token = os.environ.get('access_token'),
|
|
api_base_url = os.environ.get('base_url'),
|
|
version_check_mode = "none" # Disable version check to work with GtS
|
|
)
|
|
|
|
for field in to_post:
|
|
if field.find('http') == -1:
|
|
print("Not a URL")
|
|
else:
|
|
search = bot.search_v2(
|
|
q = field.strip(),
|
|
result_type = "statuses"
|
|
)
|
|
if search.statuses == []:
|
|
print("No matching post found")
|
|
else:
|
|
bot.status_reblog(
|
|
id = search.statuses[0].id,
|
|
visibility = "public"
|
|
)
|