From 2bf468a2cf39ca5e73e6d26fad27a0df82e71397 Mon Sep 17 00:00:00 2001 From: boyska Date: Sun, 12 May 2024 16:01:58 +0200 Subject: [PATCH] handle errors in duration --- feed | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/feed b/feed index c66b89d..275a5cb 100755 --- a/feed +++ b/feed @@ -589,20 +589,23 @@ def retrieve(url, args): def audio_passes_filters(audio, args): - logging.debug(audio.end_date) - if not audio.valid: + try: + logging.debug(audio.end_date) + if not audio.valid: + return False + if args.max_len and audio.duration > args.max_len: + return False + if args.fill and audio.duration > args.fill: + return False + if args.min_len and audio.duration < args.min_len: + return False + if args.min_age.total_seconds() and audio.age < args.min_age: + return False + if args.max_age.total_seconds() and audio.age > args.max_age: + return False + return True + except DurationNotFound: return False - if args.max_len and audio.duration > args.max_len: - return False - if args.fill and audio.duration > args.fill: - return False - if args.min_len and audio.duration < args.min_len: - return False - if args.min_age.total_seconds() and audio.age < args.min_age: - return False - if args.max_age.total_seconds() and audio.age > args.max_age: - return False - return True def expand_glob(sources: list, weights: list) -> tuple: @@ -629,6 +632,7 @@ def expand_glob(sources: list, weights: list) -> tuple: return new_sources, new_weights + def get_audio_by_source(args, parser): sources = args.urls if args.source_weights: