initial commit of the extraction script

This commit is contained in:
Tobias Diekershoff 2022-11-01 18:18:50 +01:00
parent 9a2c8e1a1e
commit f998594403

46 Normal file
View file

@ -0,0 +1,46 @@
#!/usr/bin/env python3
## SPDX-FileCopyrightText: 2022 Tobias Diekershoff <>
## SPDX-License-Identifier: BSD-3-Clause
Script to extract contact URLs from an exported OSADA profile JSON file. The
extracted contact information is stored as CSV file that can be uploaded and
imported into Friendica (Mastodon, etc. might work as well).
-- Tobias Diekershoff (2022-10-27)
import sys
import json
from os.path import exists
if len(sys.argv) != 2:
print('Please call this script with one or two parameters.')
print('1st the input file, which is the JSON exported from Osada.')
print('The output will be written to the STDOUT and can be redirected from there.')
if not exists(sys.argv[1]):
print('File "{}" not found.'.format(sys.argv[1]))
CSVFilename = sys.argv[1].replace('.json', '.csv')
f = open(CSVFilename, 'w')
f.write('Account address, Show boosts, my_permissions\n')
print('Could not write the file "{}" stopping the extraction.'.format(CSVFilename))
with open(sys.argv[1], "r") as json_data:
osada = json.load(json_data)
for item in osada['abook']:
for config in item['abconfig']:
if config['xchan'][:8] == 'https://':
if config['k'] == 'my_perms':
f.write('{}, true, "{}"\n'.format(config['xchan'], config['v']))