Created
April 27, 2021 06:41
-
-
Save penut85420/0ad858ca4e9978d1399a2c0235a98fc7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import psutil | |
class CheckingVOD: | |
def __init__(self): | |
self.process = self.locate() | |
self.refresh() | |
def locate(self, name='potplayer'): | |
pid = None | |
for proc in psutil.process_iter(): | |
if name in proc.name().lower(): | |
pid = proc.pid | |
if pid is None: | |
raise OSError('Process not found') | |
return psutil.Process(pid) | |
def refresh(self): | |
self.file_list = set() | |
for item in self.process.open_files(): | |
self.file_list.add(os.path.basename(item.path)) | |
def check(self, fpath): | |
if fpath in self.file_list: | |
return True | |
return False | |
def check_dir(self, dir_path): | |
for _, _, file_list in os.walk(dir_path): | |
for file_name in file_list: | |
if self.check(file_name): | |
return file_name | |
return None | |
if __name__ == '__main__': | |
print(CheckingVOD().check_dir(r'F:/Videos/Drill Team/')) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment