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, "new.txt")

# اطمینان از حذف فایل قبلی
if os.path.exists(output_file):
    os.remove(output_file)

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

vtt_links = []

for line in lines:
    line = line.strip()
    if not line:
        continue
    parts = line.split(";")
    for part in parts:
        part = part.strip()
        if ".vtt" in part:
            vtt_links.append(part)

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

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