some include magic; add tools/ipcam_stream.py
This commit is contained in:
parent
d638bb4f58
commit
7092c79b56
@ -1,7 +1,7 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
import asyncio
|
import asyncio
|
||||||
import time
|
import time
|
||||||
import __py_include
|
import include_homekit
|
||||||
|
|
||||||
from homekit.config import config
|
from homekit.config import config
|
||||||
from homekit.media import MediaNodeServer, ESP32CameraRecordStorage, CameraRecorder
|
from homekit.media import MediaNodeServer, ESP32CameraRecordStorage, CameraRecorder
|
||||||
|
@ -3,7 +3,7 @@ import logging
|
|||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
import inspect
|
import inspect
|
||||||
import __py_include
|
import include_homekit
|
||||||
|
|
||||||
from homekit.config import config # do not remove this import!
|
from homekit.config import config # do not remove this import!
|
||||||
from datetime import datetime, timedelta
|
from datetime import datetime, timedelta
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
import asyncio
|
import asyncio
|
||||||
import logging
|
import logging
|
||||||
import os.path
|
import os.path
|
||||||
import __py_include
|
import include_homekit
|
||||||
|
|
||||||
from argparse import ArgumentParser
|
from argparse import ArgumentParser
|
||||||
from homekit.camera.esp32 import WebClient
|
from homekit.camera.esp32 import WebClient
|
||||||
|
@ -3,7 +3,7 @@ import asyncio
|
|||||||
import logging
|
import logging
|
||||||
import os.path
|
import os.path
|
||||||
import tempfile
|
import tempfile
|
||||||
import __py_include
|
import include_homekit
|
||||||
import homekit.telegram.aio as telegram
|
import homekit.telegram.aio as telegram
|
||||||
|
|
||||||
from homekit.config import config
|
from homekit.config import config
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
import __py_include
|
import include_homekit
|
||||||
|
|
||||||
from argparse import ArgumentParser
|
from argparse import ArgumentParser
|
||||||
from homekit.util import Addr
|
from homekit.util import Addr
|
||||||
|
1
bin/include_homekit.py
Symbolic link
1
bin/include_homekit.py
Symbolic link
@ -0,0 +1 @@
|
|||||||
|
../include_homekit.py
|
@ -6,7 +6,7 @@ import json
|
|||||||
import itertools
|
import itertools
|
||||||
import sys
|
import sys
|
||||||
import asyncio
|
import asyncio
|
||||||
import __py_include
|
import include_homekit
|
||||||
|
|
||||||
from inverterd import Format, InverterError
|
from inverterd import Format, InverterError
|
||||||
from html import escape
|
from html import escape
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
import __py_include
|
import include_homekit
|
||||||
|
|
||||||
from argparse import ArgumentParser
|
from argparse import ArgumentParser
|
||||||
from homekit.config import config
|
from homekit.config import config
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
import logging
|
import logging
|
||||||
import __py_include
|
import include_homekit
|
||||||
|
|
||||||
from homekit.inverter.emulator import InverterEmulator
|
from homekit.inverter.emulator import InverterEmulator
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
import __py_include
|
import include_homekit
|
||||||
import sys
|
import sys
|
||||||
import os
|
import os
|
||||||
import subprocess
|
import subprocess
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
import __py_include
|
import include_homekit
|
||||||
import hikvision, xmeye
|
import hikvision, xmeye
|
||||||
|
|
||||||
from enum import Enum, auto
|
from enum import Enum, auto
|
||||||
|
@ -4,7 +4,7 @@ import os
|
|||||||
import asyncio
|
import asyncio
|
||||||
import time
|
import time
|
||||||
import shutil
|
import shutil
|
||||||
import __py_include
|
import include_homekit
|
||||||
|
|
||||||
import homekit.telegram.aio as telegram
|
import homekit.telegram.aio as telegram
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
import datetime
|
import datetime
|
||||||
import __py_include
|
import include_homekit
|
||||||
|
|
||||||
from enum import Enum
|
from enum import Enum
|
||||||
from typing import Optional
|
from typing import Optional
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
import os.path
|
import os.path
|
||||||
import __py_include
|
import include_homekit
|
||||||
|
|
||||||
from time import sleep
|
from time import sleep
|
||||||
from typing import Optional
|
from typing import Optional
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
import __py_include
|
import include_homekit
|
||||||
import homekit.telegram as telegram
|
import homekit.telegram as telegram
|
||||||
|
|
||||||
from homekit.telegram.config import TelegramChatsConfig
|
from homekit.telegram.config import TelegramChatsConfig
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
import os
|
import os
|
||||||
import __py_include
|
import include_homekit
|
||||||
|
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from typing import Tuple, List, Optional
|
from typing import Tuple, List, Optional
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
import __py_include
|
import include_homekit
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
print('TODO')
|
print('TODO')
|
@ -2,7 +2,7 @@
|
|||||||
import os
|
import os
|
||||||
import yaml
|
import yaml
|
||||||
import re
|
import re
|
||||||
import __py_include
|
import include_homekit
|
||||||
|
|
||||||
from argparse import ArgumentParser, ArgumentError
|
from argparse import ArgumentParser, ArgumentError
|
||||||
from homekit.pio import get_products, platformio_ini
|
from homekit.pio import get_products, platformio_ini
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
import __py_include
|
import include_homekit
|
||||||
import logging
|
import logging
|
||||||
import locale
|
import locale
|
||||||
import queue
|
import queue
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
import logging
|
import logging
|
||||||
import sys
|
import sys
|
||||||
import paho.mqtt.client as mqtt
|
import paho.mqtt.client as mqtt
|
||||||
import __py_include
|
import include_homekit
|
||||||
|
|
||||||
from typing import Optional
|
from typing import Optional
|
||||||
from argparse import ArgumentParser
|
from argparse import ArgumentParser
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
import __py_include
|
import include_homekit
|
||||||
import sys
|
import sys
|
||||||
import asyncio
|
import asyncio
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
import datetime
|
import datetime
|
||||||
import __py_include
|
import include_homekit
|
||||||
|
|
||||||
from enum import Enum
|
from enum import Enum
|
||||||
from typing import Optional
|
from typing import Optional
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
import sys
|
import sys
|
||||||
import __py_include
|
import include_homekit
|
||||||
|
|
||||||
from enum import Enum
|
from enum import Enum
|
||||||
from typing import Optional, Union
|
from typing import Optional, Union
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
import logging
|
import logging
|
||||||
import __py_include
|
import include_homekit
|
||||||
|
|
||||||
from aiohttp import web
|
from aiohttp import web
|
||||||
from homekit import http
|
from homekit import http
|
||||||
|
@ -4,7 +4,7 @@ import socket
|
|||||||
import logging
|
import logging
|
||||||
import re
|
import re
|
||||||
import gc
|
import gc
|
||||||
import __py_include
|
import include_homekit
|
||||||
|
|
||||||
from io import BytesIO
|
from io import BytesIO
|
||||||
from typing import Optional
|
from typing import Optional
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
import tempfile
|
import tempfile
|
||||||
import __py_include
|
import include_homekit
|
||||||
|
|
||||||
from enum import Enum
|
from enum import Enum
|
||||||
from datetime import datetime, timedelta
|
from datetime import datetime, timedelta
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
import os
|
import os
|
||||||
import __py_include
|
import include_homekit
|
||||||
|
|
||||||
from typing import Optional
|
from typing import Optional
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
import __py_include
|
import include_homekit
|
||||||
|
|
||||||
from homekit.config import config
|
from homekit.config import config
|
||||||
from homekit.util import Addr
|
from homekit.util import Addr
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
import logging
|
import logging
|
||||||
import threading
|
import threading
|
||||||
import __py_include
|
import include_homekit
|
||||||
|
|
||||||
from time import sleep
|
from time import sleep
|
||||||
from typing import Optional, List, Dict, Tuple
|
from typing import Optional, List, Dict, Tuple
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
import __py_include
|
import include_homekit
|
||||||
from homekit.config import config
|
from homekit.config import config
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
import __py_include
|
import include_homekit
|
||||||
import asyncio
|
import asyncio
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
import paho.mqtt.client as mqtt
|
import paho.mqtt.client as mqtt
|
||||||
import re
|
import re
|
||||||
import __py_include
|
import include_homekit
|
||||||
|
|
||||||
from homekit.config import config
|
from homekit.config import config
|
||||||
from homekit.mqtt import MqttWrapper, MqttNode
|
from homekit.mqtt import MqttWrapper, MqttNode
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
import __py_include
|
import include_homekit
|
||||||
|
|
||||||
from homekit.mqtt.temphum import MqttTempHumNodes
|
from homekit.mqtt.temphum import MqttTempHumNodes
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
import __py_include
|
import include_homekit
|
||||||
|
|
||||||
from argparse import ArgumentParser
|
from argparse import ArgumentParser
|
||||||
from homekit.temphum import SensorType
|
from homekit.temphum import SensorType
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
import asyncio
|
import asyncio
|
||||||
import json
|
import json
|
||||||
import logging
|
import logging
|
||||||
import __py_include
|
import include_homekit
|
||||||
|
|
||||||
from typing import Optional
|
from typing import Optional
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
import __py_include
|
import include_homekit
|
||||||
import re
|
import re
|
||||||
|
|
||||||
from html import escape
|
from html import escape
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
import asyncio
|
import asyncio
|
||||||
import json
|
import json
|
||||||
import os
|
import os
|
||||||
import __py_include
|
import include_homekit
|
||||||
|
|
||||||
from datetime import datetime, timedelta
|
from datetime import datetime, timedelta
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
import __py_include
|
import include_homekit
|
||||||
import asyncio
|
import asyncio
|
||||||
import logging
|
import logging
|
||||||
import jinja2
|
import jinja2
|
||||||
|
@ -25,16 +25,16 @@ class CameraType(Enum):
|
|||||||
elif channel == 2:
|
elif channel == 2:
|
||||||
if self.is_hikvision():
|
if self.is_hikvision():
|
||||||
return '/Streaming/Channels/2'
|
return '/Streaming/Channels/2'
|
||||||
elif self.value == CameraType.XMEYE:
|
elif self.is_xmeye():
|
||||||
return '/?stream=1.sdp'
|
return '/?stream=1.sdp'
|
||||||
else:
|
else:
|
||||||
raise ValueError(f'unsupported camera type {self.value}')
|
raise ValueError(f'unsupported camera type {self.value}')
|
||||||
|
|
||||||
def get_codec(self, channel: int) -> VideoCodecType:
|
def get_codec(self, channel: int) -> VideoCodecType:
|
||||||
if channel == 1:
|
if channel == 1:
|
||||||
return VideoCodecType.H264 if self.value == CameraType.HIKVISION_264 else VideoCodecType.H265
|
return VideoCodecType.H264 if self == CameraType.HIKVISION_264 else VideoCodecType.H265
|
||||||
elif channel == 2:
|
elif channel == 2:
|
||||||
return VideoCodecType.H265 if self.value == CameraType.XMEYE else VideoCodecType.H264
|
return VideoCodecType.H265 if self == CameraType.XMEYE else VideoCodecType.H264
|
||||||
else:
|
else:
|
||||||
raise ValueError(f'unexpected channel {channel}')
|
raise ValueError(f'unexpected channel {channel}')
|
||||||
|
|
||||||
|
@ -1,9 +0,0 @@
|
|||||||
import sys
|
|
||||||
import os.path
|
|
||||||
|
|
||||||
for _name in ('include/py',):
|
|
||||||
sys.path.extend([
|
|
||||||
os.path.realpath(
|
|
||||||
os.path.join(os.path.dirname(os.path.join(__file__)), '..', _name)
|
|
||||||
)
|
|
||||||
])
|
|
1
test/include_homekit.py
Symbolic link
1
test/include_homekit.py
Symbolic link
@ -0,0 +1 @@
|
|||||||
|
../include_homekit.py
|
@ -1,5 +1,5 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
import __py_include
|
import include_homekit
|
||||||
|
|
||||||
from homekit.config import config
|
from homekit.config import config
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
import __py_include
|
import include_homekit
|
||||||
|
|
||||||
from argparse import ArgumentParser
|
from argparse import ArgumentParser
|
||||||
from homekit.config import config
|
from homekit.config import config
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
import __py_include
|
import include_homekit
|
||||||
|
|
||||||
from argparse import ArgumentParser
|
from argparse import ArgumentParser
|
||||||
from homekit.config import config
|
from homekit.config import config
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
import __py_include
|
import include_homekit
|
||||||
|
|
||||||
from homekit.api import WebApiClient
|
from homekit.api import WebApiClient
|
||||||
from homekit.config import config
|
from homekit.config import config
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
import __py_include
|
import include_homekit
|
||||||
|
|
||||||
from pprint import pprint
|
from pprint import pprint
|
||||||
from argparse import ArgumentParser
|
from argparse import ArgumentParser
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
import __py_include
|
import include_homekit
|
||||||
|
|
||||||
from enum import Enum, auto
|
from enum import Enum, auto
|
||||||
from typing import Optional
|
from typing import Optional
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
import __py_include
|
import include_homekit
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
import shutil
|
import shutil
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
import __py_include
|
import include_homekit
|
||||||
from homekit.modem import E3372, ModemsConfig
|
from homekit.modem import E3372, ModemsConfig
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
import __py_include
|
import include_homekit
|
||||||
import syncleo
|
import syncleo
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
import __py_include
|
import include_homekit
|
||||||
import logging
|
import logging
|
||||||
import time
|
import time
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
import __py_include
|
import include_homekit
|
||||||
|
|
||||||
from argparse import ArgumentParser
|
from argparse import ArgumentParser
|
||||||
from homekit.util import send_datagram, stringify, Addr
|
from homekit.util import send_datagram, stringify, Addr
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
import __py_include
|
import include_homekit
|
||||||
|
|
||||||
from homekit.api.errors import ApiResponseError
|
from homekit.api.errors import ApiResponseError
|
||||||
from homekit.media import SoundNodeClient
|
from homekit.media import SoundNodeClient
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
import __py_include
|
import include_homekit
|
||||||
import threading
|
import threading
|
||||||
|
|
||||||
from time import sleep
|
from time import sleep
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import __py_include
|
import include_homekit
|
||||||
from homekit.util import Stopwatch, StopwatchError
|
from homekit.util import Stopwatch, StopwatchError
|
||||||
from time import sleep
|
from time import sleep
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
import __py_include
|
import include_homekit
|
||||||
import asyncio
|
import asyncio
|
||||||
import homekit.telegram.aio as telegram
|
import homekit.telegram.aio as telegram
|
||||||
|
|
||||||
|
1
tools/include_homekit.py
Symbolic link
1
tools/include_homekit.py
Symbolic link
@ -0,0 +1 @@
|
|||||||
|
../include_homekit.py
|
38
tools/ipcam_stream.py
Executable file
38
tools/ipcam_stream.py
Executable file
@ -0,0 +1,38 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
import include_homekit
|
||||||
|
import subprocess
|
||||||
|
import sys
|
||||||
|
|
||||||
|
from argparse import ArgumentParser, ArgumentError
|
||||||
|
from homekit.camera import IpcamConfig
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
players = ('mpv', 'vlc')
|
||||||
|
parser = ArgumentParser()
|
||||||
|
parser.add_argument('--tcp', action='store_true',
|
||||||
|
help='use tcp for rtsp')
|
||||||
|
parser.add_argument('--player', type=str, choices=players, default=players[0],
|
||||||
|
help='player to use')
|
||||||
|
parser.add_argument('--low', action='store_true',
|
||||||
|
help='use second channel')
|
||||||
|
parser.add_argument('camera', metavar='CAMERA', type=int, nargs=1,
|
||||||
|
help='number of camera to stream')
|
||||||
|
args = parser.parse_args()
|
||||||
|
|
||||||
|
ic = IpcamConfig()
|
||||||
|
camera = args.camera[0]
|
||||||
|
if not ic.has_camera(camera):
|
||||||
|
raise ArgumentError(None, f'invalid camera {camera}')
|
||||||
|
|
||||||
|
cmd = [args.player]
|
||||||
|
if args.tcp:
|
||||||
|
cmd.extend(['--rtsp-transport=tcp', '--force-seekable=yes'])
|
||||||
|
ip = ic.get_camera_ip(camera)
|
||||||
|
username, password = ic.get_rtsp_creds()
|
||||||
|
uri = f'rtsp://{username}:{password}@{ip}:554'
|
||||||
|
uri += ic.get_camera_type(camera).get_channel_url(1 if not args.low else 2)
|
||||||
|
cmd.append(uri)
|
||||||
|
|
||||||
|
p = subprocess.run(cmd, capture_output=False)
|
||||||
|
if p.returncode != 0:
|
||||||
|
print(f'error: {args.player} returned {p.returncode}', file=sys.stderr)
|
Loading…
x
Reference in New Issue
Block a user