>>64580why not just use chatgpt to fix it for you with a python script
import os
import subprocess
import mysql.connector
# Configuration variable
board = "lounge"
# Function to connect to MySQL database
def connect_to_database():
try:
connection = mysql.connector.connect(
host="localhost",
user="dbadmin",
password="dbpassword",
database="wizchandb"
)
return connection
except mysql.connector.Error as err:
print("Error: ", err)
return None
# Function to query the database
def query_database(connection, filename):
try:
cursor = connection.cursor()
truncated_filename = filename[:10]
next_truncated_filename = str(int(truncated_filename) + 1)
query = f"SELECT * FROM posts_{board} WHERE (files LIKE %s OR files LIKE %s) AND (files NOT LIKE %s) AND (files NOT LIKE %s)"
cursor.execute(query, (f'%{truncated_filename}%', f'%{next_truncated_filename}%', '%spoiler%', '%thumb%'))
result = cursor.fetchone()
cursor.close()
return result
except mysql.connector.Error as err:
print("Error: ", err)
return None
# Function to generate thumbnails
def generate_thumbnail(video_path, thumbnail_path):
try:
subprocess.run([
"/usr/bin/ffmpeg",
"-i", video_path,
"-vf", "thumbnail,scale='if(gt(iw,ih),min(255,iw),-2):if(gt(iw,ih),-2,min(255,ih))'",
"-frames:v", "1",
thumbnail_path
], check=True)
print(f"Thumbnail generated for {video_path}")
except subprocess.CalledProcessError as err:
print("Error: ", err)
# Main function
def main():
src_directory = os.path.join("/var/www/wizchan", board, "src/")
thumb_directory = os.path.join("/var/www/wizchan", board, "thumb/")
# Connect to the database
connection = connect_to_database()
if not
Post too long. Click here to view the full text.