Quellcode durchsuchen

增加原标题

zhangyong vor 9 Monaten
Ursprung
Commit
7cf7d1f551

+ 2 - 2
common/sql_help.py

@@ -60,8 +60,8 @@ class sqlCollect():
 
 
     @classmethod
-    def insert_machine_making_data(cls, name: str, task_mark: str, channel_id: str, url: str, v_id: str, piaoquan_id: str, new_title: str, code: str, formatted_time):
-        insert_sql = f"""INSERT INTO machine_making_data (name, task_mark, channel, user, v_id, pq_uid, title, pq_vid, data_time) values ("{name}", "{task_mark}", "{channel_id}", "{url}", "{v_id}" , "{piaoquan_id}", "{new_title}", "{code}", "{formatted_time}")"""
+    def insert_machine_making_data(cls, name: str, task_mark: str, channel_id: str, url: str, v_id: str, piaoquan_id: str, new_title: str, code: str, formatted_time, old_title: str):
+        insert_sql = f"""INSERT INTO machine_making_data (name, task_mark, channel, user, v_id, pq_uid, title, pq_vid, data_time, old_title) values ("{name}", "{task_mark}", "{channel_id}", "{url}", "{v_id}" , "{piaoquan_id}", "{new_title}", "{code}", "{formatted_time}", "{old_title}")"""
         MysqlHelper.update_values(
             sql=insert_sql
         )

+ 8 - 1
data_channel/douyin.py

@@ -70,6 +70,13 @@ class DY:
                         digg_count = int(data[i].get('statistics').get('digg_count'))  # 点赞
                         # comment_count = int(data[i].get('statistics').get('comment_count'))  # 评论
                         share_count = int(data[i].get('statistics').get('share_count'))  # 转发
+                        old_title = data[i].get('desc', "").strip().replace("\n", "") \
+                            .replace("/", "").replace("\\", "").replace("\r", "") \
+                            .replace(":", "").replace("*", "").replace("?", "") \
+                            .replace("?", "").replace('"', "").replace("<", "") \
+                            .replace(">", "").replace("|", "").replace(" ", "") \
+                            .replace("&NBSP", "").replace(".", "。").replace(" ", "") \
+                            .replace("'", "").replace("#", "").replace("Merge", "")
                         if share_count < 500:
                             Common.logger("dy").info(
                                 f"任务:{task_mark},用户主页id:{url_id},视频id{video_id} ,分享:{share_count},点赞{digg_count}")
@@ -83,7 +90,7 @@ class DY:
                         duration = dataHelp.video_duration(video_url)
                         if int(duration) >= 45:
                             cover_url = data[i].get('video').get('cover').get('url_list')[0]  # 视频封面
-                            all_data = {"video_id": video_id, "cover": cover_url, "video_url": video_url, "rule": video_percent}
+                            all_data = {"video_id": video_id, "cover": cover_url, "video_url": video_url, "rule": video_percent, "old_title": old_title}
                             list.append(all_data)
                             if len(list) == int(number):
                                 Common.logger("log").info(f"获取抖音视频总数:{len(list)}\n")

+ 2 - 1
data_channel/kuaishou.py

@@ -75,6 +75,7 @@ class KS:
                     video_id = feeds[i].get("photo", {}).get("id", "")
                     status = sqlCollect.is_used(task_mark, video_id, mark, channel_id)
                     if status:
+                        old_title = feeds[i].get("photo", {}).get("caption")
                         cover_url = feeds[i].get('photo', {}).get('coverUrl', "")
                         video_url = feeds[i].get('photo', {}).get('photoUrl', "")
                         # viewCount = int(feeds[i].get('photo', {}).get('viewCount', 0))
@@ -84,7 +85,7 @@ class KS:
                             continue
                         duration = dataHelp.video_duration(video_url)
                         if int(duration) >= 45:
