|
@@ -371,6 +371,14 @@ def get_url_type(url):
|
|
contentType = r.getheader('Content-Type')
|
|
contentType = r.getheader('Content-Type')
|
|
return contentType
|
|
return contentType
|
|
|
|
|
|
|
|
+def notify_line_user(msg, line_token):
|
|
|
|
+ headers = {
|
|
|
|
+ "Authorization": "Bearer " + line_token,
|
|
|
|
+ "Content-Type": "application/x-www-form-urlencoded"
|
|
|
|
+ }
|
|
|
|
+ params = {"message": msg}
|
|
|
|
+ r = requests.post("https://notify-api.line.me/api/notify",headers=headers, params=params)
|
|
|
|
+
|
|
def notify_group(msg):
|
|
def notify_group(msg):
|
|
glist=['WekCRfnAirSiSxALiD6gcm0B56EejsoK89zFbIaiZQD']
|
|
glist=['WekCRfnAirSiSxALiD6gcm0B56EejsoK89zFbIaiZQD']
|
|
for gid in glist:
|
|
for gid in glist:
|
|
@@ -429,6 +437,7 @@ def gen_video_queue(name_hash,name,text_content, image_urls,avatar,user_id):
|
|
os.remove(tmp_video_dir+top1['name_hash']+'.mp4')
|
|
os.remove(tmp_video_dir+top1['name_hash']+'.mp4')
|
|
vid_duration = VideoFileClip(video_dest+top1['name_hash']+'.mp4').duration
|
|
vid_duration = VideoFileClip(video_dest+top1['name_hash']+'.mp4').duration
|
|
user_obj = first(db.query('SELECT * FROM users where id ="'+str(user_id)+'"'))
|
|
user_obj = first(db.query('SELECT * FROM users where id ="'+str(user_id)+'"'))
|
|
|
|
+ line_token = user_obj['line_token'] # aa
|
|
left_time = user_obj['left_time']
|
|
left_time = user_obj['left_time']
|
|
email = user_obj['email']
|
|
email = user_obj['email']
|
|
print('left_time is '+str(left_time))
|
|
print('left_time is '+str(left_time))
|
|
@@ -439,10 +448,12 @@ def gen_video_queue(name_hash,name,text_content, image_urls,avatar,user_id):
|
|
print(msg)
|
|
print(msg)
|
|
msg =msg.encode(encoding='utf-8')
|
|
msg =msg.encode(encoding='utf-8')
|
|
mailer.send(msg, email)
|
|
mailer.send(msg, email)
|
|
|
|
+ notify_line_user(msg, line_token)
|
|
else:
|
|
else:
|
|
left_time = left_time - vid_duration
|
|
left_time = left_time - vid_duration
|
|
db.query('UPDATE users SET left_time ='+str(left_time)+' WHERE id='+str(user_id)+';')
|
|
db.query('UPDATE users SET left_time ='+str(left_time)+' WHERE id='+str(user_id)+';')
|
|
notify_group(name+"的影片已經產生完成囉! www.choozmo.com:8168/"+video_sub_folder+name_hash+".mp4")
|
|
notify_group(name+"的影片已經產生完成囉! www.choozmo.com:8168/"+video_sub_folder+name_hash+".mp4")
|
|
|
|
+ notify_line_user(name+"的影片已經產生完成囉! www.choozmo.com:8168/"+video_sub_folder+name_hash+".mp4", line_token)
|
|
#except:
|
|
#except:
|
|
#print('video generation error')
|
|
#print('video generation error')
|
|
#notify_group('影片錯誤')
|
|
#notify_group('影片錯誤')
|