From 09d4b8bc0456fbbbcaff257ce12a12f2e5438603 Mon Sep 17 00:00:00 2001 From: tcely Date: Sat, 24 May 2025 04:39:01 -0400 Subject: [PATCH] Use `filter_response` to clean up the debug logs --- tubesync/sync/hooks.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/tubesync/sync/hooks.py b/tubesync/sync/hooks.py index 467e2df1..cd23d5a1 100644 --- a/tubesync/sync/hooks.py +++ b/tubesync/sync/hooks.py @@ -2,6 +2,7 @@ import os from common.logger import log from common.utils import remove_enclosed +from sync.utils import filter_response progress_hook = { @@ -212,11 +213,15 @@ def yt_dlp_postprocessor_hook(event): status.media_name = name if 'started' == event['status']: - if 'formats' in event['info_dict']: - del event['info_dict']['formats'] - if 'automatic_captions' in event['info_dict']: - del event['info_dict']['automatic_captions'] - log.debug(repr(event['info_dict'])) + remove_keys = frozenset({ + 'formats', + 'automatic_captions', + }) + logged_dict = filter_response(event['info_dict'], True) + found_keys = set(logged_dict.keys()).intersection(remove_keys) + for key in found_keys: + del logged_dict[key] + log.debug(repr(logged_dict)) if 'Unknown' != key: status.media_key = key