Batch number from file
This commit is contained in:
1 parent
2792ccd5bc
commit
ac0678d9c2
1 file changed
+6
-7
@@ -41,7 +41,7 @@ FLASK_DEBUG = os.getenv("FLASK_DEBUG", "false").lower() == "true"
|
|||||||
_http_session = requests.Session()
|
_http_session = requests.Session()
|
||||||
_http_session.timeout = 3
|
_http_session.timeout = 3
|
||||||
|
|
||||||
_FILENAME_RE = re.compile(r"batch[_-](\d+)[_-](\d{8})[_-]\d{6}\.mp4", re.IGNORECASE)
|
_FILENAME_RE = re.compile(r"batch[_-]?(\d+)", re.IGNORECASE)
|
||||||
|
|
||||||
_streaming_mp4 = None
|
_streaming_mp4 = None
|
||||||
_streaming_lock = threading.Lock()
|
_streaming_lock = threading.Lock()
|
||||||
@@ -50,12 +50,9 @@ _current_file = None
|
|||||||
|
|
||||||
|
|
||||||
def _parse_filename(filename):
|
def _parse_filename(filename):
|
||||||
m = _FILENAME_RE.match(filename)
|
m = _FILENAME_RE.search(filename)
|
||||||
if m:
|
if m:
|
||||||
batch_num = int(m.group(1))
|
return int(m.group(1)), None
|
||||||
date_str = m.group(2)
|
|
||||||
date_formatted = f"{date_str[:4]}-{date_str[4:6]}-{date_str[6:8]}"
|
|
||||||
return batch_num, date_formatted
|
|
||||||
return None, None
|
return None, None
|
||||||
|
|
||||||
|
|
||||||
@@ -220,7 +217,9 @@ def api_batch_result():
|
|||||||
if batch_num is None:
|
if batch_num is None:
|
||||||
return jsonify({"success": False, "error": "Cannot parse batch number from filename"}), 200
|
return jsonify({"success": False, "error": "Cannot parse batch number from filename"}), 200
|
||||||
|
|
||||||
date_str = _folder_date(fpath) or _parse_filename(filename)[1]
|
date_str = _folder_date(fpath)
|
||||||
|
if not date_str:
|
||||||
|
return jsonify({"success": False, "error": "Cannot determine date from folder"}), 200
|
||||||
|
|
||||||
def _match_in_batches(batches):
|
def _match_in_batches(batches):
|
||||||
for b in batches:
|
for b in batches:
|
||||||
|
|||||||
Reference in new issue
Block a user