You are viewing a single comment's thread from:

RE: A good place for Dutch Hive Meetup and Winner of Wordplay Contest

in Threespeak2 years ago

Think I've fixed the problem. This one should do the trick. It's not fast, so it will take some time to run:

#!/usr/bin/python3
import sys
import json
from lighthive.client import Client

def get_all_account_names(client):
    acc0 = ""
    while True:
        accounts = client.lookup_accounts(acc0,16)
        if acc0:
            yield accounts[1:]
        else:
            yield accounts
        if not accounts or len(accounts) == 1:
            return
        acc0 = accounts[-1]

def get_account_basinifo(client, accounts):
    for account in client.get_accounts(accounts):
        if (account["last_vote_time"][:4] == "2022" or account["last_post"][:4] == "2022"):
            location = []
            for candidate in ["json_metadata", "posting_json_metadata"]:
                if "{" in account[candidate]:
                    try:
                        data = json.loads(account[candidate])
                        if "profile" in data:
                            data = data["profile"]
                        if "location" in data:
                            location.append(data["location"])
                    except Exception as ex:
                        pass
            if location:
                yield [account["name"], location]


c = Client()
for accountchunk in get_all_account_names(c):
    for account_info in get_account_basinifo(c, accountchunk):
        print(account_info[0], ":", json.dumps(account_info[1]))

Getting output like this now:

a-0-0-0-real-dex : ["Worldwide", "Metaverse"]
a-alice : ["Mars"]
a-dalora : ["Germany", "Germany"]
a-g-shard : ["San Diego", "San Diego"]
a-journal : ["I live on planet Hive"]
a-quarius : ["Portugal", "Portugal"]
a-secondchance : ["Kuala Lumpur"]
a-steem-whale : ["Malaysia", ""]
a-white-ryan-o : ["Berkeley, CA"]
a0i : ["Montreal, Quebec, Canada", "Canada / Istanbul"]
a1-shroom-spores : ["FE"]
a1000carv : ["Venezuela", "Venezuela"]
a1edutech : ["India"]
a4ankit21 : ["Himalya"]
a4d : ["Virginia, USA"]
aa11 : ["earth", "earth"]
aa9 : ["Atjeh", "\u0e1b\u0e23\u0e30\u0e40\u0e17\u0e28\u0e44\u0e17\u0e22"]
aaa-winner : ["the Win zone", "the Win zone"]
aaalviarez : ["Venezuela"]
aadi-parin : ["Italy"]
aadilmir : ["India"]
aafeng : ["likerid:aafeng17936", "Earth"]
aafeng.test : ["Steemit", "Steemit"]
aafra123 : ["Bangladesh"]
aagabriel : ["Antarctica", "Antarctica"]
aahadrizwan : [""]
aak23 : ["Central Europe"]
aakash.sachdeva9 : ["India"]
aakashsinghbais : ["India", "India"]
aakom : ["Join the community ==>>", "Join the community ==>>"]
aaliyahholt : ["Chicago,IL"]
aaloulou : [""]
aalsi-you-later : ["Pune India", "Pune India"]
aamirasghar : ["Pakistan"]
aamirijaz : ["Islamabad, Pakistan ", "Islamabad, Pakistan "]
aamirwattoo : ["Lahore (Pakistan)"]
aamizone : ["Bangalore, India"]
aanantajit : ["Venezuela"]
aandin07 : [""]
aanjnaysharma7 : ["Kullu | Manali | Chandigarh "]
aarauz15 : ["Panama", "Panama"]
aare-no-stain : ["Lagos", "Lagos"]
aarin-adebiyi : ["Nigeria "]
aarolita : ["Venezuela"]
aaron05 : ["venezuela"]
aaronadventures : ["Canada"]
aaronkroeblinger : ["Austria", "Austria"]
aaronleang : ["Malaysia", "Malaysia"]
aaronli : ["likerid:luenlun", "Hong Kong"]
aaronmota : ["M\u00e9xico"]
aaronphammait : ["Vietnam"]
aaronsant5 : ["Venezuela"]
aaronsuncamacho : ["Nevada City, CA", "Nevada City, CA"]
aarontaggert : ["Oak Harbor, Washington, USA", "Oak Harbor, Washington, USA"]
aaronteng : ["Earth", "Earth"]
aaroonjlarab : ["BARRANQUILLA - COLOMBIA"]
aarundelhi : [""]
aarzun : [""]
aashirrshaikh : ["\ud83c\udf0d"]
aashish-kandel : ["Bharatpur, Nepal"]
aasthaparmar : ["Himachal"]
aax-exchange : [""]
aay.life : ["Bulgaria"]
ab-com : ["World ", "World "]
abachon : ["Germany"]

Five minutes of output, no dutchies yet, and barely at 'ab', but maybe if someone a little closer to the fire runs it, it might be faster, not sure.

Sort:  
Loading...