Skip to content

Commit

Permalink
comtune.py: filter show by video count after complete filtering rules
Browse files Browse the repository at this point in the history
  • Loading branch information
double16 committed Jul 30, 2024
1 parent 6d1356d commit 109aa7d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
14 changes: 8 additions & 6 deletions dvrprocess/comtune.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
INI_GROUP_DETAILED_SETTINGS, get_comskip_hwassist_options, INI_GROUP_INPUT_CORRECTION
from common import tools, config, constants, edl_util, progress

TUNE_SHOW_MIN_VIDEO_COUNT = 5

CSV_SUFFIX_BLACKFRAME = "-blackframe"

logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -546,17 +548,17 @@ def setup_gad(process_pool: Pool, thread_pool: ThreadPoolExecutor, files, workdi
logger.info("Not considering %s because it has %d episodes", file_path, episode_count)
input_dirs.add(os.path.dirname(file_path))

if len(dvr_infos) == 0:
raise UserWarning("No files look like they have commercials")
if len(dvr_infos) < TUNE_SHOW_MIN_VIDEO_COUNT:
raise UserWarning(f"Too few files look like they have commercials {len(dvr_infos)} < {TUNE_SHOW_MIN_VIDEO_COUNT}")

# Ignore special longer episodes, such as the pilot
episode_common_duration = common.get_common_episode_duration(dvr_infos)
logger.info("Target episode duration %s", common.seconds_to_timespec(episode_common_duration))
dvr_infos = list(filter(lambda info: episode_common_duration == common.round_episode_duration(info), dvr_infos))
dvr_durations = list(map(lambda info: common.episode_info(info)[1], dvr_infos))

if len(dvr_infos) == 0:
raise UserWarning("No files look like they have commercials")
if len(dvr_infos) < TUNE_SHOW_MIN_VIDEO_COUNT:
raise UserWarning(f"Too few files look like they have commercials {len(dvr_infos)} < {TUNE_SHOW_MIN_VIDEO_COUNT}, after excluding specials")

expected_adjusted_duration_default = get_expected_adjusted_duration(dvr_infos[0])
logger.info(f"Mean duration {common.seconds_to_timespec(mean(dvr_durations))}")
Expand Down Expand Up @@ -980,8 +982,8 @@ def initial_solution_values_from_ini(path) -> dict[ComskipGene, list]:

def tune_show(season_dir, process_pool: Pool, files, workdir, dry_run, force, expensive_genes=False, check_compute=True,
processes=0, experimental=False):
if len(files) < 5:
logger.warning("too few video files %d to tune %s, need 5", len(files), season_dir)
if len(files) < TUNE_SHOW_MIN_VIDEO_COUNT:
logger.warning("too few video files %d to tune %s, need %d", len(files), season_dir, TUNE_SHOW_MIN_VIDEO_COUNT)
return

logger.info("tuning show %s", season_dir)
Expand Down
2 changes: 1 addition & 1 deletion dvrprocess/find_need_transcode.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ def find_need_transcode_cli(argv):
desired_audio_codecs=desired_audio_codecs,
max_resolution=max_resolution,
desired_frame_rate=desired_frame_rate):
sys.stdout.write(file_info.file_name)
sys.stdout.write(file_info.host_file_path)
sys.stdout.write(terminator)
return 0

Expand Down

0 comments on commit 109aa7d

Please sign in to comment.