def tagDownload(): path = SysConst.getDownloadPath() movieFiles = DiskIndex.getTxts(path) allNumbers = DownloadDAO.get_all_download() conn = SysConst.getConnect() for avNumber in allNumbers: name = avNumber.lower() first = name[0:name.find('-')] second = name[name.find('-') + 1:] for file in movieFiles: filename = file["filename"].lower() if filename.find(first) > -1 and filename.find(second) > -1: print("find " + name + " : " + file["fullpath"]) movieFiles.remove(file) MovieDAO.markMovieDownload(conn, avNumber.upper()) break conn.commit() conn.close()
import os from index import SysConst if __name__ == '__main__': folder = SysConst.getDownloadPath() movieTypes = set(["avi", "mp4", "mkv", "rmvb", "wmv", "iso"]) for fpath, dirs, fs in os.walk(folder): for filename in fs: # fullpath = os.path.join(fpath, filename) suffix = filename[-3:].lower() if filename[0:1] != "." and len(filename) > 4 and suffix in movieTypes: newFileName = filename[:-4] + ".txt" newFullPath = fpath + "/" + newFileName print("createFile: " + newFullPath) file = open(newFullPath, "wt") file.close()