From 7e69e57050d38ef212139205c218a4811e764b73 Mon Sep 17 00:00:00 2001 From: Aleteoryx Date: Sun, 28 Dec 2025 14:00:57 -0500 Subject: [PATCH] smarter filename heuristics --- queuers/reenc.py | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/queuers/reenc.py b/queuers/reenc.py index 052063373285c9bd5a5687ab6266c0f9b783c1a1..b573b20d77c06c0d49e37e1e3d966fb62a3e2966 100644 --- a/queuers/reenc.py +++ b/queuers/reenc.py @@ -26,9 +26,22 @@ from typing import Optional from os import system import socket -RESOLUTIONS=[(1280, 720), (1366, 768), (1920, 1080)] +# 1080p +#RESOLUTIONS=[(1280, 720), (1366, 768), (1920, 1080)] + +# 720p +#RESOLUTIONS=[(1280, 720), (1366, 768)] + +# 576p +#RESOLUTIONS=[(1024, 576), (1366, 768)] + +# cursed #RESOLUTIONS=[(710, 480), (1136, 768)] +# dvd +#RESOLUTIONS=[(720, 480), (1152, 768)] + + argv0 = 'reenc.py' def usage(): @@ -114,14 +127,14 @@ def find_sXXeXX(name): if (m := re.search('S([0-9]+)', name, re.I)) is not None: season = int(m.group(1)) name = name[:m.start()] + name[m.end():] - elif (m := re.search('Season ([0-9]+)', name, re.I)) is not None: + elif (m := re.search('Se?a?s?o?n?\\D?([0-9]+)', name, re.I)) is not None: season = int(m.group(1)) name = name[:m.start()] + name[m.end():] if (m := re.search('E([0-9]+)', name, re.I)) is not None: episode = int(m.group(1)) - elif (m := re.search('Episode ([0-9]+)', name, re.I)) is not None: + elif (m := re.search('E\p\i\s\o\d\e\\D?([0-9]+)', name, re.I)) is not None: episode = int(m.group(1)) elif (m := re.search('([0-9]+)', name, re.I)) is not None: episode = int(m.group(1)) @@ -136,8 +149,11 @@ def dump_metafile(path, name, files): pfx, sfx = find_common_ends(map(lambda x: x.name, files)) for file in files: - season, episode = find_sXXeXX(file.name) + sxxexxchunk = file.name[:len(pfx)] + file.name[-len(sfx):] + season, episode = find_sXXeXX(sxxexxchunk) title = file.name[len(pfx):-len(sfx)] + if ' ' not in file.name: + title = title.replace('.', ' ').replace('_', ' ') print(f'file: {str(file)}', file=fp) print(f'season: {season}', file=fp)