Exilon24 / RobloxServerFinder

Find a roblox server in a given region
MIT License
1 stars 1 forks source link

Is there a way to select a more specific location? like Florida? #6

Open TheConfusedlol opened 1 month ago

TheConfusedlol commented 1 month ago

I saw this nifty little script and was just wondering if there's a way to filter it down to a more specific location?

Exilon24 commented 1 month ago

Unfortunately, it's not currently a feature.

You can edit the code and add a check for florida yourself if you want to, but you need some python skill

TheConfusedlol commented 1 month ago

Unfortunately, it's not currently a feature.

You can edit the code and add a check for florida yourself if you want to, but you need some python skill

yeah ive actually been doing that, how's this?

import requests
from selenium import webdriver
import asyncio
import time
import aiohttp

# Roblox cookie
robloxCookie = "(cookie)"

# Variables for location (can be "None" if not provided)
targetCity = "singapore"  # make this be read first
targetRegion = "None"  # make this be read if targetCity is "None"
targetCountryCode = "SG"  # make this be read if others are "None"

print("Roblox Server Finder by Exilon (Exilon24 on GitHub).")
placeId = int(input("PlaceID: "))
print("Looking for game...")

uri = f"https://games.roblox.com/v1/games/{str(placeId)}/servers/Public?excludeFullGames=true&limit=100"
response = requests.get(url=uri)
servers = response.json()["data"]

gameUniverseID = requests.get(f"https://apis.roblox.com/universes/v1/places/{str(placeId)}/universe").json()["universeId"]
gameInfo = requests.get(f"https://games.roblox.com/v1/games?universeIds={str(gameUniverseID)}").json()["data"][0]

print("--------------------------------------------------------")
print(f"Now joining: {gameInfo['name']} by {gameInfo['creator']['name']}.\nThere are {gameInfo['playing']} players currently online.")
print("--------------------------------------------------------")
print("Attempting to find server information...")

authCookies = {
    ".ROBLOSECURITY": robloxCookie,
}
authHeaders = {
    "Referer": f"https://www.roblox.com/games/{placeId}/",
    "Origin": "https://roblox.com",
    "User-Agent": "Roblox/WinInet",
}

taskList = []
global driver
driver = webdriver.Chrome()

async def getServerInfo(server):
    async with aiohttp.ClientSession(cookies=authCookies) as session:
        serverId = server["id"]
        res = await session.post("https://gamejoin.roblox.com/v1/join-game-instance",
                     data={
                     "placeId": placeId,
                     "isTeleport": False,
                     "gameId": serverId,
                     "gameJoinAttemptId": serverId
                     },
                     headers=authHeaders)
        ip = await res.json()
        ip = ip["joinScript"]

        if ip is None:
            return False

        try:
            ip = ip["UdmuxEndpoints"][0]["Address"]
        except:
            print("Error with Roblox server joins...")
            return False

        # Geolocation request for the IP address
        geolocation = await session.get(f"http://ip-api.com/json/{ip}")
        geolocation = await geolocation.json()

        if geolocation["status"] != "success":
            return False

        # Print out the geolocation details
        print(f"Server found at ({geolocation['countryCode']}) --> {geolocation['region']}, {geolocation['city']}")

        # Dynamically check available variables
        if ((targetCountryCode == "None" or geolocation["countryCode"].lower() == targetCountryCode.lower()) and
            (targetRegion == "None" or geolocation["region"].lower() == targetRegion.lower()) and
            (targetCity == "None" or geolocation["city"].lower() == targetCity.lower())):

            driver.get(f"https://www.roblox.com/games/{str(placeId)}/")
            driver.add_cookie({
                "name": ".ROBLOSECURITY",
                "value": robloxCookie,
                "path": "/",
                "domain": ".roblox.com"
            })
            driver.refresh()
            driver.execute_script(f"Roblox.GameLauncher.joinGameInstance({placeId}, \"{serverId}\")")
            for t in taskList:
                t.cancel()
            return True
        return False

# Main async loop to find servers
async def main():
    for server in servers:
        taskList.append(asyncio.create_task(getServerInfo(server)))

    try:
        await asyncio.gather(*taskList)
    except:
        print("Done...") 

asyncio.run(main())
time.sleep(20)  # Keep the webdriver open to ensure Roblox loads
TheConfusedlol commented 1 month ago

It mostly works but Singapore, Japan and Oregon servers have been troublesome to deal with