joinpeertube/generate-instances-list.py

41 lines
1.6 KiB
Python
Raw Permalink Normal View History

#!/bin/python3
import json
import requests
2020-02-09 02:47:11 +00:00
instance_list = ['peertube.social', 'tube.tchncs.de', 'vidcommons.org', 'video.deadsuperhero.com', 'diode.zone', 'share.tube']
json_list = []
2020-02-09 02:47:11 +00:00
id = 0
for i in instance_list:
config_json = requests.get('https://' + i + '/api/v1/config').json()
about_json = requests.get('https://' + i + '/api/v1/config/about').json()
stats_json = requests.get('https://' + i + '/api/v1/server/stats').json()
2020-02-09 02:47:11 +00:00
data = {
"id": id,
"host": i,
"name": config_json['instance']['name'],
"shortDescription": config_json['instance']['shortDescription'],
"version": config_json['serverVersion'],
"signupAllowed": config_json['signup']['allowed'],
"userVideoQuota": config_json['user']['videoQuota'],
"categories": about_json['instance']['categories'],
"languages": about_json['instance']['languages'],
"autoBlacklistUserVideosEnabled": config_json['autoBlacklist']['videos']['ofUsers']['enabled'],
"defaultNSFWPolicy": config_json['instance']['defaultNSFWPolicy'],
"isNSFW": config_json['instance']['isNSFW'],
"totalUsers": stats_json['totalUsers'],
"totalVideos": stats_json['totalVideos'],
"totalLocalVideos": stats_json['totalLocalVideos'],
"totalInstanceFollowers": stats_json['totalInstanceFollowers'],
"totalInstanceFollowing": stats_json['totalInstanceFollowing'],
"health": None,
"createdAt": None
2020-02-09 02:47:11 +00:00
}
json_list.append(data)
2020-02-09 02:47:11 +00:00
id += 1
2020-02-09 02:47:11 +00:00
json = json.dumps({"total": len(json_list), "data": json_list}, indent=4)
print(json, file=open('public/instances.json', 'w'))