coollsd commited on
Commit
78891bd
·
verified ·
1 Parent(s): 892834b

Update ccc.py

Browse files
Files changed (1) hide show
  1. ccc.py +35 -32
ccc.py CHANGED
@@ -47,7 +47,7 @@ async def send_to_discord(session, asset_id, name, creator_id, creator_name, cre
47
  async with session.post(discord_webhook_url, json=embed) as response:
48
  if response.status != 204:
49
  pass
50
- except Exception:
51
  pass
52
 
53
  async def check_asset_batch(session, asset_ids):
@@ -60,10 +60,8 @@ async def check_asset_batch(session, asset_ids):
60
  'Requester': 'Client',
61
  'User-Agent': 'Roblox/WinInetRobloxApp'
62
  }) as response:
63
-
64
  if response.status == 200:
65
  results = await response.json()
66
-
67
  if not results or (isinstance(results, list) and all("errors" in result for result in results)):
68
  return
69
 
@@ -73,35 +71,37 @@ async def check_asset_batch(session, asset_ids):
73
  tasks.append(fetch_asset_info(session, asset_id))
74
 
75
  await asyncio.gather(*tasks)
76
-
77
- except Exception:
78
  pass
79
 
80
  async def fetch_asset_info(session, asset_id):
81
  global assets_checked, valid_assets_found
82
- with assets_checked.get_lock():
83
- assets_checked.value += 1
84
-
85
- async with session.get(f"{asset_info_url}{asset_id}/details") as asset_info_response:
86
- if asset_info_response.status == 200:
87
- asset_info = await asset_info_response.json()
88
-
89
- name = asset_info.get("Name", "Unknown")
90
- asset_type = asset_info.get("AssetTypeId", "Unknown")
91
- creator = asset_info.get("Creator", {})
92
- creator_id = creator.get("Id", "Unknown")
93
- creator_name = creator.get("Name", "Unknown")
94
- creator_type = creator.get("CreatorType", "Unknown")
95
- created_date_str = asset_info.get("Created", "Unknown")
96
- created_date = parse_iso8601(created_date_str)
97
- if created_date:
98
- created_date_formatted = created_date.strftime("%Y-%m-%d %H:%M:%S")
99
- else:
100
- created_date_formatted = "Unknown"
101
-
102
- with valid_assets_found.get_lock():
103
- valid_assets_found.value += 1
104
- await send_to_discord(session, asset_id, name, creator_id, creator_name, creator_type, asset_type, created_date_formatted)
 
 
 
105
 
106
  def parse_iso8601(date_str):
107
  try:
@@ -126,10 +126,13 @@ def generate_ids_batch(digit, batch_size=10000):
126
  return ids_batch
127
 
128
  async def run_scanner_instance(digit):
129
- async with aiohttp.ClientSession() as session:
130
- while True:
131
- batch = generate_ids_batch(digit)
132
- await check_asset_batch(session, batch)
 
 
 
133
 
134
  async def print_status_periodically():
135
  while True:
 
47
  async with session.post(discord_webhook_url, json=embed) as response:
48
  if response.status != 204:
49
  pass
50
+ except (aiohttp.ClientError, ConnectionError):
51
  pass
52
 
53
  async def check_asset_batch(session, asset_ids):
 
60
  'Requester': 'Client',
61
  'User-Agent': 'Roblox/WinInetRobloxApp'
62
  }) as response:
 
63
  if response.status == 200:
64
  results = await response.json()
 
65
  if not results or (isinstance(results, list) and all("errors" in result for result in results)):
66
  return
67
 
 
71
  tasks.append(fetch_asset_info(session, asset_id))
72
 
73
  await asyncio.gather(*tasks)
74
+ except (aiohttp.ClientError, ConnectionError):
 
75
  pass
76
 
77
  async def fetch_asset_info(session, asset_id):
78
  global assets_checked, valid_assets_found
79
+ try:
80
+ with assets_checked.get_lock():
81
+ assets_checked.value += 1
82
+
83
+ async with session.get(f"{asset_info_url}{asset_id}/details") as asset_info_response:
84
+ if asset_info_response.status == 200:
85
+ asset_info = await asset_info_response.json()
86
+
87
+ name = asset_info.get("Name", "Unknown")
88
+ asset_type = asset_info.get("AssetTypeId", "Unknown")
89
+ creator = asset_info.get("Creator", {})
90
+ creator_id = creator.get("Id", "Unknown")
91
+ creator_name = creator.get("Name", "Unknown")
92
+ creator_type = creator.get("CreatorType", "Unknown")
93
+ created_date_str = asset_info.get("Created", "Unknown")
94
+ created_date = parse_iso8601(created_date_str)
95
+ if created_date:
96
+ created_date_formatted = created_date.strftime("%Y-%m-%d %H:%M:%S")
97
+ else:
98
+ created_date_formatted = "Unknown"
99
+
100
+ with valid_assets_found.get_lock():
101
+ valid_assets_found.value += 1
102
+ await send_to_discord(session, asset_id, name, creator_id, creator_name, creator_type, asset_type, created_date_formatted)
103
+ except (aiohttp.ClientError, ConnectionError):
104
+ pass
105
 
106
  def parse_iso8601(date_str):
107
  try:
 
126
  return ids_batch
127
 
128
  async def run_scanner_instance(digit):
129
+ while True:
130
+ try:
131
+ async with aiohttp.ClientSession() as session:
132
+ batch = generate_ids_batch(digit)
133
+ await check_asset_batch(session, batch)
134
+ except (aiohttp.ClientError, ConnectionError):
135
+ continue
136
 
137
  async def print_status_periodically():
138
  while True: