From 4dbb0c5196dfa650e4ff63d965abc68910f2701c Mon Sep 17 00:00:00 2001 From: tcely Date: Sun, 9 Feb 2025 02:21:16 -0500 Subject: [PATCH 1/2] Remove subtitles also Fixes #416 --- tubesync/sync/signals.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tubesync/sync/signals.py b/tubesync/sync/signals.py index 4f811add..79cc556b 100644 --- a/tubesync/sync/signals.py +++ b/tubesync/sync/signals.py @@ -221,7 +221,7 @@ def media_post_delete(sender, instance, **kwargs): video_path = Path(str(instance.media_file.path)).resolve() instance.media_file.delete(save=False) # the other files we created have these known suffixes - for suffix in frozenset(('nfo', 'jpg', 'webp', 'info.json',)): + for suffix in frozenset(('nfo', 'jpg', 'webp', 'vtt', 'info.json',)): other_path = video_path.with_suffix(f'.{suffix}').resolve() log.info(f'Deleting file for: {instance} path: {other_path!s}') delete_file(other_path) From 6247a8b062e7a447ca3fef0cabb7e8f0628565cf Mon Sep 17 00:00:00 2001 From: tcely Date: Sun, 9 Feb 2025 02:33:32 -0500 Subject: [PATCH 2/2] Account for language code in subtitle files --- tubesync/sync/signals.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tubesync/sync/signals.py b/tubesync/sync/signals.py index 79cc556b..bb7bba5c 100644 --- a/tubesync/sync/signals.py +++ b/tubesync/sync/signals.py @@ -221,10 +221,15 @@ def media_post_delete(sender, instance, **kwargs): video_path = Path(str(instance.media_file.path)).resolve() instance.media_file.delete(save=False) # the other files we created have these known suffixes - for suffix in frozenset(('nfo', 'jpg', 'webp', 'vtt', 'info.json',)): + for suffix in frozenset(('nfo', 'jpg', 'webp', 'info.json',)): other_path = video_path.with_suffix(f'.{suffix}').resolve() log.info(f'Deleting file for: {instance} path: {other_path!s}') delete_file(other_path) + # subtitles include language code + subtitle_files = video_path.parent.glob(f'{glob_quote(video_path.with_suffix("").name)}*.vtt') + for file in subtitle_files: + log.info(f'Deleting file for: {instance} path: {file}') + delete_file(file) # Jellyfin creates .trickplay directories and posters for suffix in frozenset(('.trickplay', '-poster.jpg', '-poster.webp',)): # with_suffix insists on suffix beginning with '.' for no good reason