2023-11-27 16:08:58 +07:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
from moviepy.editor import *
|
|
|
|
import base64
|
|
|
|
import time
|
|
|
|
import textwrap
|
|
|
|
import mysql.connector
|
|
|
|
from dotenv import load_dotenv
|
|
|
|
|
|
|
|
load_dotenv()
|
|
|
|
|
|
|
|
bendera = 0
|
|
|
|
|
|
|
|
theteks = ""
|
|
|
|
picture = VideoFileClip("video.mp4")
|
|
|
|
|
2023-11-27 21:34:37 +07:00
|
|
|
thesize = 20
|
2023-11-27 16:08:58 +07:00
|
|
|
|
|
|
|
|
|
|
|
def checkindo():
|
|
|
|
mycursor = mydb.cursor()
|
|
|
|
sql = "SELECT * FROM meme_ronaldo WHERE status = '0' "
|
|
|
|
|
|
|
|
mycursor.execute(sql)
|
|
|
|
|
|
|
|
myresult = mycursor.fetchall()
|
|
|
|
|
|
|
|
if not myresult:
|
|
|
|
print("No input video")
|
|
|
|
return
|
|
|
|
|
|
|
|
for x in myresult:
|
2023-11-27 18:23:21 +07:00
|
|
|
user_empty = x[2]
|
|
|
|
text_db = x[1] # Fetch from Teks
|
2023-11-27 16:08:58 +07:00
|
|
|
print(text_db)
|
|
|
|
if (len(user_empty)) <= 1:
|
|
|
|
print("Ok")
|
|
|
|
return
|
|
|
|
else:
|
|
|
|
print("User " + user_empty + " kosong, rendering " + str(user_empty))
|
|
|
|
|
2023-11-27 18:23:21 +07:00
|
|
|
text_dbd = str(text_db)
|
2023-11-27 16:08:58 +07:00
|
|
|
|
2023-11-27 18:23:21 +07:00
|
|
|
theteks = text_dbd
|
2023-11-27 16:08:58 +07:00
|
|
|
tp = theteks.split(",")
|
|
|
|
t1 = textwrap.fill(tp[0].upper(), thesize)
|
2023-11-27 21:34:37 +07:00
|
|
|
t2 = " "
|
2023-11-27 16:08:58 +07:00
|
|
|
t10 = "10 KETIKA 11"
|
|
|
|
|
2023-11-27 21:34:37 +07:00
|
|
|
texts = [t1, t2]
|
2023-11-27 16:08:58 +07:00
|
|
|
|
|
|
|
|
|
|
|
step = 3 #each 15 sec: 0, 15, 30
|
|
|
|
duration = 3
|
|
|
|
t = 0
|
|
|
|
txt_clips = []
|
|
|
|
|
2023-11-27 18:23:21 +07:00
|
|
|
starts = [0,8] # or whatever
|
|
|
|
durations = [8,0]
|
2023-11-27 16:08:58 +07:00
|
|
|
|
|
|
|
for text,t,duration in zip(texts, starts, durations):
|
2023-11-27 21:34:37 +07:00
|
|
|
txt_clip = TextClip(text, fontsize = 24, color='white',font="DejaVu-Serif-Bold", stroke_color="black")
|
2023-11-27 16:08:58 +07:00
|
|
|
txt_clip = txt_clip.set_start(t)
|
|
|
|
txt_clip = txt_clip.set_pos('bottom').set_duration(duration)
|
|
|
|
txt_clips.append(txt_clip)
|
|
|
|
|
2023-11-27 21:34:37 +07:00
|
|
|
final_video = CompositeVideoClip([picture,txt_clips[0],txt_clips[1]])
|
2023-11-27 16:08:58 +07:00
|
|
|
|
|
|
|
final_video.write_videofile(str(user_empty)+".mp4")
|
|
|
|
|
|
|
|
#with open('teks.txt', "w") as myfile:
|
|
|
|
#myfile.write("S0VUSUtBIDEsS0VUSUtBIDIsS0VUSUtBIDMsS0VUSUtBIDQsS0VUSUtBIDUsS0VUSUtBIDYsS0VUSUtBIDcsS0VUSUtBIDgsS0VUSUtBIDks")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2023-11-27 21:34:37 +07:00
|
|
|
sql = "UPDATE meme_ronaldo SET status = \'"+ "1" +"\' WHERE value = \'" + str(user_empty) +"\'"
|
2023-11-27 16:08:58 +07:00
|
|
|
mycursor.execute(sql)
|
|
|
|
# myresult = mycursor.fetchall()
|
|
|
|
mydb.commit()
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
|
|
while True:
|
|
|
|
mydb = mysql.connector.connect(
|
|
|
|
host=os.getenv('DB_HOST'),
|
|
|
|
user=os.getenv('DB_USER'),
|
|
|
|
password=os.getenv('DB_PASSWORD'),
|
|
|
|
database=os.getenv('DB_NAME')
|
|
|
|
)
|
|
|
|
|
|
|
|
checkindo()
|
|
|
|
time.sleep(1)
|
|
|
|
|
|
|
|
# textwrap.fill(tp[0].upper(), thesize)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|