Explorar el Código

v0.3
upload multi articles

罗俊辉 hace 11 meses
padre
commit
6d50887206
Se han modificado 2 ficheros con 65 adiciones y 52 borrados
  1. 63 52
      applications/upload.py
  2. 2 0
      test/upload_dev.py

+ 63 - 52
applications/upload.py

@@ -8,12 +8,71 @@ import requests
 from uuid import uuid4
 
 
-def auto_upload_aigc(title, text, img_list):
+def process_obj(obj):
     """
-    auto publish
+    title, text, img_list, group_id
     :return:
     """
     group_id = str(uuid4()).replace("-", "")
+    title = obj['title']
+    text = obj['text']
+    img_list = obj['img_list']
+    temp = [
+        {
+            "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
+        }
+    ]
+    return temp
+
+
+def auto_upload_aigc(task_name, obj_list):
+    """
+    auto publish
+    :return:
+    """
     url = "http://aigc-api.cybertogether.net/aigc/crawler/plan/save"
 
     payload = json.dumps({
@@ -28,58 +87,11 @@ def auto_upload_aigc(title, text, img_list):
             "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
-                    }
-                ]
+                process_obj(obj) for obj in obj_list
             ],
             "inputSourceGroups": [],
             "modePublishTime": [],
-            "name": title,
+            "name": task_name,
             "frequencyType": 3,
             "planType": 2
         },
@@ -106,7 +118,6 @@ def auto_upload_aigc(title, text, img_list):
         '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)
     return response.json()
 
 

La diferencia del archivo ha sido suprimido porque es demasiado grande
+ 2 - 0
test/upload_dev.py


Algunos archivos no se mostraron porque demasiados archivos cambiaron en este cambio