mirror of
https://github.com/tubearchivist/jellyfin.git
synced 2025-01-15 13:20:13 +00:00
increase timeout
This commit is contained in:
parent
cbb7711a7d
commit
28e4c95f86
@ -8,6 +8,7 @@ from src.config import get_config
|
|||||||
from src.static_types import ConfigType, TAChannel, TAVideo
|
from src.static_types import ConfigType, TAChannel, TAVideo
|
||||||
|
|
||||||
CONFIG: ConfigType = get_config()
|
CONFIG: ConfigType = get_config()
|
||||||
|
TIMEOUT = 60
|
||||||
EXPECTED_ENV = {"ta_url", "ta_token", "jf_url", "jf_token", "ta_video_path"}
|
EXPECTED_ENV = {"ta_url", "ta_token", "jf_url", "jf_token", "ta_video_path"}
|
||||||
|
|
||||||
|
|
||||||
@ -22,7 +23,7 @@ class Jellyfin:
|
|||||||
def get(self, path: str) -> dict:
|
def get(self, path: str) -> dict:
|
||||||
"""make a get request"""
|
"""make a get request"""
|
||||||
url: str = f"{self.base}/{path}"
|
url: str = f"{self.base}/{path}"
|
||||||
response = requests.get(url, headers=self.headers, timeout=10)
|
response = requests.get(url, headers=self.headers, timeout=TIMEOUT)
|
||||||
if response.ok:
|
if response.ok:
|
||||||
return response.json()
|
return response.json()
|
||||||
|
|
||||||
@ -33,7 +34,7 @@ class Jellyfin:
|
|||||||
"""make a post request"""
|
"""make a post request"""
|
||||||
url: str = f"{self.base}/{path}"
|
url: str = f"{self.base}/{path}"
|
||||||
response = requests.post(
|
response = requests.post(
|
||||||
url, headers=self.headers, json=data, timeout=10
|
url, headers=self.headers, json=data, timeout=TIMEOUT
|
||||||
)
|
)
|
||||||
if not response.ok:
|
if not response.ok:
|
||||||
print(response.text)
|
print(response.text)
|
||||||
@ -44,7 +45,7 @@ class Jellyfin:
|
|||||||
new_headers: dict = self.headers.copy()
|
new_headers: dict = self.headers.copy()
|
||||||
new_headers.update({"Content-Type": "image/jpeg"})
|
new_headers.update({"Content-Type": "image/jpeg"})
|
||||||
response = requests.post(
|
response = requests.post(
|
||||||
url, headers=new_headers, data=thumb_base64, timeout=10
|
url, headers=new_headers, data=thumb_base64, timeout=TIMEOUT
|
||||||
)
|
)
|
||||||
if not response.ok:
|
if not response.ok:
|
||||||
print(response.text)
|
print(response.text)
|
||||||
@ -68,7 +69,7 @@ class TubeArchivist:
|
|||||||
def get_video(self, video_id: str) -> TAVideo:
|
def get_video(self, video_id: str) -> TAVideo:
|
||||||
"""get video metadata"""
|
"""get video metadata"""
|
||||||
url: str = f"{self.base}/api/video/{video_id}/"
|
url: str = f"{self.base}/api/video/{video_id}/"
|
||||||
response = requests.get(url, headers=self.headers, timeout=10)
|
response = requests.get(url, headers=self.headers, timeout=TIMEOUT)
|
||||||
|
|
||||||
if response.ok:
|
if response.ok:
|
||||||
ta_video: TAVideo = response.json()["data"]
|
ta_video: TAVideo = response.json()["data"]
|
||||||
@ -79,7 +80,7 @@ class TubeArchivist:
|
|||||||
def get_channel(self, channel_id: str) -> TAChannel | None:
|
def get_channel(self, channel_id: str) -> TAChannel | None:
|
||||||
"""get channel metadata"""
|
"""get channel metadata"""
|
||||||
url: str = f"{self.base}/api/channel/{channel_id}/"
|
url: str = f"{self.base}/api/channel/{channel_id}/"
|
||||||
response = requests.get(url, headers=self.headers, timeout=10)
|
response = requests.get(url, headers=self.headers, timeout=TIMEOUT)
|
||||||
if response.ok:
|
if response.ok:
|
||||||
ta_channel: TAChannel = response.json()["data"]
|
ta_channel: TAChannel = response.json()["data"]
|
||||||
return ta_channel
|
return ta_channel
|
||||||
@ -91,7 +92,7 @@ class TubeArchivist:
|
|||||||
"""get encoded thumbnail from ta"""
|
"""get encoded thumbnail from ta"""
|
||||||
url: str = CONFIG["ta_url"] + path
|
url: str = CONFIG["ta_url"] + path
|
||||||
response = requests.get(
|
response = requests.get(
|
||||||
url, headers=self.headers, stream=True, timeout=10
|
url, headers=self.headers, stream=True, timeout=TIMEOUT
|
||||||
)
|
)
|
||||||
base64_thumb: bytes = base64.b64encode(response.content)
|
base64_thumb: bytes = base64.b64encode(response.content)
|
||||||
|
|
||||||
@ -100,7 +101,7 @@ class TubeArchivist:
|
|||||||
def ping(self) -> None:
|
def ping(self) -> None:
|
||||||
"""ping tubearchivist server"""
|
"""ping tubearchivist server"""
|
||||||
url: str = f"{self.base}/api/ping/"
|
url: str = f"{self.base}/api/ping/"
|
||||||
response = requests.get(url, headers=self.headers, timeout=10)
|
response = requests.get(url, headers=self.headers, timeout=TIMEOUT)
|
||||||
|
|
||||||
if not response:
|
if not response:
|
||||||
raise ConnectionError("failed to connect to tube archivist")
|
raise ConnectionError("failed to connect to tube archivist")
|
||||||
|
Loading…
Reference in New Issue
Block a user