Replace url-encode-password.sh with Python script
The shell version had to pass the password through a shell variable into a Python subprocess, which is fragile for special characters. The Python version uses getpass.getpass() which reads directly from the terminal at the Python level — no shell variable, no quoting issues, no risk of special characters being mishandled. https://claude.ai/code/session_01C4jbd3waXG3eKZYbGUjLUQ
This commit is contained in:
Executable
+16
@@ -0,0 +1,16 @@
|
||||
#!/usr/bin/env python3
|
||||
"""URL-encode a camera password for use in an RTSP URL.
|
||||
|
||||
Runs entirely locally. The password is read without echoing via
|
||||
getpass — never written to disk, never sent anywhere.
|
||||
"""
|
||||
|
||||
import getpass
|
||||
import urllib.parse
|
||||
|
||||
password = getpass.getpass("Password (not echoed): ")
|
||||
encoded = urllib.parse.quote(password, safe="")
|
||||
|
||||
print(f"\nURL-encoded: {encoded}")
|
||||
print( "\nPaste into .env like:")
|
||||
print(f" CAM_RTSP_<cam>='rtsp://admin:{encoded}@192.168.1.XXX:554/stream1'")
|
||||
Reference in New Issue
Block a user