From 6522dafb4759e942caeec0a0ebb57ab07c8255e9 Mon Sep 17 00:00:00 2001 From: Stefan `Sec` Zehl Date: Fri, 16 Aug 2024 01:40:59 -0700 Subject: [PATCH] grab sample_rate, center_freq and timestamp from filename --- apps/iridium-extractor | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/apps/iridium-extractor b/apps/iridium-extractor index bce6471..2833846 100755 --- a/apps/iridium-extractor +++ b/apps/iridium-extractor @@ -3,6 +3,7 @@ import time import getopt import sys +import re import threading import os.path import argparse @@ -285,6 +286,21 @@ if __name__ == "__main__": if fmt in sample_formats: fmt = sample_formats[fmt] + # grab things from filename as fallback + if sample_rate is None and (g := re.search(r"-s(\d+(\.\d+)?(e[+-]\d+)?)-", filename)): + sample_rate = int(float(g.group(1))) + + if args.file_info is None and (g := re.search(r"-t(\d{14}(\+\d{4})?)\.", filename)): + try: + import datetime + dt = datetime.datetime.strptime(g.group(1), "%Y%m%d%H%M%S" + "%z" * bool(g.group(2))) + args.file_info = f'i-{dt.timestamp():.20g}-t1' + except ValueError: + print("Couldn't parse timestamp in filename.", file=sys.stderr) + + if center is None and (g := re.search(r"-f(\d+(\.\d+)?(e[+-]\d+)?)-", filename)): + center = int(float(g.group(1))) + if args.file_info is None: if offline: args.file_info = os.path.splitext(os.path.basename(filename))[0]