Load all members of list
Signed-off-by: Markus Birth <markus@birth-online.de>
This commit is contained in:
@@ -15,7 +15,21 @@ class BlueBackBlocker():
|
||||
|
||||
def get_list(self, list_id: str):
|
||||
list_uri = f"at://{self.did}/app.bsky.graph.list/{list_id}"
|
||||
return self.agent.app.bsky.graph.get_list({"list": list_uri})
|
||||
cursor = None
|
||||
members = []
|
||||
while True:
|
||||
r = self.agent.app.bsky.graph.get_list({"list": list_uri, "cursor": cursor})
|
||||
# returns keys "items", "list", and "cursor"
|
||||
members += r["items"]
|
||||
#print(r)
|
||||
sleep(0.20)
|
||||
if not r["cursor"]:
|
||||
break
|
||||
cursor = r["cursor"]
|
||||
return {
|
||||
"items": members,
|
||||
"list": r["list"]
|
||||
}
|
||||
|
||||
def add_to_list(self):
|
||||
pass
|
||||
@@ -60,12 +74,16 @@ def main():
|
||||
config = configparser.ConfigParser()
|
||||
config.read("config.ini")
|
||||
|
||||
print(f"Logging into BlueSky as: [bold cyan]{config['BlueSky']['Username']}")
|
||||
blocker = BlueBackBlocker(config["BlueSky"]["Username"], config["BlueSky"]["Password"])
|
||||
print(f"Logged into BlueSky as: [bold cyan]{blocker.profile.display_name}")
|
||||
print(f"Logged into BlueSky, display name: [bold blue]{blocker.profile.display_name}[/bold blue], ", end="")
|
||||
print(f"DID: [bold yellow]{blocker.did}")
|
||||
print(f"Loading list with id [bold white]{config['BlueSky']['ListId']}")
|
||||
blocklist = blocker.get_list(config["BlueSky"]["ListId"])
|
||||
#print(repr(blocklist))
|
||||
#print(blocklist)
|
||||
print(f"Found list: [bold green]{blocklist['list']['name']}[/bold green] with [bold yellow]{len(blocklist['items'])}[/bold yellow] entries.")
|
||||
|
||||
"""
|
||||
cs = ClearSky(blocker.did)
|
||||
lists_im_on = cs.get_lists()
|
||||
print(repr(lists_im_on))
|
||||
@@ -75,6 +93,7 @@ def main():
|
||||
|
||||
subscribe_blocks_im_on = cs.get_subscribed_blocklists()
|
||||
print(repr(subscribe_blocks_im_on))
|
||||
|
||||
"""
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
||||
Reference in New Issue
Block a user