Fix Transmission RPC and file browser permissions #43
@@ -10,17 +10,15 @@ router = APIRouter(prefix="/api/transmission", tags=["transmission"])
|
|||||||
def get_session_id() -> str:
|
def get_session_id() -> str:
|
||||||
"""Get Transmission RPC session ID"""
|
"""Get Transmission RPC session ID"""
|
||||||
try:
|
try:
|
||||||
result = subprocess.run(
|
with httpx.Client(timeout=5.0) as client:
|
||||||
["ssh", "nas", "curl -si -u 'admin:admin' 'http://127.0.0.1:9091/transmission/rpc' 2>&1 | grep -i 'X-Transmission-Session-Id:' | cut -d' ' -f2 | tr -d '\\r'"],
|
response = client.get(
|
||||||
capture_output=True,
|
"http://host.docker.internal:9091/transmission/rpc",
|
||||||
text=True,
|
auth=("admin", "admin")
|
||||||
shell=True,
|
)
|
||||||
timeout=5
|
session_id = response.headers.get("X-Transmission-Session-Id")
|
||||||
)
|
if not session_id:
|
||||||
session_id = result.stdout.strip()
|
raise Exception("Failed to get session ID from headers")
|
||||||
if not session_id:
|
return session_id
|
||||||
raise Exception("Failed to get session ID")
|
|
||||||
return session_id
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
raise HTTPException(status_code=500, detail=f"Failed to get Transmission session ID: {str(e)}")
|
raise HTTPException(status_code=500, detail=f"Failed to get Transmission session ID: {str(e)}")
|
||||||
|
|
||||||
@@ -37,7 +35,7 @@ def transmission_rpc(method: str, arguments: Dict[str, Any] = None) -> Dict[str,
|
|||||||
# Use httpx to make the request
|
# Use httpx to make the request
|
||||||
with httpx.Client(timeout=10.0) as client:
|
with httpx.Client(timeout=10.0) as client:
|
||||||
response = client.post(
|
response = client.post(
|
||||||
"http://100.78.131.124:9091/transmission/rpc",
|
"http://host.docker.internal:9091/transmission/rpc",
|
||||||
json=payload,
|
json=payload,
|
||||||
auth=("admin", "admin"),
|
auth=("admin", "admin"),
|
||||||
headers={"X-Transmission-Session-Id": session_id}
|
headers={"X-Transmission-Session-Id": session_id}
|
||||||
|
|||||||
Reference in New Issue
Block a user