media-sucker/src/statuser.py

29 lines
719 B
Python
Raw Normal View History

2022-02-26 08:05:20 -07:00
#! /usr/bin/python3
import threading
import json
import glob
import time
import os
class Statuser(threading.Thread):
2022-08-25 10:17:25 -06:00
def __init__(self, workers, directory):
2022-02-26 08:05:20 -07:00
self.workers = workers
self.directory = directory
self.status = {}
2022-08-25 10:17:25 -06:00
super().__init__(daemon=True)
2022-02-26 08:05:20 -07:00
def run(self):
while True:
self.status["finished"] = {
"video": glob.glob(os.path.join(self.directory, "*.mkv")),
2022-08-25 10:17:25 -06:00
"audio": glob.glob(os.path.join(self.directory, "*/*.mp3")),
2022-02-26 08:05:20 -07:00
}
self.status["workers"] = [w.status for w in self.workers]
time.sleep(12)
def json(self):
return json.dumps(self.status)
# vi: sw=4 ts=4 et ai