rpa
This commit is contained in:
parent
c94889e189
commit
09c55c5cbb
|
|
@ -172,12 +172,22 @@ async def get_promotion_list_text(page: Page, webcast_id: str, max_duration: int
|
|||
product_id, product_img, product_name, text = await get_product_data(page, product_name_js,
|
||||
promotion_list_js)
|
||||
|
||||
# page.on("response", handle_response)
|
||||
page.on("response", partial(handle_response, product_name))
|
||||
|
||||
current_time = int(time.time() * 1000) # Current time in milliseconds
|
||||
|
||||
if text.__contains__(EXPLAINING):
|
||||
current_product_id, current_product_img, current_product_name, last_live_time, start_time = await do_explaining(
|
||||
current_product_id, current_product_img, current_product_name, current_time, last_live_time,
|
||||
product_id, product_img, product_name, start_time)
|
||||
current_product_id,
|
||||
current_product_img,
|
||||
current_product_name,
|
||||
current_time,
|
||||
last_live_time,
|
||||
product_id,
|
||||
product_img,
|
||||
product_name,
|
||||
start_time)
|
||||
|
||||
elif start_time is not None and last_live_time is not None:
|
||||
# Check if text does not contain "讲解中" for >10 seconds
|
||||
|
|
@ -194,8 +204,7 @@ async def get_promotion_list_text(page: Page, webcast_id: str, max_duration: int
|
|||
duration,
|
||||
last_live_time,
|
||||
product_sessions,
|
||||
start_time,
|
||||
page)
|
||||
start_time)
|
||||
|
||||
await asyncio.sleep(3) # Poll every 3 seconds
|
||||
# except Exception as e:
|
||||
|
|
@ -213,8 +222,7 @@ async def get_promotion_list_text(page: Page, webcast_id: str, max_duration: int
|
|||
current_product_name,
|
||||
last_live_time,
|
||||
product_sessions,
|
||||
start_time,
|
||||
page)
|
||||
start_time)
|
||||
|
||||
return product_sessions
|
||||
|
||||
|
|
@ -224,8 +232,7 @@ async def do_finalized_product(current_product_id:str,
|
|||
current_product_name: str,
|
||||
last_live_time: int,
|
||||
product_sessions: list[ProductSession],
|
||||
start_time:int,
|
||||
page:Page):
|
||||
start_time: int):
|
||||
duration = last_live_time - start_time
|
||||
if duration > 0:
|
||||
product_sessions.append(ProductSession(
|
||||
|
|
@ -236,8 +243,7 @@ async def do_finalized_product(current_product_id:str,
|
|||
product_id=current_product_id,
|
||||
product_img=current_product_img
|
||||
))
|
||||
# page.on("response", handle_response)
|
||||
page.on("response", partial(handle_response, current_product_name))
|
||||
|
||||
logger.info(
|
||||
f"****** Finalized product session - Start: {start_time}, End: {last_live_time}, Duration: {duration}ms, Product: {current_product_name}")
|
||||
|
||||
|
|
@ -282,8 +288,7 @@ async def do_ended_product(current_product_id:str,
|
|||
duration: int,
|
||||
last_live_time: int,
|
||||
product_sessions: list[ProductSession],
|
||||
start_time:int,
|
||||
page:Page):
|
||||
start_time: int):
|
||||
product_sessions.append(ProductSession(
|
||||
start_time=start_time,
|
||||
end_time=last_live_time,
|
||||
|
|
@ -292,8 +297,6 @@ async def do_ended_product(current_product_id:str,
|
|||
product_id=current_product_id,
|
||||
product_img=current_product_img
|
||||
))
|
||||
# page.on("response", handle_response)
|
||||
page.on("response", partial(handle_response, current_product_name))
|
||||
|
||||
logger.info(
|
||||
f"****** Ended product session - Start: {start_time}, End: {last_live_time}, Duration: {duration}ms, Product: {current_product_name}, ID: {current_product_id}")
|
||||
|
|
@ -402,6 +405,7 @@ def submit_job(data: LiveStreamProductWatchRequest):
|
|||
call = rpa_run.spawn(data)
|
||||
return call.object_id
|
||||
|
||||
|
||||
########################################rpa_image start######################################################
|
||||
with rpa_image.imports():
|
||||
@app.function(timeout=8 * 60 * 60, volumes={"/data": rpa_vol})
|
||||
|
|
@ -461,13 +465,14 @@ with rpa_image.imports():
|
|||
|
||||
return result.dict() # Return as dict for JSON compatibility
|
||||
|
||||
|
||||
@app.local_entrypoint()
|
||||
async def local_run():
|
||||
logger.info("Starting local RPA test")
|
||||
# 312898731614
|
||||
# webcast_ids = ["36861064178"]
|
||||
# webcast_ids = ["36861064178"]
|
||||
webcast_id = "57057596185"
|
||||
webcast_id = "206240580433"
|
||||
|
||||
data: LiveStreamProductWatchRequest = LiveStreamProductWatchRequest(live_id=webcast_id)
|
||||
# TODO other info
|
||||
|
|
|
|||
Loading…
Reference in New Issue