liqian 3 年 前
コミット
1dac8ecb21
1 ファイル変更10 行追加6 行削除
  1. 10 6
      utils.py

+ 10 - 6
utils.py

@@ -109,17 +109,21 @@ def update_video_w_h_rate(video_id, key_name):
     :return: None
     """
     # 获取数据
-    sql = "SELECT id, width/height w_h_rate " \
-          "FROM longvideo.wx_video " \
-          "WHERE width/height > 1 " \
-          "AND id = {};".format(video_id)
+    sql = "SELECT id, width, height, rotate FROM longvideo.wx_video WHERE id = {};".format(video_id)
     mysql_helper = MysqlHelper()
     data = mysql_helper.get_data(sql=sql)
     if len(data) == 0:
         return
     # 更新到redis
-    w_h_rate = float(data[0][1])
-    info_data = {int(video_id): w_h_rate}
+    width, height, rotate = int(data[0][1]), int(data[0][2]), int(data[0][3])
+    if rotate in (90, 270):
+        w_h_rate = height / width
+    else:
+        w_h_rate = width / height
+    if w_h_rate > 1:
+        info_data = {int(video_id): w_h_rate}
+    else:
+        return
     redis_helper = RedisHelper()
     # 写入新数据
     if len(info_data) > 0: