Process new files
This commit is contained in:
parent
d4cdbb3606
commit
7bcf366581
@ -325,7 +325,15 @@ if __name__ == '__main__':
|
||||
|
||||
watch_dir = config.get(section, "watch_dir")
|
||||
inotify_watch = setup_watch(watch_dir)
|
||||
|
||||
output_dir = config.get(section, "output_dir")
|
||||
try:
|
||||
os.makedirs(output_dir, exist_ok=True)
|
||||
except OSError as ose:
|
||||
log.error(f"Unable to create section '[{section}]' output dir '{output_dir}' with an OSError:\n"
|
||||
f"{ose}\n"
|
||||
f"Exiting 4 ...")
|
||||
sys.exit(4)
|
||||
else:
|
||||
while True:
|
||||
time.sleep(0.2)
|
||||
for event in inotify_watch.read():
|
||||
@ -334,6 +342,15 @@ if __name__ == '__main__':
|
||||
file_name = event.name
|
||||
log.info(f"File '{file_name}' was moved to watch directory '{watch_dir}', processing ...")
|
||||
|
||||
# TODO https://docs.python.org/3/library/xml.etree.elementtree.html
|
||||
# TODO generate xml
|
||||
# TODO: Basic string manipulation via regex in options file
|
||||
season_and_episode = get_season_and_episode(section, config, file_name)
|
||||
nfo = generate_nfo(season_and_episode["title_str"], file_name)
|
||||
file_moved_to_target_dir = move_file_to_target_dir(
|
||||
section,
|
||||
config,
|
||||
file_name,
|
||||
season_and_episode)
|
||||
if file_moved_to_target_dir:
|
||||
write_nfo_to_disk(
|
||||
nfo,
|
||||
file_moved_to_target_dir,
|
||||
output_dir)
|
||||
|
Loading…
x
Reference in New Issue
Block a user