Skip to content

Commit

Permalink
encoded password special characters in stream url (#163)
Browse files Browse the repository at this point in the history
  • Loading branch information
maciej-or authored Apr 14, 2024
1 parent e4f3675 commit 43d1f48
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions custom_components/hikvision_next/isapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import json
import logging
from typing import Any, Optional
from urllib.parse import urlparse
from urllib.parse import quote, urlparse

from hikvisionapi import AsyncClient
from httpx import HTTPStatusError, TimeoutException
Expand Down Expand Up @@ -854,7 +854,10 @@ async def get_camera_image(

def get_stream_source(self, stream: CameraStreamInfo) -> str:
"""Get stream source."""
return f"rtsp://{self.isapi.login}:{self.isapi.password}@{self.device_info.ip_address}:{self.device_info.rtsp_port}/Streaming/channels/{stream.id}"
u = quote(self.isapi.login, safe="")
p = quote(self.isapi.password, safe="")
url = f"{self.device_info.ip_address}:{self.device_info.rtsp_port}/Streaming/channels/{stream.id}"
return f"rtsp://{u}:{p}@{url}"


def str_to_bool(value: str) -> bool:
Expand Down

0 comments on commit 43d1f48

Please sign in to comment.