-                            all_data = {"video_id": video_id, "cover": cover_url, "video_url": video_url, "rule": realLikeCount}
+                            all_data = {"video_id": video_id, "cover": cover_url, "video_url": video_url, "rule": realLikeCount, "old_title": old_title}
                             list.append(all_data)
                             if len(list) == int(number):
                                 Common.logger("log").info(f"获取快手视频总数:{len(list)}\n")

+ 4 - 2
data_channel/piaoquan.py

@@ -87,7 +87,7 @@ class PQ:
                     new_title = random.choice(titles)
                 video_url = data["content"]["transedVideoPath"]
                 cover = data["content"]["coverImgPath"]
-                all_data = {"video_id": video_id, "title": new_title, "cover": cover, "video_url": video_url, "rule": "无"}
+                all_data = {"video_id": video_id, "title": new_title, "cover": cover, "video_url": video_url, "rule": "无", "old_title": data["content"]["title"]}
                 list.append(all_data)
                 return list
             return list
@@ -120,7 +120,9 @@ class PQ:
                 if status:
                     cover = url["coverImgPath"]
                     video_url = url["transedVideoPath"]
-                    all_data = {"video_id": video_id, "cover": cover, "video_url": video_url, "rule": "无"}
+                    old_title = url["title"]
+
+                    all_data = {"video_id": video_id, "cover": cover, "video_url": video_url, "rule": "无", "old_title": old_title}
                     list.append(all_data)
                     if len(list) == int(number):
                         Common.logger("log").info(f"获取视频总数:{len(list)}\n")

+ 2 - 1
data_channel/shipinhao.py

@@ -98,6 +98,7 @@ class SPH:
                             video_url = video_obj.get('DownloadAddress')
                             share_cnt = int(obj['forward_count'])  # 分享
                             like_cnt = int(obj['like_count'])  # 点赞
+                            old_title = video_obj.get('title').split("\n")[0].split("#")[0]
                             if share_cnt < 500:
                                 Common.logger("sph").info(
                                     f"任务:{task_mark},用户主页id:{url},视频id{objectId} ,分享:{share_cnt},点赞:{like_cnt}")
@@ -111,7 +112,7 @@ class SPH:
                             duration = dataHelp.video_duration(video_url)
                             if int(duration) >= 45:
                                 cover = video_obj.get('thumb_url')
-                                all_data = {"video_id": objectId, "cover": cover, "video_url": video_url, "rule": video_percent}
+                                all_data = {"video_id": objectId, "cover": cover, "video_url": video_url, "rule": video_percent, "old_title": old_title}
                                 list.append(all_data)
                                 if len(list) == int(number):
                                     Common.logger("log").info(f"获取视频号视频总数:{len(list)}\n")

+ 4 - 2
video_rewriting/video_prep.py

@@ -123,6 +123,8 @@ class getVideo:
                         cover = video["cover"]
                         video_url = video["video_url"]
                         rule = video['rule']
+                        old_title = video['old_title']
+
                         time.sleep(1)
                         pw_random_id = cls.random_id()
                         if channel_id == "票圈":
@@ -202,8 +204,8 @@ class getVideo:
                                 sqlCollect.insert_task(task_mark, v_id, mark, channel_id)  # 插入数据库
                                 current_time = datetime.now()
                                 formatted_time = current_time.strftime("%Y-%m-%d %H:%M:%S")
-                                sqlCollect.insert_machine_making_data(name, task_mark, channel_id, url, v_id, piaoquan_id, new_title, code, formatted_time)
-                                values = [[name, task_mark, channel_id, url, v_id, piaoquan_id, new_title, str(code), formatted_time, str(rule)]]
+                                sqlCollect.insert_machine_making_data(name, task_mark, channel_id, url, v_id, piaoquan_id, new_title, code, formatted_time, old_title)
+                                values = [[name, task_mark, channel_id, url, v_id, piaoquan_id, old_title, new_title, str(code), formatted_time, str(rule)]]
                                 # 使用锁保护表格插入操作
                                 with lock:
                                     if name == "王雪珂":