Prechádzať zdrojové kódy

Check owner and nextPageCursor working

emil 4 rokov pred
rodič
commit
fced24b203
1 zmenil súbory, kde vykonal 85 pridanie a 43 odobranie
  1. 85 43
      Main.py

+ 85 - 43
Main.py

@@ -3,18 +3,22 @@ import json
 import time
 import datetime
 
+# Make list of searched groups (debug för att ma aldrig får några valid, varna för duplicate)
+# Kolla på de andra api för att hämta grupper
+
 # ----------------------------------------------------------------- #
 
 keyword = "aaaa"
 exactMatch = False
 
 groupCount = 100  # 10, 25, 50, 100
-howManyCycles = 100
-delayTime = 5
+howManyCycles = 2
+delayTime = 0
 
-groupMaxMembers = 30
+groupMaxMembers = 10
 groupHasFunds = False
 publicGroup = True
+hasOwner = False
 
 saveInFile = True
 
@@ -26,49 +30,63 @@ url = "https://groups.rprxy.xyz/v1/groups/search?keyword=" + keyword + "&priorit
 
 foundGroups = []
 groupIdList = []
-nextPageCursor = ""
-
-for cycle in range(0, howManyCycles):
-    print("Cycle number: " + str(cycle))
-    print("Percentage: " + str(int((cycle / howManyCycles) * 1000) / 10) + "%")
-    requestData = requests.get(url + "&cursor=")
-    # print(requestData.json())
-    dataTable = json.loads(requestData.content)
-
-    if nextPageCursor == "end":
-        break
-
-    try:
-        nextPageCursor = dataTable["nextPageCursor"]
-    except:
-        nextPageCursor = "end"
-
-    for group in dataTable["data"]:
-        valid = True
-        if group["memberCount"] > groupMaxMembers:
-            valid = False
-        if publicGroup and not group["publicEntryAllowed"]:
-            valid = False
-        if groupHasFunds:
-            fundsUrl = "https://economy.rprxy.xyz/v1/groups/" + str(group["id"]) + "/currency"
-            economyData = requests.get(fundsUrl)
-            economyJSON = json.loads(economyData.content)
-            try:
-                if economyJSON["robux"] == 0:
-                    valid = False
-            except:
+lookedGroups = {}
+nextPageCursor = "yes"
+
+try:
+    for cycle in range(0, howManyCycles):
+        print("[WORKING] Cycle number: " + str(cycle))
+        print("[WORKING] Percentage: " + str(int((cycle / howManyCycles) * 1000) / 10) + "%")
+
+        if not nextPageCursor:
+            break
+        elif nextPageCursor == "yes":
+            nextPageCursor = ""
+
+        requestData = requests.get(url + "&cursor=" + nextPageCursor) # Forgot to add nextPageCursor, ruined the program...
+        # print(requestData.json())
+        dataTable = json.loads(requestData.content)
+
+        try:
+            nextPageCursor = dataTable["nextPageCursor"]
+        except:
+            nextPageCursor = ""
+
+        for group in dataTable["data"]:
+            if group["id"] in lookedGroups:
+                print("[WARN] Duplicate Group: " + group["name"])
+                continue
+            # else:
+                # lookedGroups[group["id"]] = True
+
+            valid = True
+            # print(str(group["memberCount"]))
+            if group["memberCount"] > groupMaxMembers:
                 valid = False
+            if publicGroup and not group["publicEntryAllowed"]:
+                valid = False
+            if groupHasFunds:
+                fundsUrl = "https://economy.rprxy.xyz/v1/groups/" + str(group["id"]) + "/currency"
+                economyData = requests.get(fundsUrl)
+                economyJSON = json.loads(economyData.content)
+                try:
+                    if economyJSON["robux"] == 0:
+                        valid = False
+                except:
+                    valid = False
 
-        if valid:
-            print("Found valid group " + str(group["id"]))
-            # group["description"] = ""
-            # group["name"] = ""
-            foundGroups.append(group)
-            groupIdList.append(group["id"])
-        # else:
-        # print("Invalid group")
+            if valid:
+                print("[INFO] Found valid group " + str(group["id"]))
+                # group["description"] = ""
+                # group["name"] = ""
+                foundGroups.append(group)
+                groupIdList.append(group["id"])
+            # else:
+            # print("Invalid group")
 
-    time.sleep(delayTime)
+        time.sleep(delayTime)
+except:
+    print("[ERROR] Error in loop")
 
 if foundGroups.__len__() > 0 and saveInFile:
     thisTime = datetime.datetime.today()
@@ -88,6 +106,30 @@ if foundGroups.__len__() > 0 and saveInFile:
             groupIdFile.write("\n")
         # groupIdFile.close()
 
+groupIdItt = groupIdList
+if not hasOwner:
+    for groupId in groupIdItt:
+        time.sleep(2)
+        ownerUrl = "https://groups.rprxy.xyz/v1/groups/" + str(groupId)
+        print(ownerUrl)
+        groupData = requests.get(ownerUrl)
+        groupJSON = json.loads(groupData.content)
+        try:
+            if groupJSON["owner"]["userId"]:
+                groupIdList.remove(groupId)
+                foundGroups.remove(groupId)
+                print("Has owner")
+                print(groupJSON)
+            else:
+                print("No owner")
+                print(groupJSON)
+        except:
+            print("No owner error")
+            print(groupJSON)
+
+
+
+
 print("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nSEARCH COMPLETE")
 print("Found groups: " + str(foundGroups.__len__()))
 print(foundGroups)