def moveUnlinkableDirectories(self, dirPath, toPath): print("Moving Unlinkable from", dirPath) print("To:", toPath) if not os.path.isdir(dirPath): print(dirPath, "is not a directory") raise ValueError if not os.path.isdir(toPath): print(toPath, "is not a directory") raise ValueError srcItems = os.listdir(dirPath) srcItems.sort() print("Len ", len(srcItems)) for item in srcItems: itemPath = os.path.join(dirPath, item) if not os.path.isdir(itemPath): continue if not nt.haveCanonicalMangaUpdatesName(item): targetDir = os.path.join(toPath, item) print("Moving item", item, "to unlinked dir") shutil.move(itemPath, targetDir) srcItems = os.listdir(toPath) srcItems.sort() print("Len ", len(srcItems)) for item in srcItems: itemPath = os.path.join(toPath, item) if not os.path.isdir(itemPath): continue if nt.haveCanonicalMangaUpdatesName(item): print("Moving item", item, "to linked dir") targetDir = os.path.join(dirPath, item) shutil.move(itemPath, targetDir) else: mId = nt.getAllMangaUpdatesIds(item) if mId: print("Item has multiple matches:", itemPath) for no in mId: print(" URL: https://www.mangaupdates.com/series.html?id=%s" % (no, ))