Browse Source

视频标题加符号及表情

wangkun 2 years ago
parent
commit
f4a6b593a6
3 changed files with 45 additions and 30 deletions
  1. 10 5
      main/demo.py
  2. 28 23
      main/hour_list.py
  3. 7 2
      main/person_list.py

+ 10 - 5
main/demo.py

@@ -345,12 +345,17 @@ class Demo:
             if char_sheet[i][1] is not None:
                 char_list.append(char_sheet[i][1])
 
-        title = "今天我们要搬家了,哈哈哈"
+        befor_video_title = "今天我们要搬家了,哈哈哈"
         expression = random.choice(expression_list)
-        title_list = [expression+title, title+expression]
-        update_title = random.choice(title_list)+random.choice(char_list)
-        print(f"原标题:{title}")
-        print(f"加表情后的标题:{update_title}")
+        expression_title_list = [expression + befor_video_title, befor_video_title + expression]
+        title_list1 = random.choice(expression_title_list)
+        title_list2 = befor_video_title + random.choice(char_list)
+        title_list3 = befor_video_title.replace(",", random.choice(expression_list)).replace(",", random.choice(
+            expression_list))
+        title_list4 = [title_list1, title_list2, title_list3]
+        video_title = random.choice(title_list4)
+        print(f"原标题:{befor_video_title}")
+        print(f"加表情后的标题:{video_title}")
 
 
 if __name__ == "__main__":

+ 28 - 23
main/hour_list.py

@@ -8,6 +8,7 @@ import sys
 import time
 import requests
 import urllib3
+
 sys.path.append(os.getcwd())
 from main.common import Common
 from main.feishu_lib import Feishu
@@ -17,7 +18,6 @@ proxies = {"http": None, "https": None}
 
 
 class HourList:
-
     # 配置微信
     time.sleep(1)
     wechat_sheet = Feishu.get_values_batch("hour", "xiaoniangao", "dzcWHw")
@@ -95,7 +95,7 @@ class HourList:
                         # 分享量
                         if int(d_share_cnt) >= 0:
                             # 发布时间 <= 10 天
-                            if int(time.time()) - int(d_send_time)/1000 <= 864000:
+                            if int(time.time()) - int(d_send_time) / 1000 <= 864000:
                                 return True
                             else:
                                 return False
@@ -119,7 +119,7 @@ class HourList:
             time.sleep(1)
             Feishu.insert_columns(log_type, "xiaoniangao", "ba0da4", "COLUMNS", 11, 14)
             time.sleep(1)
-            Feishu.update_values(log_type, "xiaoniangao", "ba0da4",  "L1:N2", values)
+            Feishu.update_values(log_type, "xiaoniangao", "ba0da4", "L1:N2", values)
             time.sleep(1)
             Feishu.merge_cells(log_type, "xiaoniangao", "ba0da4", "L1:N1")
             Common.logger(log_type).info("插入今天日期成功")
@@ -226,8 +226,13 @@ class HourList:
                             .replace("?", "").replace('"', "").replace("<", "") \
                             .replace(">", "").replace("|", "").replace(" ", "")
                         expression = random.choice(expression_list)
-                        title_list = [expression + befor_video_title, befor_video_title + expression]
-                        video_title = random.choice(title_list) + random.choice(char_list)
+                        expression_title_list = [expression + befor_video_title, befor_video_title + expression]
+                        title_list1 = random.choice(expression_title_list)
+                        title_list2 = befor_video_title + random.choice(char_list)
+                        title_list3 = befor_video_title.replace(
+                            ",", random.choice(expression_list)).replace(",", random.choice(expression_list))
+                        title_list4 = [title_list1, title_list2, title_list3]
+                        video_title = random.choice(title_list4)
                     else:
                         video_title = 0
 
@@ -387,8 +392,8 @@ class HourList:
             if len(update_hour_sheet) == 2:
                 Common.logger(log_type).info("当前工作表无数据")
             else:
