1
0
Fork 0
mirror of https://git.sr.ht/~cadence/NewLeaf synced 2026-03-05 12:01:38 +00:00

Split out file cleanup code

This commit is contained in:
Cadence Ember 2021-01-26 01:05:40 +13:00
parent b454ebd6e5
commit 268457394f
No known key found for this signature in database
GPG key ID: BC1C2C61CF521B17
2 changed files with 15 additions and 13 deletions

11
tools/files.py Normal file
View file

@ -0,0 +1,11 @@
import os
def get_created_files(id):
if id[0] == "-":
id = "_" + id[1:] # youtube-dl changes - to _ at the start, presumably to not accidentally trigger switches with * in shell
return (f for f in os.listdir() if f.startswith("{}_".format(id)))
def clean_up_temp_files(id):
created_files = get_created_files(id)
for file in created_files:
os.unlink(file)