Compare commits

...

2 commits

Author SHA1 Message Date
j
a229194d48 actually cleanup, only remove renders in infinity range 2024-03-19 10:12:15 +01:00
j
3d5293e7de lower priority 2024-03-19 10:11:40 +01:00
2 changed files with 10 additions and 10 deletions

View file

@ -7,7 +7,7 @@ Type=simple
Restart=always Restart=always
User=pandora User=pandora
Group=pandora Group=pandora
Nice=-15 Nice=19
WorkingDirectory=/srv/pandora/pandora WorkingDirectory=/srv/pandora/pandora
ExecStart=/srv/pandora/pandora/manage.py infinity ExecStart=/srv/pandora/pandora/manage.py infinity

View file

@ -635,7 +635,6 @@ def update_m3u(render_prefix, exclude=[]):
def render_infinity(options): def render_infinity(options):
prefix = options['prefix'] prefix = options['prefix']
duration = int(options['duration']) duration = int(options['duration'])
base = int(options['offset'])
state_f = os.path.join(prefix, "infinity.json") state_f = os.path.join(prefix, "infinity.json")
if os.path.exists(state_f): if os.path.exists(state_f):
@ -644,7 +643,8 @@ def render_infinity(options):
else: else:
state = { state = {
"offset": 100, "offset": 100,
"max-items": 30 "max-items": 30,
"no_video": False,
} }
for key in ("prefix", "duration"): for key in ("prefix", "duration"):
state[key] = options[key] state[key] = options[key]
@ -653,19 +653,19 @@ def render_infinity(options):
render_prefix = state["prefix"] + "/render/" render_prefix = state["prefix"] + "/render/"
current = [ current = [
f for f in os.listdir(render_prefix) f for f in os.listdir(render_prefix)
if f.isdigit() and os.path.isdir(render_prefix + f) if f.isdigit() and os.path.isdir(render_prefix + f) and state["offset"] > int(f) >= 100
] ]
if len(current) > state["max-items"]: if len(current) > state["max-items"]:
current = ox.sorted_strings(current) current = list(reversed(ox.sorted_strings(current)))
remove = current[-state["max-items"]:] remove = list(reversed(current[-state["max-items"]:]))
update_m3u(render_prefix, exclude=remove) update_m3u(render_prefix, exclude=remove)
for folder in remove: for folder in remove:
folder = render_prefix + folder folder = render_prefix + folder
print("remove", folder) print("remove", folder)
#shutil.rmtree(folder) shutil.rmtree(folder)
cmd = ["ssh", "front", "rm", "-r", folder] cmd = ["ssh", "front", "rm", "-rf", folder]
print(cmd) #print(cmd)
#subprocess.check_call(cmd) subprocess.check_call(cmd)
render_all(state) render_all(state)
path = "%s%s/" % (render_prefix, state["offset"]) path = "%s%s/" % (render_prefix, state["offset"])
cmd = ['rsync', '-a', path, "front:" + path] cmd = ['rsync', '-a', path, "front:" + path]