diff --git a/hik_push/__pycache__/event_map_mapping.cpython-312.pyc b/hik_push/__pycache__/event_map_mapping.cpython-312.pyc deleted file mode 100644 index 2111ca4..0000000 Binary files a/hik_push/__pycache__/event_map_mapping.cpython-312.pyc and /dev/null differ diff --git a/hik_push/__pycache__/main.cpython-312.pyc b/hik_push/__pycache__/main.cpython-312.pyc index 011d451..3e339fe 100644 Binary files a/hik_push/__pycache__/main.cpython-312.pyc and b/hik_push/__pycache__/main.cpython-312.pyc differ diff --git a/hik_push/event_map_mapping.py b/hik_push/event_map_mapping.py deleted file mode 100644 index 7b28fe8..0000000 --- a/hik_push/event_map_mapping.py +++ /dev/null @@ -1,45 +0,0 @@ -mapping = { - 131329: {"type": '视频丢失', "analyze_key": None}, - 131330: {"type": '视频遮挡', "analyze_key": None}, - 131331: {"type": '移动侦测', "analyze_key": None}, - 131612: {"type": '场景变更', "analyze_key": None}, - 131613: {"type": '虚焦', "analyze_key": None}, - 589825: {"type": '报警输入', "analyze_key": None}, - 196355: {"type": '可视域事件', "analyze_key": None}, - 851969: {"type": 'GPS采集', "analyze_key": None}, - 131588: {"type": '区域入侵', "analyze_key": "fielddetection"}, - 131585: {"type": '越界侦测', "analyze_key": "linedetection"}, - 131586: {"type": '进入区域', "analyze_key": "regionEntrance"}, - 131587: {"type": '离开区域', "analyze_key": "regionExiting"}, - 131590: {"type": '徘徊侦测', "analyze_key": "loitering"}, - 131593: {"type": '人员聚集', "analyze_key": "group"}, - 131592: {"type": '快速移动', "analyze_key": "rapidMove"}, - 131591: {"type": '停车侦测', "analyze_key": "parking"}, - 131594: {"type": '物品遗留', "analyze_key": "unattendedBaggage"}, - 131595: {"type": '物品拿取', "analyze_key": "attendedBaggage"}, - 131664: {"type": '人数异常', "analyze_key": "peoplenumChange"}, - 131665: {"type": '间距异常', "analyze_key": "spacingChange"}, - 131596: {"type": '剧烈运动', "analyze_key": "violentMotion"}, - 131603: {"type": '岗位值守', "analyze_key": "leavePosition"}, - 131605: {"type": '倒地', "analyze_key": "fallDown"}, - 131597: {"type": '攀高', "analyze_key": "reachHight"}, - 131666: {"type": '人员站立', "analyze_key": "standUp"}, - 131609: {"type": '防风场滞留', "analyze_key": "yardTarry"}, - 131598: {"type": '起身', "analyze_key": "getUp"}, - 131599: {"type": '人靠近ATM', "analyze_key": "humanEnter"}, - 131600: {"type": '操作超时', "analyze_key": "overTime"}, - 131601: {"type": '贴纸条', "analyze_key": "stickUp"}, - 131602: {"type": '安装读卡器', "analyze_key": "installScanner"}, - 131604: {"type": '尾随', "analyze_key": "trail"}, - 131606: {"type": '声强突变', "analyze_key": "audioAbnormal"}, - 131607: {"type": '折线攀高', "analyze_key": "advReachHeight"}, - 131611: {"type": '折线警戒面', "analyze_key": "advTraversePlane"}, - 192518: {"type": '温差报警', "analyze_key": "thermometryDiff"}, - 192517: {"type": '温度报警', "analyze_key": "thermometry"}, - 192516: {"type": '船只检测', "analyze_key": "shipDetection"}, - 192515: {"type": '火点检测', "analyze_key": "fireDetection"}, - 192514: {"type": '烟火检测', "analyze_key": "smokeAndFireDetection"}, - 192513: {"type": '烟雾检测', "analyze_key": "smokeDetection"}, - 930335: {"type": '高空抛物', "analyze_key": None}, - 889196545: {"type": '监控点离线', "analyze_key": None}, -} diff --git a/hik_push/main.py b/hik_push/main.py index 7b5d91b..e251287 100644 --- a/hik_push/main.py +++ b/hik_push/main.py @@ -10,18 +10,11 @@ app = FastAPI() async def add_stream(data: dict): - redis = await aioredis.from_url("redis://localhost", db=0) - await redis.lpush("event", json.dumps(data)) - # await redis.xadd("hik-event", {"event": json.dumps(data)}) + redis = await aioredis.Redis(host="127.0.0.1", port=6379) + await redis.lpush("hik-sub-event", json.dumps(data)) await redis.close() -@app.post("/upload") -async def upload_file(file: UploadFile): - print(file) - return {"message": "success"} - - @app.get("/") async def root(): return {"message": "Hello World"} @@ -30,7 +23,7 @@ async def root(): @app.post("/eventRcv") async def event_rcv(data: dict, background_tasks: BackgroundTasks): background_tasks.add_task(add_stream, data) - return {"data": data} + return {"msg": "success"} def run_app(): diff --git a/hik_push/mapping/__init__.py b/hik_push/mapping/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/hik_push/mapping/__pycache__/__init__.cpython-312.pyc b/hik_push/mapping/__pycache__/__init__.cpython-312.pyc new file mode 100644 index 0000000..0cad1e1 Binary files /dev/null and b/hik_push/mapping/__pycache__/__init__.cpython-312.pyc differ diff --git a/hik_push/mapping/__pycache__/device_map.cpython-312.pyc b/hik_push/mapping/__pycache__/device_map.cpython-312.pyc new file mode 100644 index 0000000..23c493e Binary files /dev/null and b/hik_push/mapping/__pycache__/device_map.cpython-312.pyc differ diff --git a/hik_push/mapping/__pycache__/event_map_mapping.cpython-312.pyc b/hik_push/mapping/__pycache__/event_map_mapping.cpython-312.pyc new file mode 100644 index 0000000..5edd953 Binary files /dev/null and b/hik_push/mapping/__pycache__/event_map_mapping.cpython-312.pyc differ diff --git a/hik_push/mapping/device_map.py b/hik_push/mapping/device_map.py new file mode 100644 index 0000000..a52c4b0 --- /dev/null +++ b/hik_push/mapping/device_map.py @@ -0,0 +1,15 @@ +device_map = { + "192.168.1.12": "4GB-供油站", + "192.168.1.13": "T2变电所", + "192.168.1.14": "二厂平台~西", + "192.168.1.15": "二厂平台~中o1", + "192.168.1.16": "T1变电所", + "192.168.1.17": "二厂平台~东", + "192.168.1.18": "二厂平台~中o2", + "192.168.1.19": "T3变电所", + "192.168.1.20": "T11变电所", + "192.168.1.21": "4GA-供油站", + "192.168.1.22": "T9-变压器", + "192.168.1.23": "T6-变压器", + "192.168.1.24": "4DB-供油站", +} diff --git a/hik_push/mapping/event_map_mapping.py b/hik_push/mapping/event_map_mapping.py new file mode 100644 index 0000000..73f4b08 --- /dev/null +++ b/hik_push/mapping/event_map_mapping.py @@ -0,0 +1,45 @@ +mapping = { + 131329: '视频丢失', + 131330: '视频遮挡', + 131331: '移动侦测', + 131612: '场景变更', + 131613: '虚焦', + 589825: '报警输入', + 196355: '可视域事件', + 851969: 'GPS采集', + 131588: '区域入侵', + 131585: '越界侦测', + 131586: '进入区域', + 131587: '离开区域', + 131590: '徘徊侦测', + 131593: '人员聚集', + 131592: '快速移动', + 131591: '停车侦测', + 131594: '物品遗留', + 131595: '物品拿取', + 131664: '人数异常', + 131665: '间距异常', + 131596: '剧烈运动', + 131603: '岗位值守', + 131605: '倒地', + 131597: '攀高', + 131666: '人员站立', + 131609: '防风场滞留', + 131598: '起身', + 131599: '人靠近ATM', + 131600: '操作超时', + 131601: '贴纸条', + 131602: '安装读卡器', + 131604: '尾随', + 131606: '声强突变', + 131607: '折线攀高', + 131611: '折线警戒面', + 192518: '温差报警', + 192517: '温度报警', + 192516: '船只检测', + 192515: '火点检测', + 192514: '烟火检测', + 192513: '烟雾检测', + 930335: '高空抛物', + 889196545: '监控点离线', +} diff --git a/hik_push/mapping/user_map.py b/hik_push/mapping/user_map.py new file mode 100644 index 0000000..e332f42 --- /dev/null +++ b/hik_push/mapping/user_map.py @@ -0,0 +1,17 @@ +user_map = { + "192.168.1.12": [ + + ], + "192.168.1.13": [], + "192.168.1.14": [], + "192.168.1.15": [], + "192.168.1.16": [], + "192.168.1.17": [], + "192.168.1.18": [], + "192.168.1.19": [], + "192.168.1.20": [], + "192.168.1.21": [], + "192.168.1.22": [], + "192.168.1.23": [], + "192.168.1.24": [], +} diff --git a/hik_push/mypackages/Jinja2-3.1.3-py3-none-any.whl b/hik_push/mypackages/Jinja2-3.1.3-py3-none-any.whl new file mode 100644 index 0000000..eeb2bc7 Binary files /dev/null and b/hik_push/mypackages/Jinja2-3.1.3-py3-none-any.whl differ diff --git a/hik_push/mypackages/MarkupSafe-2.1.4-cp312-cp312-win_amd64.whl b/hik_push/mypackages/MarkupSafe-2.1.4-cp312-cp312-win_amd64.whl new file mode 100644 index 0000000..756a3d5 Binary files /dev/null and b/hik_push/mypackages/MarkupSafe-2.1.4-cp312-cp312-win_amd64.whl differ diff --git a/hik_push/mypackages/PyYAML-6.0.1-cp312-cp312-win_amd64.whl b/hik_push/mypackages/PyYAML-6.0.1-cp312-cp312-win_amd64.whl new file mode 100644 index 0000000..a86cba1 Binary files /dev/null and b/hik_push/mypackages/PyYAML-6.0.1-cp312-cp312-win_amd64.whl differ diff --git a/hik_push/mypackages/annotated_types-0.6.0-py3-none-any.whl b/hik_push/mypackages/annotated_types-0.6.0-py3-none-any.whl new file mode 100644 index 0000000..acb80e7 Binary files /dev/null and b/hik_push/mypackages/annotated_types-0.6.0-py3-none-any.whl differ diff --git a/hik_push/mypackages/anyio-4.2.0-py3-none-any.whl b/hik_push/mypackages/anyio-4.2.0-py3-none-any.whl new file mode 100644 index 0000000..0e79d9f Binary files /dev/null and b/hik_push/mypackages/anyio-4.2.0-py3-none-any.whl differ diff --git a/hik_push/mypackages/certifi-2023.11.17-py3-none-any.whl b/hik_push/mypackages/certifi-2023.11.17-py3-none-any.whl new file mode 100644 index 0000000..de0787f Binary files /dev/null and b/hik_push/mypackages/certifi-2023.11.17-py3-none-any.whl differ diff --git a/hik_push/mypackages/charset_normalizer-3.3.2-cp312-cp312-win_amd64.whl b/hik_push/mypackages/charset_normalizer-3.3.2-cp312-cp312-win_amd64.whl new file mode 100644 index 0000000..4823180 Binary files /dev/null and b/hik_push/mypackages/charset_normalizer-3.3.2-cp312-cp312-win_amd64.whl differ diff --git a/hik_push/mypackages/click-8.1.7-py3-none-any.whl b/hik_push/mypackages/click-8.1.7-py3-none-any.whl new file mode 100644 index 0000000..5e8a550 Binary files /dev/null and b/hik_push/mypackages/click-8.1.7-py3-none-any.whl differ diff --git a/hik_push/mypackages/colorama-0.4.6-py2.py3-none-any.whl b/hik_push/mypackages/colorama-0.4.6-py2.py3-none-any.whl new file mode 100644 index 0000000..f666ce9 Binary files /dev/null and b/hik_push/mypackages/colorama-0.4.6-py2.py3-none-any.whl differ diff --git a/hik_push/mypackages/dnspython-2.5.0-py3-none-any.whl b/hik_push/mypackages/dnspython-2.5.0-py3-none-any.whl new file mode 100644 index 0000000..46fef8d Binary files /dev/null and b/hik_push/mypackages/dnspython-2.5.0-py3-none-any.whl differ diff --git a/hik_push/mypackages/email_validator-2.1.0.post1-py3-none-any.whl b/hik_push/mypackages/email_validator-2.1.0.post1-py3-none-any.whl new file mode 100644 index 0000000..c745ec2 Binary files /dev/null and b/hik_push/mypackages/email_validator-2.1.0.post1-py3-none-any.whl differ diff --git a/hik_push/mypackages/fastapi-0.109.0-py3-none-any.whl b/hik_push/mypackages/fastapi-0.109.0-py3-none-any.whl new file mode 100644 index 0000000..894ff08 Binary files /dev/null and b/hik_push/mypackages/fastapi-0.109.0-py3-none-any.whl differ diff --git a/hik_push/mypackages/h11-0.14.0-py3-none-any.whl b/hik_push/mypackages/h11-0.14.0-py3-none-any.whl new file mode 100644 index 0000000..a02c8de Binary files /dev/null and b/hik_push/mypackages/h11-0.14.0-py3-none-any.whl differ diff --git a/hik_push/mypackages/hik_push-0.1.0.zip b/hik_push/mypackages/hik_push-0.1.0.zip new file mode 100644 index 0000000..077efdc Binary files /dev/null and b/hik_push/mypackages/hik_push-0.1.0.zip differ diff --git a/hik_push/mypackages/httpcore-1.0.2-py3-none-any.whl b/hik_push/mypackages/httpcore-1.0.2-py3-none-any.whl new file mode 100644 index 0000000..8bb8a4a Binary files /dev/null and b/hik_push/mypackages/httpcore-1.0.2-py3-none-any.whl differ diff --git a/hik_push/mypackages/httptools-0.6.1-cp312-cp312-win_amd64.whl b/hik_push/mypackages/httptools-0.6.1-cp312-cp312-win_amd64.whl new file mode 100644 index 0000000..4198ead Binary files /dev/null and b/hik_push/mypackages/httptools-0.6.1-cp312-cp312-win_amd64.whl differ diff --git a/hik_push/mypackages/httpx-0.26.0-py3-none-any.whl b/hik_push/mypackages/httpx-0.26.0-py3-none-any.whl new file mode 100644 index 0000000..1d984fd Binary files /dev/null and b/hik_push/mypackages/httpx-0.26.0-py3-none-any.whl differ diff --git a/hik_push/mypackages/idna-3.6-py3-none-any.whl b/hik_push/mypackages/idna-3.6-py3-none-any.whl new file mode 100644 index 0000000..fdf65ae Binary files /dev/null and b/hik_push/mypackages/idna-3.6-py3-none-any.whl differ diff --git a/hik_push/mypackages/itsdangerous-2.1.2-py3-none-any.whl b/hik_push/mypackages/itsdangerous-2.1.2-py3-none-any.whl new file mode 100644 index 0000000..2260642 Binary files /dev/null and b/hik_push/mypackages/itsdangerous-2.1.2-py3-none-any.whl differ diff --git a/hik_push/mypackages/orjson-3.9.12-cp312-none-win_amd64.whl b/hik_push/mypackages/orjson-3.9.12-cp312-none-win_amd64.whl new file mode 100644 index 0000000..f3a75d1 Binary files /dev/null and b/hik_push/mypackages/orjson-3.9.12-cp312-none-win_amd64.whl differ diff --git a/hik_push/mypackages/pydantic-2.5.3-py3-none-any.whl b/hik_push/mypackages/pydantic-2.5.3-py3-none-any.whl new file mode 100644 index 0000000..ea5efe7 Binary files /dev/null and b/hik_push/mypackages/pydantic-2.5.3-py3-none-any.whl differ diff --git a/hik_push/mypackages/pydantic_core-2.14.6-cp312-none-win_amd64.whl b/hik_push/mypackages/pydantic_core-2.14.6-cp312-none-win_amd64.whl new file mode 100644 index 0000000..41df158 Binary files /dev/null and b/hik_push/mypackages/pydantic_core-2.14.6-cp312-none-win_amd64.whl differ diff --git a/hik_push/mypackages/pydantic_extra_types-2.4.1-py3-none-any.whl b/hik_push/mypackages/pydantic_extra_types-2.4.1-py3-none-any.whl new file mode 100644 index 0000000..4a5c8b3 Binary files /dev/null and b/hik_push/mypackages/pydantic_extra_types-2.4.1-py3-none-any.whl differ diff --git a/hik_push/mypackages/pydantic_settings-2.1.0-py3-none-any.whl b/hik_push/mypackages/pydantic_settings-2.1.0-py3-none-any.whl new file mode 100644 index 0000000..8753b30 Binary files /dev/null and b/hik_push/mypackages/pydantic_settings-2.1.0-py3-none-any.whl differ diff --git a/hik_push/mypackages/python_dotenv-1.0.0-py3-none-any.whl b/hik_push/mypackages/python_dotenv-1.0.0-py3-none-any.whl new file mode 100644 index 0000000..a31e5ae Binary files /dev/null and b/hik_push/mypackages/python_dotenv-1.0.0-py3-none-any.whl differ diff --git a/hik_push/mypackages/python_multipart-0.0.6-py3-none-any.whl b/hik_push/mypackages/python_multipart-0.0.6-py3-none-any.whl new file mode 100644 index 0000000..376ccec Binary files /dev/null and b/hik_push/mypackages/python_multipart-0.0.6-py3-none-any.whl differ diff --git a/hik_push/mypackages/redis-5.0.1-py3-none-any.whl b/hik_push/mypackages/redis-5.0.1-py3-none-any.whl new file mode 100644 index 0000000..68c8184 Binary files /dev/null and b/hik_push/mypackages/redis-5.0.1-py3-none-any.whl differ diff --git a/hik_push/mypackages/requests-2.31.0-py3-none-any.whl b/hik_push/mypackages/requests-2.31.0-py3-none-any.whl new file mode 100644 index 0000000..bfd5d2e Binary files /dev/null and b/hik_push/mypackages/requests-2.31.0-py3-none-any.whl differ diff --git a/hik_push/mypackages/sniffio-1.3.0-py3-none-any.whl b/hik_push/mypackages/sniffio-1.3.0-py3-none-any.whl new file mode 100644 index 0000000..7d72f26 Binary files /dev/null and b/hik_push/mypackages/sniffio-1.3.0-py3-none-any.whl differ diff --git a/hik_push/mypackages/starlette-0.35.1-py3-none-any.whl b/hik_push/mypackages/starlette-0.35.1-py3-none-any.whl new file mode 100644 index 0000000..5b5fac0 Binary files /dev/null and b/hik_push/mypackages/starlette-0.35.1-py3-none-any.whl differ diff --git a/hik_push/mypackages/typing_extensions-4.9.0-py3-none-any.whl b/hik_push/mypackages/typing_extensions-4.9.0-py3-none-any.whl new file mode 100644 index 0000000..32a7666 Binary files /dev/null and b/hik_push/mypackages/typing_extensions-4.9.0-py3-none-any.whl differ diff --git a/hik_push/mypackages/ujson-5.9.0-cp312-cp312-win_amd64.whl b/hik_push/mypackages/ujson-5.9.0-cp312-cp312-win_amd64.whl new file mode 100644 index 0000000..3a9b36f Binary files /dev/null and b/hik_push/mypackages/ujson-5.9.0-cp312-cp312-win_amd64.whl differ diff --git a/hik_push/mypackages/urllib3-2.1.0-py3-none-any.whl b/hik_push/mypackages/urllib3-2.1.0-py3-none-any.whl new file mode 100644 index 0000000..0951ac3 Binary files /dev/null and b/hik_push/mypackages/urllib3-2.1.0-py3-none-any.whl differ diff --git a/hik_push/mypackages/uvicorn-0.26.0-py3-none-any.whl b/hik_push/mypackages/uvicorn-0.26.0-py3-none-any.whl new file mode 100644 index 0000000..890c2c3 Binary files /dev/null and b/hik_push/mypackages/uvicorn-0.26.0-py3-none-any.whl differ diff --git a/hik_push/mypackages/watchfiles-0.21.0-cp312-none-win_amd64.whl b/hik_push/mypackages/watchfiles-0.21.0-cp312-none-win_amd64.whl new file mode 100644 index 0000000..33c6c73 Binary files /dev/null and b/hik_push/mypackages/watchfiles-0.21.0-cp312-none-win_amd64.whl differ diff --git a/hik_push/mypackages/websockets-12.0-cp312-cp312-win_amd64.whl b/hik_push/mypackages/websockets-12.0-cp312-cp312-win_amd64.whl new file mode 100644 index 0000000..8116c59 Binary files /dev/null and b/hik_push/mypackages/websockets-12.0-cp312-cp312-win_amd64.whl differ diff --git a/hik_push/read_event.py b/hik_push/read_event.py index c25a8ed..8194fda 100644 --- a/hik_push/read_event.py +++ b/hik_push/read_event.py @@ -5,7 +5,9 @@ from io import BytesIO import requests from custom_exception import FeishuAuthException -from event_map_mapping import mapping +from mapping.event_map_mapping import mapping +from mapping.device_map import device_map +from mapping.user_map import user_map from redis import asyncio as aioredis @@ -27,7 +29,7 @@ def get_access_token(api_id, secret): # 获取事件的图片 def get_image_url(event): - analysis_key = mapping.get(event['eventType'])['analyze_key'] + analysis_key = mapping.get(event['eventType'])['detection_key'] if analysis_key is None: return None images = [] @@ -65,7 +67,6 @@ def upload_image(url): # 推送到飞书 def push_to_feishu(data): push_url = "https://open.feishu.cn/open-apis/message/v4/batch_send/" - # push_url = "http://192.168.20.115:8000/ipaasuat/engine_company/anycross/trigger/callback/MmRhZTE4OTRiYjVkZDQ5YWNmOGRmZDI0NjQ1MTBlODUw/1.0.0" data = json.dumps(data) r = requests.post(push_url, data=data, headers=headers).content.decode('utf-8') data = json.loads(r) @@ -76,92 +77,34 @@ def push_to_feishu(data): async def read_event(): - access_token = get_access_token(app_id, app_secret) - headers['Authorization'] = f"Bearer {access_token}" - redis_client = await aioredis.from_url("redis://localhost") + redis_client = await aioredis.Redis(host="127.0.0.1", port=6379) while True: - data = await redis_client.brpop("event") - event_json = json.loads(data[1].decode('utf-8')) + data = await redis_client.brpop("hik-sub-event") + sub_json = json.loads(data[1].decode('utf-8')) try: - events = event_json["params"]["events"] + events = sub_json["params"]["events"] for event in events: - event_type = mapping.get(event['eventType'], {"type": "未知事件类型"}) - print(event_type) - # TODO: 上传图片到飞书链接 - images = get_image_url(event) - feishu_image_key = None - if images is not None: - feishu_image_key = upload_image(images[0]) - print(feishu_image_key) - - # TODO: 根据ip_address获取对应userid - # + # 将eventType ID 替换为中文字符串 + event_type = event['eventType'] + event_type_str = mapping.get(event_type, "未知事件类型") + event['eventType'] = event_type_str + # ip address ip_address = event["data"]["ipAddress"] - # channel_name = get_value_by_nested_key(event, ("data", "channelName")) + # 根据 ip_address 获取对应设备名称 + device_name = device_map.get(ip_address, "未知设备") + event['deviceName'] = device_name + # print(event['data'][event['data']['eventType']]) + # TODO: 根据 ip_address 获取对应 userid + user_ids = user_map.get(ip_address, []) + event['userIds'] = user_ids + # TODO: 请求推送 api + # + print(event, device_name) - # TODO: 向飞书推送消息 - push_data = { - "user_ids": [ - "8dg79c18" - ], - "msg_type": "interactive", - "card": { - "config": { - "wide_screen_mode": True - }, - "elements": [ - { - "tag": "markdown", - "content": "这里是卡片文本,支持使用markdown标签设置文本格式。例如:\n*斜体* 、**粗体**、~~删除线~~、[文字链接](" - "https://www.feishu.cn)、 彩色文本 " - }, - { - "alt": { - "content": "", - "tag": "plain_text" - }, - "img_key": feishu_image_key, - "tag": "img", - "mode": "fit_horizontal", - "compact_width": False - }, - { - "tag": "action", - "actions": [ - { - "tag": "button", - "text": { - "tag": "plain_text", - "content": "这是跳转按钮" - }, - "type": "primary", - "url": "https://feishu.cn" - } - ] - } - ], - "header": { - "template": "blue", - "title": { - "content": event_type["type"], - "tag": "plain_text" - } - } - } - } - push_to_feishu(push_data) - print(event_type["type"], ip_address) - - except FeishuAuthException: - print("飞书登录失败") - # TODO: 重新获取 access token - access_token = get_access_token(app_id, app_secret) - headers['Authorization'] = f"Bearer {access_token}" - await redis_client.lpush("event", json.dumps(event_json)) - continue except Exception as e: print("error: ", e) continue + await asyncio.sleep(0.5) if __name__ == "__main__": diff --git a/hik_push/requirements.txt b/hik_push/requirements.txt new file mode 100644 index 0000000..d8995d9 --- /dev/null +++ b/hik_push/requirements.txt @@ -0,0 +1,36 @@ +annotated-types==0.6.0 +anyio==4.2.0 +certifi==2023.11.17 +charset-normalizer==3.3.2 +click==8.1.7 +colorama==0.4.6 +dnspython==2.5.0 +email-validator==2.1.0.post1 +fastapi==0.109.0 +h11==0.14.0 +-e git+http://101.43.70.124:3000/cxc/hik-push.git@6b679957040979034a03da39c78011a26285dc7e#egg=hik_push +httpcore==1.0.2 +httptools==0.6.1 +httpx==0.26.0 +idna==3.6 +itsdangerous==2.1.2 +Jinja2==3.1.3 +MarkupSafe==2.1.4 +orjson==3.9.12 +pydantic==2.5.3 +pydantic-extra-types==2.4.1 +pydantic-settings==2.1.0 +pydantic_core==2.14.6 +python-dotenv==1.0.0 +python-multipart==0.0.6 +PyYAML==6.0.1 +redis==5.0.1 +requests==2.31.0 +sniffio==1.3.0 +starlette==0.35.1 +typing_extensions==4.9.0 +ujson==5.9.0 +urllib3==2.1.0 +uvicorn==0.26.0 +watchfiles==0.21.0 +websockets==12.0 diff --git a/hik_push/user_map.py b/hik_push/user_map.py deleted file mode 100644 index 40a4be7..0000000 --- a/hik_push/user_map.py +++ /dev/null @@ -1,5 +0,0 @@ -user_map = { - "10.19.134.11": [ - "8dg79c18" - ] -}