-                for i in range(2, len(update_hour_sheet)+1):
-                    Common.logger(log_type).info("更新第:{}行视频信息", i+1)
+                for i in range(2, len(update_hour_sheet) + 1):
+                    Common.logger(log_type).info("更新第:{}行视频信息", i + 1)
 
                     # 略过空行
                     if update_hour_sheet[i][0] is None \
@@ -499,7 +504,7 @@ class HourList:
                                 time.sleep(1)
                                 Feishu.update_values(
                                     log_type, "xiaoniangao", "ba0da4",
-                                    "L" + str(i+1) + ":" + "L" + str(i+1), [[values]])
+                                    "L" + str(i + 1) + ":" + "L" + str(i + 1), [[values]])
                                 Common.logger(log_type).info("10:00数据更新成功:{}", values)
 
                             elif upload_data == today and update_hour.hour == 15 and int(upload_hour) <= 10:
@@ -520,7 +525,7 @@ class HourList:
                                 time.sleep(1)
                                 Feishu.update_values(
                                     log_type, "xiaoniangao", "ba0da4",
-                                    "M" + str(i+1) + ":" + "M" + str(i+1), [[values]])
+                                    "M" + str(i + 1) + ":" + "M" + str(i + 1), [[values]])
                                 Common.logger(log_type).info("15:00数据更新成功:{}", values)
 
                             elif upload_data == today and update_hour.hour == 15 and 10 < int(upload_hour) <= 15:
@@ -535,7 +540,7 @@ class HourList:
                                 time.sleep(1)
                                 Feishu.update_values(
                                     log_type, "xiaoniangao", "ba0da4",
-                                    "M" + str(i+1) + ":" + "M" + str(i+1), [[values]])
+                                    "M" + str(i + 1) + ":" + "M" + str(i + 1), [[values]])
                                 Common.logger(log_type).info("15:00数据更新成功:{}", values)
 
                             elif upload_data == today and update_hour.hour == 20 and int(upload_hour) <= 10:
@@ -563,7 +568,7 @@ class HourList:
                                 time.sleep(1)
                                 Feishu.update_values(
                                     log_type, "xiaoniangao", "ba0da4",
-                                    "N" + str(i+1) + ":" + "N" + str(i+1), [[values]])
+                                    "N" + str(i + 1) + ":" + "N" + str(i + 1), [[values]])
                                 Common.logger(log_type).info("20:00数据更新成功:{}", values)
 
                             elif upload_data == today and update_hour.hour == 20 and 10 < int(upload_hour) <= 15:
@@ -584,7 +589,7 @@ class HourList:
                                 time.sleep(1)
                                 Feishu.update_values(
                                     log_type, "xiaoniangao", "ba0da4",
-                                    "N" + str(i+1) + ":" + "N" + str(i+1), [[values]])
+                                    "N" + str(i + 1) + ":" + "N" + str(i + 1), [[values]])
                                 Common.logger(log_type).info("20:00数据更新成功:{}", values)
 
                             elif upload_data == today and update_hour.hour == 20 and 15 < int(upload_hour) <= 20:
@@ -599,10 +604,10 @@ class HourList:
                                 time.sleep(1)
                                 Feishu.update_values(
                                     log_type, "xiaoniangao", "ba0da4",
-                                    "N" + str(i+1) + ":" + "N" + str(i+1), [[values]])
+                                    "N" + str(i + 1) + ":" + "N" + str(i + 1), [[values]])
                                 Common.logger(log_type).info("20:00数据更新成功:{}", values)
 
-                            elif (upload_data == yesterday or upload_data == before_yesterday)\
+                            elif (upload_data == yesterday or upload_data == before_yesterday) \
                                     and update_hour.hour == 10:
                                 Common.logger(log_type).info("满足条件: 抓取时间小于今天 and 当前时间:10点")
 
@@ -615,10 +620,10 @@ class HourList:
                                 time.sleep(1)
                                 Feishu.update_values(
                                     log_type, "xiaoniangao", "ba0da4",
-                                    "L" + str(i+1) + ":" + "L" + str(i+1), [[values]])
+                                    "L" + str(i + 1) + ":" + "L" + str(i + 1), [[values]])
                                 Common.logger(log_type).info("10:00数据更新成功:{}", values)
 
