From a1fa823b180d4502824b82e303fc503cf4d3a606 Mon Sep 17 00:00:00 2001 From: tcely Date: Wed, 9 Apr 2025 17:18:23 -0400 Subject: [PATCH 1/2] POST to `/Items/{ID}/Refresh` --- tubesync/sync/mediaservers.py | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/tubesync/sync/mediaservers.py b/tubesync/sync/mediaservers.py index 3b8e558e..23c66074 100644 --- a/tubesync/sync/mediaservers.py +++ b/tubesync/sync/mediaservers.py @@ -175,16 +175,25 @@ class JellyfinMediaServer(MediaServer): '

The token is required for API access. You can generate a token in your Jellyfin user profile settings.

' '

The libraries is a comma-separated list of library IDs in Jellyfin.

') - def make_request(self, uri='/', params={}): + def make_request(self, uri='/', params={}, *, data={}, json=None, method='GET'): headers = { 'User-Agent': 'TubeSync', 'X-Emby-Token': self.object.loaded_options['token'] # Jellyfin uses the same `X-Emby-Token` header as Emby } + assert method in {'GET', 'POST'}, f'Unimplemented method: {method}' url = f'{self.object.url}{uri}' - log.debug(f'[jellyfin media server] Making HTTP GET request to: {url}') + log.debug(f'[jellyfin media server] Making HTTP {method} request to: {url}') - return requests.get(url, headers=headers, verify=self.object.verify_https, timeout=self.TIMEOUT) + return requests.request( + method, url, + headers=headers, + params=params, + data=data, + json=json, + verify=self.object.verify_https, + timeout=self.TIMEOUT, + ) def validate(self): if not self.object.host: @@ -245,8 +254,8 @@ class JellyfinMediaServer(MediaServer): def update(self): libraries = self.object.loaded_options.get('libraries', '').split(',') for library_id in map(str.strip, libraries): - uri = f'/Library/{library_id}/Refresh' - response = self.make_request(uri) + uri = f'/Items/{library_id}/Refresh' + response = self.make_request(uri, method='POST') if response.status_code != 204: # 204 No Content is expected for successful refresh raise MediaServerError(f'Failed to refresh Jellyfin library "{library_id}", status code: {response.status_code}') return True From 40144a8400a14adefc94829fb690093fe282fc2e Mon Sep 17 00:00:00 2001 From: tcely Date: Wed, 9 Apr 2025 18:41:03 -0400 Subject: [PATCH 2/2] Import the `check_source_directory_exists` task --- tubesync/sync/management/commands/reset-tasks.py | 2 +- tubesync/sync/views.py | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/tubesync/sync/management/commands/reset-tasks.py b/tubesync/sync/management/commands/reset-tasks.py index 3d6f515d..55436863 100644 --- a/tubesync/sync/management/commands/reset-tasks.py +++ b/tubesync/sync/management/commands/reset-tasks.py @@ -3,7 +3,7 @@ from django.db.transaction import atomic from django.utils.translation import gettext_lazy as _ from background_task.models import Task from sync.models import Source -from sync.tasks import index_source_task +from sync.tasks import index_source_task, check_source_directory_exists from common.logger import log diff --git a/tubesync/sync/views.py b/tubesync/sync/views.py index 0e3f8dbb..eeb79ed0 100644 --- a/tubesync/sync/views.py +++ b/tubesync/sync/views.py @@ -29,7 +29,8 @@ from .forms import (ValidateSourceForm, ConfirmDeleteSourceForm, RedownloadMedia from .utils import validate_url, delete_file, multi_key_sort from .tasks import (map_task_to_instance, get_error_message, get_source_completed_tasks, get_media_download_task, - delete_task_by_media, index_source_task, migrate_queues) + delete_task_by_media, index_source_task, + check_source_directory_exists, migrate_queues) from .choices import (Val, MediaServerType, SourceResolution, YouTube_SourceType, youtube_long_source_types, youtube_help, youtube_validation_urls)