Your Name 3 years ago
parent
commit
604b732619
1 changed files with 6 additions and 1 deletions
  1. 6 1
      process_webp_from_db.py

+ 6 - 1
process_webp_from_db.py

@@ -5,13 +5,18 @@ import os
 
 
 
 
 db = dataset.connect('mysql://hhh7796hhh:lYmWsu^ujcA1@hhh-v57.cmab1ctkglka.ap-northeast-2.rds.amazonaws.com:3306/xoops?charset=utf8mb4')
 db = dataset.connect('mysql://hhh7796hhh:lYmWsu^ujcA1@hhh-v57.cmab1ctkglka.ap-northeast-2.rds.amazonaws.com:3306/xoops?charset=utf8mb4')
-
+db2 = dataset.connect('mysql://hhh7796hhh:lYmWsu^ujcA1@hhh-v57.cmab1ctkglka.ap-northeast-2.rds.amazonaws.com:3306/xoops?charset=utf8mb4')
+table=db2['_had']
 cursor=db.query('SELECT adid,adlogo_mobile FROM xoops._had where length(adlogo_mobile_webp)<5  order by adid desc limit 100;')
 cursor=db.query('SELECT adid,adlogo_mobile FROM xoops._had where length(adlogo_mobile_webp)<5  order by adid desc limit 100;')
 for c in cursor:
 for c in cursor:
 #    print(c['adid'])
 #    print(c['adid'])
+    adid=c['adid']
     mobile_h=c['adlogo_mobile'].replace('https://images.hhh.com.tw/','/home/hhh-images/')
     mobile_h=c['adlogo_mobile'].replace('https://images.hhh.com.tw/','/home/hhh-images/')
     print(mobile_h)
     print(mobile_h)
     print(os.path.exists(mobile_h))
     print(os.path.exists(mobile_h))
     cmd='cwebp '+mobile_h+" -o "+mobile_h+".webp"
     cmd='cwebp '+mobile_h+" -o "+mobile_h+".webp"
     print(cmd)
     print(cmd)
+    sqlcmd='update _had set adlogo_mobile_webp="'+mobile_h+'" where adid="'+adid+'"'
+#    db2.query()
+    break