From 13b64336897b71a4aed640b74c7e3fb16fee0b8b Mon Sep 17 00:00:00 2001 From: tcely Date: Tue, 18 Aug 2026 07:32:27 -0400 Subject: [PATCH 1/4] feat: condensed storage for subtitles and automatic captions --- tubesync/sync/utils.py | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/tubesync/sync/utils.py b/tubesync/sync/utils.py index e3d335e14..658520d5e 100644 --- a/tubesync/sync/utils.py +++ b/tubesync/sync/utils.py @@ -242,12 +242,41 @@ def drop_subtitles_url(**kwargs): ) ) + def condense_exts(arg_dict, key): + mapped, result_list = list_of_dictionaries(arg_dict[key], extract_exts) + if mapped: + acc = dict(names=set(), exts=dict()) + for t in result_list: + reduce_ext(t, acc) + # promote for the shared name case, otherwise keep everything + if 1 == len(acc['names']): + acc['exts'] = sorted(e for s in acc['exts'].values() for e in s) + arg_dict[key] = [acc] + elif acc['names']: + arg_dict[key] = [acc] + + def extract_exts(arg_dict): + ext = arg_dict.get('ext') + name = arg_dict.get('name') + return (name, ext) + + def reduce_ext(t, results): + name, ext = t + if not name: + return + results['names'].add(name) + exts = results['exts'].get(name, set()) + results['exts'][name] = exts + if ext: + exts.add(ext) + for key in ('subtitles', 'requested_subtitles', 'automatic_captions',): if key in response_dict.keys(): lang_codes = response_dict[key] if isinstance(lang_codes, dict): for lang_code in lang_codes.keys(): _drop_url_keys(lang_codes, lang_code, drop_subtitles_url) + condense_exts(lang_codes, lang_code) # end of subtitles cleanup }}} # beginning of heatmap cleanup {{{ From aa9b2435197e9b15042ca7132cb7bdef963d1a3d Mon Sep 17 00:00:00 2001 From: tcely Date: Tue, 18 Aug 2026 07:34:39 -0400 Subject: [PATCH 2/4] chore(lint): address FURB188 --- tubesync/sync/utils.py | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/tubesync/sync/utils.py b/tubesync/sync/utils.py index 658520d5e..faf0d152c 100644 --- a/tubesync/sync/utils.py +++ b/tubesync/sync/utils.py @@ -313,12 +313,9 @@ def parse_media_format(format_dict): except (ValueError, TypeError): width = 0 format_full = format_dict.get('format_note', '').strip().upper() - format_str = format_full[:-2] if format_full.endswith('60') else format_full - format_str = format_str.strip() - format_str = format_str[:-3] if format_str.endswith('HDR') else format_str - format_str = format_str.strip() - format_str = format_str[:-2] if format_str.endswith('60') else format_str - format_str = format_str.strip() + format_str = format_full.removesuffix('60').strip() + format_str = format_str.removesuffix('HDR').strip() + format_str = format_str.removesuffix('60').strip() is_hls = True is_dash = False if 'DASH' in format_str: From ae06b826a5373cbcc410e7e858d216fb2948f049 Mon Sep 17 00:00:00 2001 From: tcely Date: Tue, 18 Aug 2026 07:35:01 -0400 Subject: [PATCH 3/4] chore(lint): address PLR1730 --- tubesync/sync/utils.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/tubesync/sync/utils.py b/tubesync/sync/utils.py index faf0d152c..ccae5c95d 100644 --- a/tubesync/sync/utils.py +++ b/tubesync/sync/utils.py @@ -81,10 +81,8 @@ def resize_image_to_height(image, width, height): ''' image = image.convert('RGB') ratio = image.width / image.height - scaled_width = math.ceil(height * ratio) - if scaled_width < width: - # Width too small, stretch it - scaled_width = width + # When scaled width is too small, stretch it + scaled_width = max(width, math.ceil(height * ratio)) image = image.resize((scaled_width, height), Image.LANCZOS) if scaled_width > width: # Width too large, crop it From ec7a38628594cb4fc78a1f3ae743d3b1371bf0e4 Mon Sep 17 00:00:00 2001 From: tcely Date: Tue, 18 Aug 2026 07:35:17 -0400 Subject: [PATCH 4/4] chore(lint): disable SIM118 --- tubesync/sync/utils.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tubesync/sync/utils.py b/tubesync/sync/utils.py index ccae5c95d..ea2d1028a 100644 --- a/tubesync/sync/utils.py +++ b/tubesync/sync/utils.py @@ -164,6 +164,7 @@ def _url_keys(arg_dict, filter_func): return result +# ruff: disable[SIM118] # expects a dictionary where the value at key is a: # list of dictionaries def _drop_url_keys(arg_dict, key, filter_func): @@ -284,6 +285,7 @@ def reduce_ext(t, results): # end of heatmap cleanup }}} return response_dict +# ruff: enable[SIM118] def parse_media_format(format_dict):