diff options
Diffstat (limited to 'steamrelationships')
| -rw-r--r-- | steamrelationships/__init__.py | 2 | ||||
| -rw-r--r-- | 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 @@ | |||
| 1 | from steamrelationships.sr import SteamRelationships as sr | 1 | from steamrelationships.sr import SteamRelationships |
| 2 | from steamrelationships.constants import _Const | 2 | from steamrelationships.constants import _Const |
| 3 | CONST = _Const() \ No newline at end of file | 3 | 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: | |||
| 111 | # example url: http://api.steampowered.com/ISteamUser/GetFriendList/v0001/?key=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX&steamid=76561197960435530&relationship=friend | 111 | # example url: http://api.steampowered.com/ISteamUser/GetFriendList/v0001/?key=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX&steamid=76561197960435530&relationship=friend |
| 112 | if not steamid64: | 112 | if not steamid64: |
| 113 | print("Requested id must not be blank") | 113 | print("Requested id must not be blank") |
| 114 | return | 114 | return {} |
| 115 | 115 | ||
| 116 | # Format url and make a request | 116 | # Format url and make a request |
| 117 | url = "https://api.steampowered.com/ISteamUser/GetFriendList/v0001/" | 117 | url = "https://api.steampowered.com/ISteamUser/GetFriendList/v0001/" |
| @@ -122,6 +122,7 @@ class SteamRelationships: | |||
| 122 | # BIG WARNING BIG WARNING BIG WARNING BIG WARNING BIG WARNING BIG WARNING BIG WARNING BIG WARNING BIG WARNING BIG WARNING BIG WARNING # | 122 | # BIG WARNING BIG WARNING BIG WARNING BIG WARNING BIG WARNING BIG WARNING BIG WARNING BIG WARNING BIG WARNING BIG WARNING BIG WARNING # |
| 123 | 123 | ||
| 124 | # TODO: FIX THIS SO IT DOESN"T EXPLODE EVERYTHING ALL THE TIME | 124 | # TODO: FIX THIS SO IT DOESN"T EXPLODE EVERYTHING ALL THE TIME |
| 125 | response: object | ||
| 125 | if self._checkrequests() > 0: | 126 | if self._checkrequests() > 0: |
| 126 | response = self.session.get(url, params=options, timeout=self.timeout) # GET should be as secure as POST because ssl is being used | 127 | response = self.session.get(url, params=options, timeout=self.timeout) # GET should be as secure as POST because ssl is being used |
| 127 | 128 | ||
| @@ -144,21 +145,24 @@ class SteamRelationships: | |||
| 144 | 145 | ||
| 145 | return final | 146 | return final |
| 146 | 147 | ||
| 147 | def basic_scan(self, startid: str = None) -> list: | 148 | # Do a basic scan for a single id |
| 148 | # Scan an initial id, then populate a list with the scans of each friend | 149 | def basic_scan(self, id: str) -> list: |
| 150 | return self.parseFriendsList(self._getFriendsList(id)) | ||
| 151 | |||
| 152 | def recursive_scan(self, startid: str, ): | ||
| 149 | scans: dict = {} | 153 | scans: dict = {} |
| 150 | alreadyscanned: list = [] | 154 | alreadyscanned: list = [] |
| 151 | 155 | ||
| 152 | # Start the scan and collect the first user's friend list | 156 | scans[startid] = self.basic_scan(startid) |
| 153 | scans[startid] = self.parseFriendsList(self._getFriendsList(startid)) | ||
| 154 | alreadyscanned.append(startid) | 157 | alreadyscanned.append(startid) |
| 155 | 158 | ||
| 156 | ''' | 159 | tempscans: dict = {} |
| 157 | # Scan the current scanid's friends and append them to the list | 160 | for person in scans: |
| 158 | for friend in scans[startid]: | 161 | for friend in scans[person]: |
| 159 | if friend not in alreadyscanned: | 162 | if friend not in alreadyscanned: |
| 160 | scans[friend] = self.parseFriendsList(self._getFriendsList(friend)) | 163 | tempscans[friend] = self.basic_scan(tempscans) |
| 161 | alreadyscanned.append(friend) | 164 | alreadyscanned.append(friend) |
| 162 | ''' | ||
| 163 | 165 | ||
| 164 | return scans \ No newline at end of file | 166 | scans.update(tempscans) |
| 167 | |||
| 168 | return \ No newline at end of file | ||
