File tree Expand file tree Collapse file tree 1 file changed +16
-0
lines changed Expand file tree Collapse file tree 1 file changed +16
-0
lines changed Original file line number Diff line number Diff line change 3
3
import time
4
4
import getopt
5
5
import sys
6
+ import re
6
7
import threading
7
8
import os .path
8
9
import argparse
@@ -285,6 +286,21 @@ if __name__ == "__main__":
285
286
if fmt in sample_formats :
286
287
fmt = sample_formats [fmt ]
287
288
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
+
288
304
if args .file_info is None :
289
305
if offline :
290
306
args .file_info = os .path .splitext (os .path .basename (filename ))[0 ]
You can’t perform that action at this time.
0 commit comments