| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143 |
- from typing import Optional, Dict, List
- from app.infra.shared import AsyncHttpClient
- async def fetch_piaoquan_video_list_detail(video_list: List[int]) -> Optional[Dict]:
- """async fetch piaoquan video detail"""
- url = "https://longvideoapi.piaoquantv.com/longvideoapi/openapi/video/batchSelectVideoInfo"
- data = {"videoIdList": video_list}
- header = {
- "Content-Type": "application/json",
- }
- async with AsyncHttpClient() as client:
- response = await client.post(url, json=data, headers=header)
- return response
- async def change_video_audit_status(video_id: int, status_code: int = 5) -> Dict:
- url = "https://admin.piaoquantv.com/manager/video/audit/v2/updateAuditStatus"
- payload = "videoId={}&auditStatus={}&updateReasonJson=&rejectReasonJson=%5B%7B%22reason%22%3A%22%E9%95%BF%E6%96%87%E8%87%AA%E5%8A%A8%E4%B8%8B%E6%9E%B6%22%2C%22reasonId%22%3A-1%7D%5D&adminUid=206".format(
- video_id, status_code
- )
- headers = {
- "accept": "application/json",
- "accept-language": "en,zh;q=0.9,zh-CN;q=0.8",
- "Content-Type": "application/json",
- "cookie": "",
- "origin": "https://admin.piaoquantv.com",
- "priority": "u=1, i",
- "sec-ch-ua": '"Not/A)Brand";v="8", "Chromium";v="126", "Google Chrome";v="126"',
- "sec-ch-ua-mobile": "?0",
- "sec-ch-ua-platform": '"macOS"',
- "sec-fetch-dest": "empty",
- "sec-fetch-mode": "cors",
- "sec-fetch-site": "same-origin",
- "user-agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36",
- }
- async with AsyncHttpClient() as client:
- response = await client.post(url, data=payload, headers=headers)
- return response
- async def publish_video_to_piaoquan(oss_path: str, uid: str, title: str) -> Dict:
- url = "https://vlogapi.piaoquantv.com/longvideoapi/crawler/video/send"
- headers = {
- "User-Agent": "PQSpeed/486 CFNetwork/1410.1 Darwin/22.6.0",
- "cookie": "JSESSIONID=4DEA2B5173BB9A9E82DB772C0ACDBC9F; JSESSIONID=D02C334150025222A0B824A98B539B78",
- "referer": "http://appspeed.piaoquantv.com",
- "token": "524a8bc871dbb0f4d4717895083172ab37c02d2f",
- "accept-language": "zh-CN,zh-Hans;q=0.9",
- "Content-Type": "application/json",
- }
- payload = {
- "deviceToken": "9ef064f2f7869b3fd67d6141f8a899175dddc91240971172f1f2a662ef891408",
- "fileExtensions": "MP4",
- "loginUid": uid,
- "networkType": "Wi-Fi",
- "platform": "iOS",
- "requestId": "fb972cbd4f390afcfd3da1869cd7d001",
- "sessionId": "362290597725ce1fa870d7be4f46dcc2",
- "subSessionId": "362290597725ce1fa870d7be4f46dcc2",
- "title": title,
- "token": "524a8bc871dbb0f4d4717895083172ab37c02d2f",
- "uid": uid,
- "versionCode": "486",
- "versionName": "3.4.12",
- "videoFromScene": "1",
- "videoPath": oss_path,
- "viewStatus": "1",
- "appType": 888888,
- "repeatStatus": 1,
- }
- async with AsyncHttpClient() as client:
- response = await client.post(url, data=payload, headers=headers)
- return response
- class DecodeServer:
- base_url: str = "http://supply-content-deconstruction-api.piaoquantv.com"
- # 创建解构任务
- async def create_decode_task(self, data: Dict) -> Dict:
- """
- scene: 业务场景:0 选题; 1 创作; 2 制作;
- content_type: 内容类型: 1 长文; 2 图文; 3 视频;
- content:
- channel_content_id:
- video_url:
- images: [ image_url_1, image_url_2, ...]
- body_text: 长文内容
- title: 文章标题
- channel_account_id: 作者 id
- channel_account_name: 作者名称
- output_type: {
- }
- """
- url = f"{self.base_url}/api/v1/content/tasks/decode"
- headers = {
- "User-Agent": "PQSpeed/486 CFNetwork/1410.1 Darwin/22.6.0",
- "Content-Type": "application/json",
- }
- async with AsyncHttpClient() as client:
- response = await client.post(url, json=data, headers=headers)
- return response
- # 获取解构结果
- async def fetch_decode_result(self, task_id: str) -> Dict:
- """
- INPUT: TaskId
- OUTPUT: Dict
- {
- code: 0 | 404(task not exist),
- msg: 'ok',
- data: {
- "taskId": "123",
- "status": 3, 0 PENDING, 1 RUNNING, 2 SUCCESS, 3 FAILED
- "result": None | JSON,
- "reason": "" | 失败原因,
- "url": {
- "pointUrl": "", 选题点结构结果页地址(仅解构任务有
- "weightUrl": "", 权重页地址(解构聚类都有)
- "patternUrl": "" 选题点聚类结果页地址(仅聚类任务有)
- }
- },
- }
- """
- url = f"{self.base_url}/api/v1/content/tasks/{task_id}"
- headers = {
- "User-Agent": "PQSpeed/486 CFNetwork/1410.1 Darwin/22.6.0",
- "Content-Type": "application/json",
- }
- async with AsyncHttpClient() as client:
- response = await client.get(url, headers=headers)
- return response
|