Skip to content

Commit

Permalink
grab sample_rate, center_freq and timestamp from filename
Browse files Browse the repository at this point in the history
  • Loading branch information
Sec42 committed Aug 26, 2024
1 parent 0ddc285 commit 7327255
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions apps/iridium-extractor
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import time
import getopt
import sys
import re
import threading
import os.path
import argparse
Expand Down Expand Up @@ -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]
Expand Down

0 comments on commit 7327255

Please sign in to comment.