From 7ec0a1de96e3cd43b266dc13a6ede938f28ae39b Mon Sep 17 00:00:00 2001 From: jb-alvarado Date: Wed, 3 Feb 2021 17:26:12 +0100 Subject: [PATCH] get default value from numnber check, check for advertisement --- ffplayout/utils.py | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/ffplayout/utils.py b/ffplayout/utils.py index 0f592570..b201c6c5 100644 --- a/ffplayout/utils.py +++ b/ffplayout/utils.py @@ -657,26 +657,29 @@ def get_date(seek_day): return d.strftime('%Y-%m-%d') -def is_float(value): +def is_float(value, default=False): """ test if value is float """ try: - float(value) - return True + return float(value) except (ValueError, TypeError): - return False + return default -def is_int(value): +def is_int(value, default=False): """ test if value is int """ try: - int(value) - return True + return int(value) except ValueError: - return False + return default + + +def is_advertisement(node): + if 'category' in node and node["category"] == 'advertisement': + return True def valid_json(file):