-                            elif (upload_data == yesterday or upload_data == before_yesterday)\
+                            elif (upload_data == yesterday or upload_data == before_yesterday) \
                                     and update_hour.hour == 15:
                                 Common.logger(log_type).info("满足条件: 抓取时间小于今天 and 当前时间:15点")
 
@@ -637,10 +642,10 @@ class HourList:
                                 time.sleep(1)
                                 Feishu.update_values(
                                     log_type, "xiaoniangao", "ba0da4",
-                                    "M" + str(i+1) + ":" + "M" + str(i+1), [[values]])
+                                    "M" + str(i + 1) + ":" + "M" + str(i + 1), [[values]])
                                 Common.logger(log_type).info("15:00数据更新成功:{}", values)
 
-                            elif (upload_data == yesterday or upload_data == before_yesterday)\
+                            elif (upload_data == yesterday or upload_data == before_yesterday) \
                                     and update_hour.hour == 20:
                                 Common.logger(log_type).info("满足条件: 抓取时间小于今天 and 当前时间:20点")
 
@@ -666,7 +671,7 @@ class HourList:
                                 time.sleep(1)
                                 Feishu.update_values(
                                     log_type, "xiaoniangao", "ba0da4",
-                                    "N" + str(i+1) + ":" + "N" + str(i+1), [[values]])
+                                    "N" + str(i + 1) + ":" + "N" + str(i + 1), [[values]])
                                 Common.logger(log_type).info("20:00数据更新成功:{}", values)
 
                         except Exception as e:
@@ -692,8 +697,8 @@ class HourList:
             if len(download_hour_sheet) == 2:
                 Common.logger(log_type).info("当前工作表无数据")
             else:
-                for i in range(2, len(download_hour_sheet)+1):
-                    Common.logger(log_type).info("分析第:{}行视频信息是否符合下载规则", i+1)
+                for i in range(2, len(download_hour_sheet) + 1):
+                    Common.logger(log_type).info("分析第:{}行视频信息是否符合下载规则", i + 1)
 
                     # 略过空行
                     if download_hour_sheet[i][0] is None \
@@ -1044,7 +1049,7 @@ class HourList:
                                            hour_video_comment_cnt,
                                            hour_video_like_cnt,
                                            hour_video_share_cnt,
-                                           int(hour_video_duration)/1000,
+                                           int(hour_video_duration) / 1000,
                                            hour_video_resolution,
                                            time.strftime("%Y-%m-%d %H:%M:%S",
                                                          time.localtime(int(hour_video_send_time) / 1000)),
@@ -1070,7 +1075,7 @@ class HourList:
                                            p_id,
                                            p_mid,
                                            hour_user_name,
-                                           int(hour_video_duration)/1000,
+                                           int(hour_video_duration) / 1000,
                                            time.strftime("%Y/%m/%d %H:%M:%S",
                                                          time.localtime(int(hour_video_send_time) / 1000)),
                                            hour_play_cnt]]

+ 7 - 2
main/person_list.py

@@ -368,8 +368,13 @@ class Person:
                     .replace("?", "").replace('"', "").replace("<", "") \
                     .replace(">", "").replace("|", "").replace(" ", "")
                 expression = random.choice(expression_list)
-                title_list = [expression + befor_video_title, befor_video_title + expression]
-                video_title = random.choice(title_list) + random.choice(char_list)
+                expression_title_list = [expression + befor_video_title, befor_video_title + expression]
+                title_list1 = random.choice(expression_title_list)
+                title_list2 = befor_video_title + random.choice(char_list)
+                title_list3 = befor_video_title.replace(
+                    ",", random.choice(expression_list)).replace(",", random.choice(expression_list))
+                title_list4 = [title_list1, title_list2, title_list3]
+                video_title = random.choice(title_list4)
 
                 # 用户名
                 user_name = feeds[i]["album_user"]["nick"].strip().replace("\n", "") \