|
@@ -8,77 +8,102 @@ from applications.functions.common import request_for_info, create_gzh_path
|
|
|
from applications.functions.log import logging
|
|
|
|
|
|
|
|
|
+async def return_info(video_id, kimi_title, trace_id, mysql_client, index):
|
|
|
+ """
|
|
|
+
|
|
|
+ :param index:
|
|
|
+ :param mysql_client:
|
|
|
+ :param trace_id:
|
|
|
+ :param kimi_title:
|
|
|
+ :param video_id:
|
|
|
+ :return:
|
|
|
+ """
|
|
|
+ response = request_for_info(video_id)
|
|
|
+ productionCover = response['data'][0]['shareImgPath']
|
|
|
+ productionName = kimi_title
|
|
|
+ videoUrl = response['data'][0]['videoPath']
|
|
|
+ user_id = response['data'][0]['user']['uid']
|
|
|
+ programAvatar = "https://rescdn.yishihui.com/0temp/lehuo.png"
|
|
|
+ programId = "wxe8f8f0e23cecad0f"
|
|
|
+ programName = "票圈乐活"
|
|
|
+ source = "Web"
|
|
|
+ root_share_id, productionPath = create_gzh_path(video_id=video_id, shared_uid=user_id)
|
|
|
+ logging(
|
|
|
+ code="1002",
|
|
|
+ info="root_share_id --{}, productionPath -- {}".format(root_share_id, productionPath),
|
|
|
+ function="process",
|
|
|
+ trace_id=trace_id
|
|
|
+ )
|
|
|
+ result = {
|
|
|
+ "productionCover": productionCover,
|
|
|
+ "productionName": productionName,
|
|
|
+ "programAvatar": programAvatar,
|
|
|
+ "programId": programId,
|
|
|
+ "programName": programName,
|
|
|
+ "source": source,
|
|
|
+ "rootShareId": root_share_id,
|
|
|
+ "productionPath": productionPath,
|
|
|
+ "videoUrl": videoUrl
|
|
|
+ }
|
|
|
+ update_result_sql = f"""
|
|
|
+ UPDATE long_articles_video_dev
|
|
|
+ SET
|
|
|
+ result{index} = '{json.dumps(result, ensure_ascii=False)}',
|
|
|
+ success = 1
|
|
|
+ WHERE
|
|
|
+ trace_id = '{trace_id}'
|
|
|
+ """
|
|
|
+ await mysql_client.async_insert(update_result_sql)
|
|
|
+ logging(
|
|
|
+ code="2000",
|
|
|
+ info="统计 root_share_id && video_id",
|
|
|
+ function="process",
|
|
|
+ trace_id=trace_id,
|
|
|
+ data={
|
|
|
+ "rootShareId": root_share_id,
|
|
|
+ "videoId": video_id
|
|
|
+ }
|
|
|
+ )
|
|
|
+ return result
|
|
|
+
|
|
|
+
|
|
|
async def recall_videos(trace_id, mysql_client):
|
|
|
"""
|
|
|
从 mysql 读取数据
|
|
|
:param trace_id: 唯一 id
|
|
|
- :param mysql_client: mysql 服务
|
|
|
+ :param mysql_client: mysql 服务、
|
|
|
:return:
|
|
|
"""
|
|
|
select_sql = f"""
|
|
|
- SELECT recall_video_id1, kimi_title
|
|
|
- FROM long_articles_video
|
|
|
+ SELECT recall_video_id1,recall_video_id2, recall_video_id3, kimi_title
|
|
|
+ FROM long_articles_video_dev
|
|
|
WHERE trace_id = '{trace_id}';
|
|
|
"""
|
|
|
info_tuple = await mysql_client.async_select(select_sql)
|
|
|
- best_video_id, kimi_title = info_tuple[0]
|
|
|
- print(best_video_id)
|
|
|
- if best_video_id:
|
|
|
- logging(
|
|
|
- code="1002",
|
|
|
- info="best video_id --{}".format(best_video_id),
|
|
|
- function="process",
|
|
|
- trace_id=trace_id
|
|
|
- )
|
|
|
- print("best video id", best_video_id)
|
|
|
- response = request_for_info(best_video_id)
|
|
|
- productionCover = response['data'][0]['shareImgPath']
|
|
|
- productionName = kimi_title
|
|
|
- videoUrl = response['data'][0]['videoPath']
|
|
|
- user_id = response['data'][0]['user']['uid']
|
|
|
- programAvatar = "https://rescdn.yishihui.com/0temp/lehuo.png"
|
|
|
- programId = "wxe8f8f0e23cecad0f"
|
|
|
- programName = "票圈乐活"
|
|
|
- source = "Web"
|
|
|
- root_share_id, productionPath = create_gzh_path(video_id=best_video_id, shared_uid=user_id)
|
|
|
+ vid1, vid2, vid3, kimi_title = info_tuple[0]
|
|
|
+ vid_list = [vid1, vid2, vid3]
|
|
|
+ unEmptyList = [i for i in vid_list if i]
|
|
|
+ L = []
|
|
|
+ print(unEmptyList)
|
|
|
+ if unEmptyList:
|
|
|
logging(
|
|
|
code="1002",
|
|
|
- info="root_share_id --{}, productionPath -- {}".format(root_share_id, productionPath),
|
|
|
+ info="vid_list: {}".format(json.dumps(unEmptyList, ensure_ascii=False)),
|
|
|
function="process",
|
|
|
trace_id=trace_id
|
|
|
)
|
|
|
- result = {
|
|
|
- "productionCover": productionCover,
|
|
|
- "productionName": productionName,
|
|
|
- "programAvatar": programAvatar,
|
|
|
- "programId": programId,
|
|
|
- "programName": programName,
|
|
|
- "source": source,
|
|
|
- "rootShareId": root_share_id,
|
|
|
- "productionPath": productionPath,
|
|
|
- "videoUrl": videoUrl
|
|
|
- }
|
|
|
- update_result_sql = f"""
|
|
|
- UPDATE long_articles_video
|
|
|
- SET
|
|
|
- result1 = '{json.dumps(result, ensure_ascii=False)}',
|
|
|
- success = 1
|
|
|
- WHERE
|
|
|
- trace_id = '{trace_id}'
|
|
|
- """
|
|
|
- await mysql_client.async_insert(update_result_sql)
|
|
|
- logging(
|
|
|
- code="2000",
|
|
|
- info="统计 root_share_id && video_id",
|
|
|
- function="process",
|
|
|
- trace_id=trace_id,
|
|
|
- data={
|
|
|
- "rootShareId": root_share_id,
|
|
|
- "videoId": best_video_id
|
|
|
- }
|
|
|
- )
|
|
|
+ for index, best_video_id in enumerate(unEmptyList, 1):
|
|
|
+ temp = await return_info(
|
|
|
+ video_id=best_video_id,
|
|
|
+ kimi_title=kimi_title,
|
|
|
+ trace_id=trace_id,
|
|
|
+ mysql_client=mysql_client,
|
|
|
+ index=index
|
|
|
+ )
|
|
|
+ L.append(temp)
|
|
|
+
|
|
|
else:
|
|
|
- result = {
|
|
|
+ L = {
|
|
|
"traceId": trace_id,
|
|
|
"Message": "No Videos Found now, Please try again in one minute"
|
|
|
}
|
|
@@ -86,7 +111,7 @@ async def recall_videos(trace_id, mysql_client):
|
|
|
code="1002",
|
|
|
info="返回结果",
|
|
|
function="process",
|
|
|
- data=result,
|
|
|
+ data=L,
|
|
|
trace_id=trace_id
|
|
|
)
|
|
|
- return result
|
|
|
+ return L
|