Spaces:
Running
Running
Commit
·
fdbc27b
1
Parent(s):
dc6febb
Minor Changes in Codes
Browse files
FileStream/bot/__init__.py
CHANGED
@@ -23,8 +23,8 @@ WORK_LOADS = {}
|
|
23 |
MULTI_CLIENTS = {}
|
24 |
ACTIVE_CLIENTS = {}
|
25 |
|
26 |
-
async def req_client():
|
27 |
index = min(WORK_LOADS, key=WORK_LOADS.get)
|
28 |
faster_client = MULTI_CLIENTS[index]
|
29 |
-
response = dict(index=index, client=faster_client)
|
30 |
-
return
|
|
|
23 |
MULTI_CLIENTS = {}
|
24 |
ACTIVE_CLIENTS = {}
|
25 |
|
26 |
+
async def req_client(PUBLIC_IP:str)-> dict:
|
27 |
index = min(WORK_LOADS, key=WORK_LOADS.get)
|
28 |
faster_client = MULTI_CLIENTS[index]
|
29 |
+
#response = dict(index=index, client=faster_client)
|
30 |
+
return dict(index=index,public_ip=PUBLIC_IP, client=faster_client)
|
FileStream/server/Functions/downloader.py
CHANGED
@@ -22,8 +22,9 @@ from FileStream.utils.FileProcessors.custom_ul import TeleUploader
|
|
22 |
async def media_streamer(request: web.Request, db_id: str, speed: str):
|
23 |
# Get the Range header from the request, default to 0 if not present
|
24 |
range_header = request.headers.get("Range", 0)
|
25 |
-
client = await req_client()
|
26 |
# Log client info if multi-client mode
|
|
|
27 |
if Telegram.MULTI_CLIENT:
|
28 |
logging.info(f"Client {client['index']} is now serving {request.headers.get('X-FORWARDED-FOR', request.remote)}")
|
29 |
|
@@ -31,13 +32,13 @@ async def media_streamer(request: web.Request, db_id: str, speed: str):
|
|
31 |
tg_connect = ACTIVE_CLIENTS.get(client['client'], None)
|
32 |
|
33 |
if tg_connect is None:
|
34 |
-
logging.
|
35 |
tg_connect = utils.ByteStreamer(client['client'])
|
36 |
ACTIVE_CLIENTS[client['client']] = tg_connect
|
37 |
|
38 |
else:
|
39 |
tg_connect.update_last_activity()
|
40 |
-
logging.
|
41 |
|
42 |
try:
|
43 |
# Fetch file properties once and use it throughout
|
|
|
22 |
async def media_streamer(request: web.Request, db_id: str, speed: str):
|
23 |
# Get the Range header from the request, default to 0 if not present
|
24 |
range_header = request.headers.get("Range", 0)
|
25 |
+
client = await req_client(request.remote)
|
26 |
# Log client info if multi-client mode
|
27 |
+
|
28 |
if Telegram.MULTI_CLIENT:
|
29 |
logging.info(f"Client {client['index']} is now serving {request.headers.get('X-FORWARDED-FOR', request.remote)}")
|
30 |
|
|
|
32 |
tg_connect = ACTIVE_CLIENTS.get(client['client'], None)
|
33 |
|
34 |
if tg_connect is None:
|
35 |
+
logging.info(f"Creating new ByteStreamer object for client {client['index']}")
|
36 |
tg_connect = utils.ByteStreamer(client['client'])
|
37 |
ACTIVE_CLIENTS[client['client']] = tg_connect
|
38 |
|
39 |
else:
|
40 |
tg_connect.update_last_activity()
|
41 |
+
logging.info(f"Using cached ByteStreamer object for client {client['index']}")
|
42 |
|
43 |
try:
|
44 |
# Fetch file properties once and use it throughout
|