From 283617bd5dc04a9e8e21e0455f7aa79d1fb3455a Mon Sep 17 00:00:00 2001 From: Ali Hamdi Ali Fadel Date: Sat, 2 Nov 2024 21:04:37 +0000 Subject: [PATCH] Skip subscriber_only videos --- pyproject.toml | 2 +- tafrigh/cli.py | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 5110857..0771e6f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "tafrigh" -version = "1.7.0" +version = "1.7.1" description = "تفريغ النصوص وإنشاء ملفات SRT و VTT باستخدام نماذج Whisper وتقنية wit.ai." authors = ["EasyBooks "] license = "MIT" diff --git a/tafrigh/cli.py b/tafrigh/cli.py index 9ca3517..7b84da9 100644 --- a/tafrigh/cli.py +++ b/tafrigh/cli.py @@ -214,7 +214,7 @@ def process_url( elements = list(filter(lambda element: element, elements)) for idx, element in enumerate(tqdm(elements, desc='URL elements')): - if element['title'] == '[Private video]' or element['title'] == '[Deleted video]': + if should_skip(element): continue new_progress_info = progress_info.copy() @@ -285,3 +285,9 @@ def write_output_sample(segments: list[SegmentType], output: Config.Output) -> N 'url': segment['url'], 'file_path': segment['file_path'], }) + + +def should_skip(element: dict[str, Any]) -> bool: + return (element['title'] == '[Private video]' or + element['title'] == '[Deleted video]' or + element['availability'] == 'subscriber_only')