ZeroIntensity / gamehub

Official GameHub Repository.
https://www.gamehub2.com
MIT License
4 stars 3 forks source link

Gamehub blocked fcps #27

Open MoistJim opened 2 years ago

ZeroIntensity commented 2 years ago

there isnt that much that i can do about this.

there are a number of freenom links (such as https://www.game-hub2.tk/) that might be unblocked, but no guarantees.

if you would like to host your own version of the site, you can query games and their URLs from the API, as so:

query {
  games {
    name # name of the game
    data # URL of the game
  }
}

its also built to be very friendly to proxies, so you could try a proxy from titanium network or write your own:

# warning: this script may not work properly
from fastapi import FastAPI, Request, Response
from fastapi.responses import FileResponse
import uvicorn
import aiohttp
from base64 import urlsafe_b64encode
import aiofiles
import os
import re

app = FastAPI()
BASE_URL: str = "https://www.gamehub2.com"
CURRENT_URL: str = 'your_url_here'

async def prox_response(res: aiohttp.ClientResponse):
    text: str = await res.text()
    text = text.replace(BASE_URL.replace('https://', ''), CURRENT_URL)
    typ: str = res.headers['Content-Type']
    target = Response

    if not re.match('text/html', typ):
        path: str = f'./cache/{urlsafe_b64encode(str(res.url).encode()).decode()}.cache'  # make sure to create a cache directory

        if not os.path.exists(path):
            async with aiofiles.open(path, mode = "wb") as f:
                await f.write(await res.read())

        target = FileResponse
        text = path

    return target(text, res.status, media_type = res.headers['Content-Type'])

@app.exception_handler(404)
async def handle(request: Request, _) -> Response:
    path: str = request.url.path
    async with aiohttp.ClientSession() as session:
        async with session.get(BASE_URL + path) as response:
            return await prox_response(response)

if __name__ ==  '__main__':
    uvicorn.run(app, host = '0.0.0.0', port = 5000)  # type: ignore