[GH-ISSUE #2] Suggestions #3

Closed
opened 2026-03-23 20:32:42 +00:00 by mirror · 1 comment
Owner

Originally created by @IngwiePhoenix on GitHub (Apr 14, 2023).
Original GitHub issue: https://github.com/tubearchivist/tubearchivist-jf/issues/2

Hello!

Found this through the TA docs and am currently running it in a screen to add proper metadata to Jellyfin.

Here's a few suggestions I had:

  • My Jellyfin is kinda slow, running on an ARM SBC. I manually patched the timeout parameter to a ridiculous amount, knowing that sometimes it replies absurdly slow. A config option to set this would be very appreciated.
  • Configure an alternative library name. I kept it to the default Youtube, but it'd be nice to use a different name.

Here's what I patched:

diff --git a/src/connect.py b/src/connect.py
index b7ac72d..9cabd0e 100644
--- a/src/connect.py
+++ b/src/connect.py
@@ -10,6 +10,8 @@ from src.static_types import ConfigType, TAVideo

 CONFIG: ConfigType = get_config()

+GLOBAL_TIMEOUT = 100
+

 class Jellyfin:
     """connect to jellyfin"""
@@ -22,7 +24,7 @@ class Jellyfin:
     def get(self, path: str) -> dict:
         """make a get request"""
         url: str = f"{self.base}/{path}"
-        response = requests.get(url, headers=self.headers, timeout=10)
+        response = requests.get(url, headers=self.headers, timeout=GLOBAL_TIMEOUT)
         if response.ok:
             return response.json()

@@ -33,7 +35,7 @@ class Jellyfin:
         """make a post request"""
         url: str = f"{self.base}/{path}"
         response = requests.post(
-            url, headers=self.headers, json=data, timeout=10
+            url, headers=self.headers, json=data, timeout=GLOBAL_TIMEOUT
         )
         if not response.ok:
             print(response.text)
@@ -44,7 +46,7 @@ class Jellyfin:
         new_headers: dict = self.headers.copy()
         new_headers.update({"Content-Type": "image/jpeg"})
         response = requests.post(
-            url, headers=new_headers, data=thumb_base64, timeout=10
+            url, headers=new_headers, data=thumb_base64, timeout=GLOBAL_TIMEOUT
         )
         if not response.ok:
             print(response.text)
@@ -68,7 +70,7 @@ class TubeArchivist:
     def get(self, path: str) -> TAVideo:
         """get document from ta"""
         url: str = f"{self.base}/api/{path}"
-        response = requests.get(url, headers=self.headers, timeout=10)
+        response = requests.get(url, headers=self.headers, timeout=GLOBAL_TIMEOUT)

         if response.ok:
             response_json = response.json()
@@ -83,7 +85,7 @@ class TubeArchivist:
         """get encoded thumbnail from ta"""
         url: str = CONFIG["ta_url"] + path
         response = requests.get(
-            url, headers=self.headers, stream=True, timeout=10
+            url, headers=self.headers, stream=True, timeout=GLOBAL_TIMEOUT
         )
         base64_thumb: bytes = base64.b64encode(response.content)

diff --git a/src/series.py b/src/series.py
index c9e1868..cecd4b9 100644
--- a/src/series.py
+++ b/src/series.py
@@ -23,6 +23,7 @@ class Library:
         path: str = "Items?Recursive=true&includeItemTypes=Folder"
         folders: dict = Jellyfin().get(path)
         for folder in folders["Items"]:
+            print("Checking: " + folder.get("Name").lower())
             if folder.get("Name").lower() == "youtube":
                 return folder.get("Id")

I was confused why my initial run didn't work, hence the random print statement. (In fact, first line of Python I have written ever xD)

Thanks for this awesome script!

Originally created by @IngwiePhoenix on GitHub (Apr 14, 2023). Original GitHub issue: https://github.com/tubearchivist/tubearchivist-jf/issues/2 Hello! Found this through the TA docs and am currently running it in a screen to add proper metadata to Jellyfin. Here's a few suggestions I had: - My Jellyfin is kinda slow, running on an ARM SBC. I manually patched the timeout parameter to a ridiculous amount, knowing that sometimes it replies absurdly slow. A config option to set this would be very appreciated. - Configure an alternative library name. I kept it to the default Youtube, but it'd be nice to use a different name. Here's what I patched: ```diff diff --git a/src/connect.py b/src/connect.py index b7ac72d..9cabd0e 100644 --- a/src/connect.py +++ b/src/connect.py @@ -10,6 +10,8 @@ from src.static_types import ConfigType, TAVideo CONFIG: ConfigType = get_config() +GLOBAL_TIMEOUT = 100 + class Jellyfin: """connect to jellyfin""" @@ -22,7 +24,7 @@ class Jellyfin: def get(self, path: str) -> dict: """make a get request""" url: str = f"{self.base}/{path}" - response = requests.get(url, headers=self.headers, timeout=10) + response = requests.get(url, headers=self.headers, timeout=GLOBAL_TIMEOUT) if response.ok: return response.json() @@ -33,7 +35,7 @@ class Jellyfin: """make a post request""" url: str = f"{self.base}/{path}" response = requests.post( - url, headers=self.headers, json=data, timeout=10 + url, headers=self.headers, json=data, timeout=GLOBAL_TIMEOUT ) if not response.ok: print(response.text) @@ -44,7 +46,7 @@ class Jellyfin: new_headers: dict = self.headers.copy() new_headers.update({"Content-Type": "image/jpeg"}) response = requests.post( - url, headers=new_headers, data=thumb_base64, timeout=10 + url, headers=new_headers, data=thumb_base64, timeout=GLOBAL_TIMEOUT ) if not response.ok: print(response.text) @@ -68,7 +70,7 @@ class TubeArchivist: def get(self, path: str) -> TAVideo: """get document from ta""" url: str = f"{self.base}/api/{path}" - response = requests.get(url, headers=self.headers, timeout=10) + response = requests.get(url, headers=self.headers, timeout=GLOBAL_TIMEOUT) if response.ok: response_json = response.json() @@ -83,7 +85,7 @@ class TubeArchivist: """get encoded thumbnail from ta""" url: str = CONFIG["ta_url"] + path response = requests.get( - url, headers=self.headers, stream=True, timeout=10 + url, headers=self.headers, stream=True, timeout=GLOBAL_TIMEOUT ) base64_thumb: bytes = base64.b64encode(response.content) diff --git a/src/series.py b/src/series.py index c9e1868..cecd4b9 100644 --- a/src/series.py +++ b/src/series.py @@ -23,6 +23,7 @@ class Library: path: str = "Items?Recursive=true&includeItemTypes=Folder" folders: dict = Jellyfin().get(path) for folder in folders["Items"]: + print("Checking: " + folder.get("Name").lower()) if folder.get("Name").lower() == "youtube": return folder.get("Id") ``` I was confused why my initial run didn't work, hence the random print statement. (In fact, first line of Python I have written ever xD) Thanks for this awesome script!
Author
Owner

@bbilly1 commented on GitHub (Aug 5, 2023):

timeout is increased in v0.1.0, also in docker build now.

<!-- gh-comment-id:1666377160 --> @bbilly1 commented on GitHub (Aug 5, 2023): timeout is increased in v0.1.0, also in docker build now.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
tubearchivist/tubearchivist-jf#3
No description provided.