Skip to content

Instantly share code, notes, and snippets.

@penut85420
Created April 27, 2021 06:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save penut85420/0ad858ca4e9978d1399a2c0235a98fc7 to your computer and use it in GitHub Desktop.
Save penut85420/0ad858ca4e9978d1399a2c0235a98fc7 to your computer and use it in GitHub Desktop.
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