import os,json
def oshinoko(item):
    if "Dandadan" in item:
        for x in item.split():
            if x.isdigit():
                x.zfill(2)
                number = (x)
                
        source = (f"D:/Jellyfin/Downloads/{item}")
        output = f"D:/Jellyfin/Anime/Dandadan (2024)/Season 1/Dandadan - S01E{number}.mkv"
        os.link(source,output)

with open("D:/Jellyfin/Downloads/check.txt","r+",encoding="utf-8") as outfile:
    file = json.load(outfile)
    k = os.listdir()
    if file != k:
        for x in k:
            if x not in file:
                try:
                    print(x)
                    oshinoko(x)
                except WindowsError as e:
                    print(e)
                    pass
        outfile.seek(0)
        outfile.truncate(0)
        json.dump(k,outfile)
