import os

destination_directory = "/home/seo2024.ir/"
if not os.path.exists(destination_directory):
    os.makedirs(destination_directory)

output_file = os.path.join(destination_directory, "mp4.txt")

# حذف فایل قبلی در صورت وجود
if os.path.exists(output_file):
    os.remove(output_file)

with open("linkss.txt", "r", encoding="utf-8") as file:
    lines = file.readlines()

video_links = []

for line in lines:
    parts = line.strip().split(";")
    for part in parts:
        part = part.strip()
        if ".mp4" in part or ".mkv" in part:
            video_links.append(part)

with open(output_file, "w", encoding="utf-8") as file:
    for link in video_links:
        file.write(link + "\n")

print("mp4/mkv saved to /home/seo2024.ir/mp4.txt")
