From: Roland Häder Date: Thu, 6 Jul 2023 07:59:05 +0000 (+0200) Subject: Fixed: X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=f0b80435fd9a8031a3e006652346289cf0e25598;p=fba.git Fixed: - PeerTube's JSON response always includes mode2=following or mode2=follower depending on if mode=followers or mode=following is set - this causes PeerTube instances being reported with duplicate amount of peers --- diff --git a/fba/networks/peertube.py b/fba/networks/peertube.py index 2cfa7f9..7dc41cb 100644 --- a/fba/networks/peertube.py +++ b/fba/networks/peertube.py @@ -68,13 +68,11 @@ def fetch_peers(domain: str) -> list: logger.debug("Found %d record(s).", len(rows)) for record in rows: logger.debug("record()=%d", len(record)) - for mode2 in ["follower", "following" ]: - logger.debug("mode2='%s'", mode2) - if mode2 in record and "host" in record[mode2]: + for mode2 in ["follower", "following"]: + logger.debug("mode=%s,mode2='%s'", mode, mode2) + if mode2 in record and "host" in record[mode2] and record[mode2]["host"] != domain: logger.debug("Found mode2='%s',host='%s', adding ...", mode2, record[mode2]['host']) peers.append(record[mode2]["host"]) - else: - logger.warning("Record from domain='%s' has no mode2='%s' or 'host' record[]='%s", domain, mode2, type(record)) if len(rows) < 100: logger.debug("Reached end of JSON response, domain='%s'", domain) @@ -86,5 +84,5 @@ def fetch_peers(domain: str) -> list: logger.warning("domain='%s' causes error during API query: '%s' - SKIPPED!", domain, data['error_message']) break - logger.debug("Returning peers[]='%s' - EXIT!", type(peers)) + logger.debug("peers[%s]()=%d - EXIT!", type(peers), len(peers)) return peers