privateone commited on
Commit
51cfe77
·
1 Parent(s): 8212bf7

Testing Changes

Browse files
FileStream/bot/__init__.py CHANGED
@@ -26,7 +26,7 @@ ACTIVE_CLIENTS = {}
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
- print("\n \nFaster Client",faster_client,type(faster_client),"\nWORK_LOADS",WORK_LOADS,type(WORK_LOADS),"\nMULTI_CLIENTS",MULTI_CLIENTS,type(MULTI_CLIENTS),"\n")
30
  #ACTIVE_CLIENTS.update(faster_client)
31
  #response = dict(index=index, client=faster_client)
32
  return dict(index=index,public_ip=PUBLIC_IP, client=faster_client)
 
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
+ pprint("\n \nFaster Client",faster_client,type(faster_client),"\nWORK_LOADS",WORK_LOADS,type(WORK_LOADS),"\nMULTI_CLIENTS",MULTI_CLIENTS,type(MULTI_CLIENTS),"\n")
30
  #ACTIVE_CLIENTS.update(faster_client)
31
  #response = dict(index=index, client=faster_client)
32
  return dict(index=index,public_ip=PUBLIC_IP, client=faster_client)
FileStream/server/Functions/downloader.py CHANGED
@@ -22,23 +22,24 @@ 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(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
 
31
  # Use an existing ByteStreamer or create a new one
32
  #tg_connect = ACTIVE_CLIENTS.get(client['client'], None)
33
 
34
- if client["client"] in ACTIVE_CLIENTS:
35
- logging.info(f"Creating new ByteStreamer object for client {client['index']}")
36
- tg_connect = ACTIVE_CLIENTS(client["client"])
37
 
38
  else:
39
- tg_connect = utils.ByteStreamer(client["client"])
40
- ACTIVE_CLIENTS[client["client"]] = tg_connect
41
- logging.info(f"Using cached ByteStreamer object for client {client['index']}")
42
 
43
  tg_connect.update_last_activity()
44
 
@@ -71,7 +72,7 @@ async def media_streamer(request: web.Request, db_id: str, speed: str):
71
 
72
  # Request the file chunks
73
  body = tg_connect.yield_file(
74
- file_id, client['index'], offset, first_part_cut, last_part_cut, part_count, chunk_size
75
  )
76
 
77
  # Determine MIME type and filename
 
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
+ Worker = await req_client(request.remote)
26
+ client=Worker["client"]
27
  # Log client info if multi-client mode
28
 
29
  if Telegram.MULTI_CLIENT:
30
+ logging.info(f"Client {Worker['index']} is now serving {request.headers.get('X-FORWARDED-FOR', request.remote)}")
31
 
32
  # Use an existing ByteStreamer or create a new one
33
  #tg_connect = ACTIVE_CLIENTS.get(client['client'], None)
34
 
35
+ if client in ACTIVE_CLIENTS:
36
+ logging.info(f"Creating new ByteStreamer object for client {Worker['index']}")
37
+ tg_connect = ACTIVE_CLIENTS(client)
38
 
39
  else:
40
+ tg_connect = utils.ByteStreamer(client)
41
+ ACTIVE_CLIENTS[client] = tg_connect
42
+ logging.info(f"Using cached ByteStreamer object for client {Worker['index']}")
43
 
44
  tg_connect.update_last_activity()
45
 
 
72
 
73
  # Request the file chunks
74
  body = tg_connect.yield_file(
75
+ file_id, Worker['index'], offset, first_part_cut, last_part_cut, part_count, chunk_size
76
  )
77
 
78
  # Determine MIME type and filename