罗俊辉 11 ヶ月 前
コミット
3563063fac

+ 0 - 129
applications/functions.py

@@ -4,9 +4,6 @@
 from datetime import datetime, timedelta
 
 import requests
-import json
-import oss2
-from uuid import uuid4
 
 
 def generate_daily_strings(start_date, end_date):
@@ -66,129 +63,3 @@ def get_text(video_id):
         headers=header
     )
     return response.json()
-
-
-def auto_upload_aigc():
-    """
-    auto publish
-    :return:
-    """
-    url = "http://aigc-api.cybertogether.net/aigc/crawler/plan/save"
-
-    payload = json.dumps({
-        "params": {
-            "contentFilters": [],
-            "accountFilters": [],
-            "filterAccountMatchMode": 1,
-            "filterContentMatchMode": 1,
-            "selectModeValues": [],
-            "imageSearchModeValues": [],
-            "contentModal": 3,
-            "analyze": {},
-            "crawlerComment": 0,
-            "inputGroup": [
-                [
-                    {
-                        "inputValue": [
-                            {
-                                "fileName": "pqzf.png",
-                                "ossKey": "upload/03bf695277827c2387133a1ac9290fd2.png",
-                                "type": "image/png",
-                                "size": 2978
-                            }
-                        ],
-                        "fieldName": "cover",
-                        "fieldType": 1,
-                        "groupId": "fa9557a13208975a893777188f9e4b28"
-                    },
-                    {
-                        "fieldName": "title",
-                        "fieldType": 0,
-                        "groupId": "fa9557a13208975a893777188f9e4b28",
-                        "inputValue": "412412412"
-                    },
-                    {
-                        "fieldName": "content",
-                        "fieldType": 0,
-                        "groupId": "fa9557a13208975a893777188f9e4b28",
-                        "inputValue": "12312442"
-                    },
-                    {
-                        "fieldName": "image",
-                        "fieldType": 1,
-                        "groupId": "fa9557a13208975a893777188f9e4b28",
-                        "inputValue": [
-                            {
-                                "fileName": "lehuo.png",
-                                "ossKey": "upload/4bf6db57ccd1629909e070833aab8878.png",
-                                "type": "image/png",
-                                "size": 5085
-                            }
-                        ]
-                    },
-                    {
-                        "fieldName": "video",
-                        "fieldType": 2,
-                        "groupId": "fa9557a13208975a893777188f9e4b28"
-                    },
-                    {
-                        "fieldName": "audio",
-                        "fieldType": 3,
-                        "groupId": "fa9557a13208975a893777188f9e4b28"
-                    },
-                    {
-                        "fieldName": "tag",
-                        "fieldType": 0,
-                        "groupId": "fa9557a13208975a893777188f9e4b28"
-                    }
-                ]
-            ],
-            "inputSourceGroups": [],
-            "modePublishTime": [],
-            "name": "junhui测试自动上传_by_python",
-            "frequencyType": 3,
-            "planType": 2
-        },
-        "baseInfo": {
-            "token": "af54cdc404c3464d896745df389b2dce",
-            "appType": 9,
-            "platform": "pc",
-            "appVersionCode": 1000,
-            "clientTimestamp": 1,
-            "fid": 1,
-            "loginUid": 1,
-            "pageSource": 1,
-            "requestId": 1,
-            "rid": 1,
-            "uid": 1
-        }
-    })
-    headers = {
-        'Accept': 'application/json',
-        'Accept-Language': 'en,zh;q=0.9,zh-CN;q=0.8',
-        'Content-Type': 'application/json',
-        'Origin': 'http://aigc-admin.cybertogether.net',
-        'Proxy-Connection': 'keep-alive',
-        'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/125.0.0.0 Safari/537.36'
-    }
-
-    response = requests.request("POST", url, headers=headers, data=payload)
-
-    print(response.text)
-
-
-def upload_to_oss(local_path):
-    """
-    上传到oss
-    :return:
-    """
-    oss_video_key = str(uuid4())
-    access_key_id = "LTAIP6x1l3DXfSxm"
-    access_key_secret = "KbTaM9ars4OX3PMS6Xm7rtxGr1FLon"
-    endpoint = "oss-cn-hangzhou.aliyuncs.com"
-    bucket_name = "art-pubbucket"
-    bucket = oss2.Bucket(
-        oss2.Auth(access_key_id, access_key_secret), endpoint, bucket_name
-    )
-    bucket.put_object_from_file(key=oss_video_key, filename=local_path)
-    return oss_video_key

+ 139 - 0
applications/upload.py

