From 1680e070bdec3700bb9964d21c0523222e48ca9c Mon Sep 17 00:00:00 2001 From: NW/RL Date: Mon, 1 Apr 2024 15:46:00 -0500 Subject: Posterity --- steamrelationships/__init__.py | 2 +- steamrelationships/sr.py | 30 +++++++++++++++++------------- 2 files changed, 18 insertions(+), 14 deletions(-) diff --git a/steamrelationships/__init__.py b/steamrelationships/__init__.py index b4b2480..8c1715a 100644 --- a/steamrelationships/__init__.py +++ b/steamrelationships/__init__.py @@ -1,3 +1,3 @@ -from steamrelationships.sr import SteamRelationships as sr +from steamrelationships.sr import SteamRelationships from steamrelationships.constants import _Const CONST = _Const() \ No newline at end of file diff --git a/steamrelationships/sr.py b/steamrelationships/sr.py index 88045b1..429eec2 100644 --- a/steamrelationships/sr.py +++ b/steamrelationships/sr.py @@ -111,7 +111,7 @@ class SteamRelationships: # example url: http://api.steampowered.com/ISteamUser/GetFriendList/v0001/?key=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX&steamid=76561197960435530&relationship=friend if not steamid64: print("Requested id must not be blank") - return + return {} # Format url and make a request url = "https://api.steampowered.com/ISteamUser/GetFriendList/v0001/" @@ -122,6 +122,7 @@ class SteamRelationships: # BIG WARNING BIG WARNING BIG WARNING BIG WARNING BIG WARNING BIG WARNING BIG WARNING BIG WARNING BIG WARNING BIG WARNING BIG WARNING # # TODO: FIX THIS SO IT DOESN"T EXPLODE EVERYTHING ALL THE TIME + response: object if self._checkrequests() > 0: response = self.session.get(url, params=options, timeout=self.timeout) # GET should be as secure as POST because ssl is being used @@ -144,21 +145,24 @@ class SteamRelationships: return final - def basic_scan(self, startid: str = None) -> list: - # Scan an initial id, then populate a list with the scans of each friend + # Do a basic scan for a single id + def basic_scan(self, id: str) -> list: + return self.parseFriendsList(self._getFriendsList(id)) + + def recursive_scan(self, startid: str, ): scans: dict = {} alreadyscanned: list = [] - - # Start the scan and collect the first user's friend list - scans[startid] = self.parseFriendsList(self._getFriendsList(startid)) + + scans[startid] = self.basic_scan(startid) alreadyscanned.append(startid) - ''' - # Scan the current scanid's friends and append them to the list - for friend in scans[startid]: - if friend not in alreadyscanned: - scans[friend] = self.parseFriendsList(self._getFriendsList(friend)) + tempscans: dict = {} + for person in scans: + for friend in scans[person]: + if friend not in alreadyscanned: + tempscans[friend] = self.basic_scan(tempscans) alreadyscanned.append(friend) - ''' - return scans \ No newline at end of file + scans.update(tempscans) + + return \ No newline at end of file -- cgit v1.2.3