Skip to content

Commit 6522daf

Browse files
Sec42schneider42
authored andcommitted
grab sample_rate, center_freq and timestamp from filename
1 parent 1cc3373 commit 6522daf

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

apps/iridium-extractor

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import time
44
import getopt
55
import sys
6+
import re
67
import threading
78
import os.path
89
import argparse
@@ -285,6 +286,21 @@ if __name__ == "__main__":
285286
if fmt in sample_formats:
286287
fmt = sample_formats[fmt]
287288

289+
# grab things from filename as fallback
290+
if sample_rate is None and (g := re.search(r"-s(\d+(\.\d+)?(e[+-]\d+)?)-", filename)):
291+
sample_rate = int(float(g.group(1)))
292+
293+
if args.file_info is None and (g := re.search(r"-t(\d{14}(\+\d{4})?)\.", filename)):
294+
try:
295+
import datetime
296+
dt = datetime.datetime.strptime(g.group(1), "%Y%m%d%H%M%S" + "%z" * bool(g.group(2)))
297+
args.file_info = f'i-{dt.timestamp():.20g}-t1'
298+
except ValueError:
299+
print("Couldn't parse timestamp in filename.", file=sys.stderr)
300+
301+
if center is None and (g := re.search(r"-f(\d+(\.\d+)?(e[+-]\d+)?)-", filename)):
302+
center = int(float(g.group(1)))
303+
288304
if args.file_info is None:
289305
if offline:
290306
args.file_info = os.path.splitext(os.path.basename(filename))[0]

0 commit comments

Comments
 (0)