@@ -0,0 +1,139 @@
+"""
+@author: luojunhui
+"""
+import json
+import oss2
+
+import requests
+from uuid import uuid4
+
+
+def auto_upload_aigc(title, text, img_list):
+    """
+    auto publish
+    :return:
+    """
+    group_id = str(uuid4()).replace("-", "")
+    url = "http://aigc-api.cybertogether.net/aigc/crawler/plan/save"
+
+    payload = json.dumps({
+        "params": {
+            "contentFilters": [],
+            "accountFilters": [],
+            "filterAccountMatchMode": 1,
+            "filterContentMatchMode": 1,
+            "selectModeValues": [],
+            "imageSearchModeValues": [],
+            "contentModal": 3,
+            "analyze": {},
+            "crawlerComment": 0,
+            "inputGroup": [
+                [
+                    {
+                        "inputValue": [
+                            {
+                                "fileName": "pqzf.png",
+                                "ossKey": "upload/03bf695277827c2387133a1ac9290fd2.png",
+                                "type": "image/png",
+                                "size": 2978
+                            }
+                        ],
+                        "fieldName": "cover",
+                        "fieldType": 1,
+                        "groupId": group_id
+                    },
+                    {
+                        "fieldName": "title",
+                        "fieldType": 0,
+                        "groupId": group_id,
+                        "inputValue": title
+                    },
+                    {
+                        "fieldName": "content",
+                        "fieldType": 0,
+                        "groupId": group_id,
+                        "inputValue": text
+                    },
+                    {
+                        "fieldName": "image",
+                        "fieldType": 1,
+                        "groupId": group_id,
+                        "inputValue": img_list
+                    },
+                    {
+                        "fieldName": "video",
+                        "fieldType": 2,
+                        "groupId": group_id
+                    },
+                    {
+                        "fieldName": "audio",
+                        "fieldType": 3,
+                        "groupId": group_id
+                    },
+                    {
+                        "fieldName": "tag",
+                        "fieldType": 0,
+                        "groupId": group_id
+                    }
+                ]
+            ],
+            "inputSourceGroups": [],
+            "modePublishTime": [],
+            "name": title,
+            "frequencyType": 3,
+            "planType": 2
+        },
+        "baseInfo": {
+            "token": "af54cdc404c3464d896745df389b2dce",
+            "appType": 9,
+            "platform": "pc",
+            "appVersionCode": 1000,
+            "clientTimestamp": 1,
+            "fid": 1,
+            "loginUid": 1,
+            "pageSource": 1,
+            "requestId": 1,
+            "rid": 1,
+            "uid": 1
+        }
+    })
+    headers = {
+        'Accept': 'application/json',
+        'Accept-Language': 'en,zh;q=0.9,zh-CN;q=0.8',
+        'Content-Type': 'application/json',
+        'Origin': 'http://aigc-admin.cybertogether.net',
+        'Proxy-Connection': 'keep-alive',
+        'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/125.0.0.0 Safari/537.36'
+    }
+    response = requests.request("POST", url, headers=headers, data=payload)
+    print(response.text)
+
+
+def upload_to_oss(local_path):
+    """
+    上传到oss
+    :return:
+    """
+    oss_video_key = "upload/" + str(uuid4()) + ".png"
+    access_key_id = "LTAI5tCHXiNx4sUVPTSrk3zD"
+    access_key_secret = "BoTrog6kA2dsmp70VrReKC7ZQHjQ0F"
+    endpoint = "oss-ap-southeast-1.aliyuncs.com"
+    bucket_name = "aigc-admin"
+    bucket = oss2.Bucket(
+        oss2.Auth(access_key_id, access_key_secret), endpoint, bucket_name
+    )
+    bucket.put_object_from_file(key=oss_video_key, filename=local_path)
+    return oss_video_key
+
+
+def download_image(img_path, image_url):
+    """
+    下载视频
+    :param img_path:
+    :param image_url:
+    :return:
+    """
+    res = requests.get(image_url)
+    with open(img_path, "wb") as f:
+        f.write(res.content)
+    return img_path

+ 1 - 1
deal/__init__.py

@@ -1,5 +1,5 @@
 """
 @author: luojunhui
 """
-from .request_deal import RequestDeal
+from .videos_deal import RequestDeal
 from .db_deal import insert_text_mysql, get_text_by_id

+ 13 - 0
deal/publish_deal.py

@@ -0,0 +1,13 @@
+"""
+@author: luojunhui
+"""
+from applications.upload import *
+
+
+class PublishDeal(object):
+    """
+    自动发布接口处理
+    """
+    def __init__(self, params):
+        self.title = params['title']
+        self.text = params['text']

+ 0 - 0
deal/request_deal.py → deal/videos_deal.py


+ 3 - 0
deal/whisper_deal.py

@@ -0,0 +1,3 @@
+"""
+@author: luojunhui
+"""

+ 10 - 0
requirements.txt

@@ -0,0 +1,10 @@
+quart
+aiohttp
+aiomysql
+requests
+pymysql
+oss2
+lxml
+fake_useragent
+tqdm
+hypercorn

+ 11 - 0
routes/vta_routes.py

@@ -62,6 +62,17 @@ def VTARoutes(mysql_client):
             result = {"text": None}
         return jsonify(result)
 
+    @bp.route('/publish', methods=["POST"])
+    async def auto_publish():
+        """
+        auto publish article info to aigc system
+        :return:
+        """
+        res = {
+            "info": "this api is developing"
+        }
+        return jsonify(res)
+
     return bp