Add ability to have a different name for folder

This commit is contained in:
CommanderRedYT 2023-11-15 09:00:32 +01:00
parent eb4558569c
commit 2481248736
No known key found for this signature in database
GPG Key ID: 572F157519DC8A5E
6 changed files with 15 additions and 3 deletions

View File

@ -53,6 +53,7 @@ An example configuration is provided in the docker-compose.yml file. Configure t
- `TA_TOKEN`: Tube Archivist API token, accessible from the settings page
- `JF_URL`: Full URL where Jellyfin is reachable
- `JF_TOKEN`: Jellyfin API token
- `JF_FOLDER`: Folder override if your folder is not named "YouTube" on your Filesystem.
- `LISTEN_PORT`: Optionally change the port where the integration is listening for messages. Defaults to `8001`. If you change this, make sure to also change the json link for auto trigger as described below.
Mount the `/youtube` folder from Tube Archivist also in this container at `/youtube` to give this integration access to the media archive.
@ -83,6 +84,7 @@ pip install requests
- `ta_token`: Tube Archivist API token, accessible from the settings page
- `jf_url`: Full URL where Jellyfin is reachable
- `jf_token`: Jellyfin API token
- `jf_folder`: Name of the folder where TubeArchivist puts the files into
Then run the script from the main folder with python, e.g.
```python

View File

@ -38,6 +38,7 @@ def get_config_env() -> ConfigType | Literal[False]:
"ta_token": os.environ["TA_TOKEN"],
"jf_url": os.environ["JF_URL"],
"jf_token": os.environ["JF_TOKEN"],
"jf_folder": os.environ['JF_FOLDER']
}
return config_content

View File

@ -9,7 +9,7 @@ from src.static_types import ConfigType, TAChannel, TAVideo
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"} # js_folder is optional
class Jellyfin:

View File

@ -22,8 +22,15 @@ class Library:
"""get collection id for youtube folder"""
path: str = "Items?Recursive=true&includeItemTypes=Folder"
folders: dict = Jellyfin().get(path)
folder_name: str | None = get_config()["jf_folder"]
if not folder_name or len(folder_name) < 1:
folder_name = "youtube"
else:
folder_name = folder_name.lower()
for folder in folders["Items"]:
if folder.get("Name").lower() == "youtube":
if folder.get("Name").lower() == folder_name:
return folder.get("Id")
raise ValueError("youtube folder not found")

View File

@ -11,6 +11,7 @@ class ConfigType(TypedDict):
ta_token: str
jf_url: str
jf_token: str
jf_folder: str | None
class TAChannel(TypedDict):

View File

@ -3,5 +3,6 @@
"ta_url": "http://tubearchivist.local",
"ta_token": "xxxxxxxxxxxxxxxx",
"jf_url": "http://jellyfin.local:8096",
"jf_token": "yyyyyyyyyyyyyyyy"
"jf_token": "yyyyyyyyyyyyyyyy",
"jf_folder": "YouTube"
}