import os
import time

# اجرای اسکریپت اول
############################################
os.system("python3.9 importer/ids.py")
time.sleep(3)
print("Ids")
# os.system("python3.9 importer/zarids.py")
# time.sleep(3)
# print("zarids")
os.system("python3.9 linkupdater2.py")
time.sleep(3)
print("link updater")
os.system("python3.9 linkupdater_fixer.py")
time.sleep(3)
print("linkupdater_fixer.py")
os.system("python3.9 dub-deleter.py")
time.sleep(3)
print("python3.9 dub deleter")
os.system("python3.9 new.py")
time.sleep(3)
print("link new")
os.system("python3.9 links.py")
time.sleep(3)
print("link links")
os.system("python3.9 mp4.py")
time.sleep(3)
print("link mp4")
os.system("python3.9 vtt.py")
time.sleep(3)
print("link vtt")
os.system("python3.9 string-deleter.py")
time.sleep(3)
print("link string-deleted")
os.system("python3.9 dub-deleter2.py")
time.sleep(3)
print("python3.9 dub deleter")
#############################################


# سؤال از کاربر
print("downloaded? Ready for import and update? Yes or No")
جواب = input("Please enter y or n (press Enter for Yes): ").strip().lower()

# اگه جواب "n" نباشه (یعنی "y" یا خالی باشه)، ادامه بده
if جواب != "n":
    os.system("python3.9 main.py")
    time.sleep(3)   
    
    # # حذف فایل new.txt
    # # if os.path.exists("new.txt"):
    #     # os.remove("new.txt")
    #     # print("File new.txt has been deleted")
    # # else:
    #     # print("File new.txt not found")
    
    # # اضافه کردن محتویات outfordl.txt به stream_serials.txt بدون خط خالی اضافی
    # with open('outfordl.txt', 'r', encoding='utf-8') as source_file:
    #     source_content = source_file.read().strip()  # حذف فاصله‌ها و خطوط خالی اضافی

    # if os.path.exists('stream_serials.txt'):
    #     with open('stream_serials.txt', 'r', encoding='utf-8') as dest_file:
    #         existing_content = dest_file.read().rstrip()  # حذف خط خالی آخر
    # else:
    #     existing_content = ""

    # final_content = existing_content
    # if existing_content and source_content:  # اگه محتوای قبلی هست، یه خط جدید اضافه کن
    #     final_content += "\n"
    # final_content += source_content

    # with open('stream_serials.txt', 'w', encoding='utf-8') as dest_file:
    #     dest_file.write(final_content)

    print("done")  # چاپ پیام اتمام عملیات کپی

else:
    print("Operation canceled")