mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-02-05 18:55:23 +03:00
remove code from other branch (merging fuckup)
This commit is contained in:
parent
b525716dc7
commit
93c5090414
@ -3,7 +3,6 @@
|
|||||||
import asyncio
|
import asyncio
|
||||||
import datetime
|
import datetime
|
||||||
import logging
|
import logging
|
||||||
import multiprocessing as mp
|
|
||||||
import os
|
import os
|
||||||
import queue
|
import queue
|
||||||
import random
|
import random
|
||||||
|
|||||||
@ -1226,69 +1226,6 @@ def get_video_properties(url, get_duration=False):
|
|||||||
return result
|
return result
|
||||||
|
|
||||||
|
|
||||||
def update_yaml_from_url(file_path, url):
|
|
||||||
parsed_url = urllib.parse.urlparse(url)
|
|
||||||
query_string = urllib.parse.parse_qs(parsed_url.query, keep_blank_values=True)
|
|
||||||
|
|
||||||
for key_path_str, new_value_list in query_string.items():
|
|
||||||
key_path = key_path_str.split(".")
|
|
||||||
for i in range(len(key_path)):
|
|
||||||
try:
|
|
||||||
index = int(key_path[i])
|
|
||||||
key_path[i] = (key_path[i - 1], index)
|
|
||||||
key_path.pop(i - 1)
|
|
||||||
except ValueError:
|
|
||||||
pass
|
|
||||||
new_value = new_value_list[0]
|
|
||||||
update_yaml_file(file_path, key_path, new_value)
|
|
||||||
|
|
||||||
|
|
||||||
def update_yaml_file(file_path, key_path, new_value):
|
|
||||||
yaml = YAML()
|
|
||||||
with open(file_path, "r") as f:
|
|
||||||
data = yaml.load(f)
|
|
||||||
|
|
||||||
temp = data
|
|
||||||
for key in key_path[:-1]:
|
|
||||||
if isinstance(key, tuple):
|
|
||||||
if key[0] not in temp:
|
|
||||||
temp[key[0]] = [{}] * max(1, key[1] + 1)
|
|
||||||
elif len(temp[key[0]]) <= key[1]:
|
|
||||||
temp[key[0]] += [{}] * (key[1] - len(temp[key[0]]) + 1)
|
|
||||||
temp = temp[key[0]][key[1]]
|
|
||||||
else:
|
|
||||||
if key not in temp:
|
|
||||||
temp[key] = []
|
|
||||||
temp = temp[key]
|
|
||||||
print(new_value)
|
|
||||||
last_key = key_path[-1]
|
|
||||||
if new_value == "":
|
|
||||||
print(last_key)
|
|
||||||
if isinstance(last_key, tuple):
|
|
||||||
del temp[last_key[0]][last_key[1]]
|
|
||||||
else:
|
|
||||||
del temp[last_key]
|
|
||||||
else:
|
|
||||||
if isinstance(last_key, tuple):
|
|
||||||
if last_key[0] not in temp:
|
|
||||||
temp[last_key[0]] = [{}] * max(1, last_key[1] + 1)
|
|
||||||
elif len(temp[last_key[0]]) <= last_key[1]:
|
|
||||||
temp[last_key[0]] += [{}] * (last_key[1] - len(temp[last_key[0]]) + 1)
|
|
||||||
temp[last_key[0]][last_key[1]] = new_value
|
|
||||||
else:
|
|
||||||
if (
|
|
||||||
last_key in temp
|
|
||||||
and isinstance(temp[last_key], dict)
|
|
||||||
and isinstance(new_value, dict)
|
|
||||||
):
|
|
||||||
temp[last_key].update(new_value)
|
|
||||||
else:
|
|
||||||
temp[last_key] = new_value
|
|
||||||
|
|
||||||
with open(file_path, "w") as f:
|
|
||||||
yaml.dump(data, f)
|
|
||||||
|
|
||||||
|
|
||||||
class LimitedQueue(FFQueue):
|
class LimitedQueue(FFQueue):
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user