diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 22bd31b2..5ae58c0a 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -144,7 +144,7 @@ jobs: done } >> "${GITHUB_STEP_SUMMARY}" uvx --no-config --no-managed-python --no-progress --isolated \ - ruff check --exit-zero \ + ruff check \ --target-version "${target_version}" \ --output-format github \ --ignore "${ignore_csv_list}" diff --git a/Pipfile b/Pipfile index 2e3f3acf..49b5127b 100644 --- a/Pipfile +++ b/Pipfile @@ -24,5 +24,4 @@ yt-dlp = {extras = ["default", "curl-cffi"], version = "*"} emoji = "*" brotli = "*" html5lib = "*" -yt-dlp-get-pot = "*" bgutil-ytdlp-pot-provider = "*" diff --git a/tubesync/sync/models/_private.py b/tubesync/sync/models/_private.py index 5ec14d7c..8cf41ce1 100644 --- a/tubesync/sync/models/_private.py +++ b/tubesync/sync/models/_private.py @@ -1,3 +1,4 @@ +from pathlib import Path from ..choices import Val, YouTube_SourceType # noqa @@ -10,3 +11,11 @@ def _nfo_element(nfo, label, text, /, *, attrs={}, tail='\n', char=' ', indent=2 element.tail = tail + (char * indent) return element +def directory_and_stem(arg_path, /, all_suffixes=False): + filepath = Path(arg_path) + stem = Path(filepath.stem) + while all_suffixes and stem.suffixes and '' != stem.suffix: + stem = Path(stem.stem) + stem = str(stem) + return (filepath.parent, stem,) + diff --git a/tubesync/sync/models/media.py b/tubesync/sync/models/media.py index 11b30f80..62f73d5d 100644 --- a/tubesync/sync/models/media.py +++ b/tubesync/sync/models/media.py @@ -25,8 +25,7 @@ from ..youtube import ( ) from ..utils import ( seconds_to_timestr, parse_media_format, filter_response, - write_text_file, mkdir_p, directory_and_stem, glob_quote, - multi_key_sort, + write_text_file, mkdir_p, glob_quote, multi_key_sort, ) from ..matching import ( get_best_combined_format, @@ -39,7 +38,7 @@ from ..choices import ( from ._migrations import ( media_file_storage, get_media_thumb_path, get_media_file_path, ) -from ._private import _srctype_dict, _nfo_element +from ._private import _srctype_dict, _nfo_element, directory_and_stem from .media__tasks import ( download_checklist, download_finished, wait_for_premiere, ) @@ -1193,7 +1192,7 @@ class Media(models.Model): other_path.replace(new_file_path) for fuzzy_path in fuzzy_paths: - (fuzzy_prefix_path, fuzzy_stem) = directory_and_stem(fuzzy_path) + (fuzzy_prefix_path, fuzzy_stem) = directory_and_stem(fuzzy_path, True) old_file_str = fuzzy_path.name new_file_str = new_stem + old_file_str[len(fuzzy_stem):] new_file_path = Path(new_prefix_path / new_file_str) diff --git a/tubesync/sync/tasks.py b/tubesync/sync/tasks.py index 466e41d3..bf5e43ed 100644 --- a/tubesync/sync/tasks.py +++ b/tubesync/sync/tasks.py @@ -35,7 +35,7 @@ from common.utils import ( django_queryset_generator as qs_gen, from .choices import Val, TaskQueue from .models import Source, Media, MediaServer from .utils import ( get_remote_image, resize_image_to_height, - write_text_file, filter_response, ) + write_text_file, filter_response, seconds_to_timestr, ) from .youtube import YouTubeError db_vendor = db.connection.vendor @@ -256,8 +256,11 @@ def wait_for_errors(model, /, *, task_name=None): ) for task in tasks: update_task_status(task, 'paused (429)') - log.info(f'waiting for errors: 429 ({tqs.count()}): {model}') - time.sleep(10 * tqs.count()) + + delay = 10 * tqs.count() + time_str = seconds_to_timestr(delay) + log.info(f'waiting for errors: 429 ({time_str}): {model}') + time.sleep(delay) for task in tasks: update_task_status(task, None) diff --git a/tubesync/sync/templates/sync/media-item.html b/tubesync/sync/templates/sync/media-item.html index b70f78c2..074987ea 100644 --- a/tubesync/sync/templates/sync/media-item.html +++ b/tubesync/sync/templates/sync/media-item.html @@ -121,7 +121,8 @@ {% if media_file_path == media.filepath %}  (matched) {% endif %} - + + File size File size
{{ media.downloaded_filesize|bytesformat }} diff --git a/tubesync/sync/utils.py b/tubesync/sync/utils.py index 5bc90d25..fc7874fd 100644 --- a/tubesync/sync/utils.py +++ b/tubesync/sync/utils.py @@ -130,15 +130,6 @@ def file_is_editable(filepath): return False -def directory_and_stem(arg_path): - filepath = Path(arg_path) - stem = Path(filepath.stem) - while stem.suffixes and '' != stem.suffix: - stem = Path(stem.stem) - stem = str(stem) - return (filepath.parent, stem,) - - def mkdir_p(arg_path, mode=0o777): ''' Reminder: mode only affects the last directory diff --git a/tubesync/sync/views.py b/tubesync/sync/views.py index 4f683834..093cad3f 100644 --- a/tubesync/sync/views.py +++ b/tubesync/sync/views.py @@ -845,9 +845,11 @@ class TasksView(ListView): data = super().get_context_data(*args, **kwargs) now = timezone.now() qs = Task.objects.all() - errors_qs = qs.filter(attempts__gt=0, locked_by__isnull=True) running_qs = qs.filter(locked_by__isnull=False) scheduled_qs = qs.filter(locked_by__isnull=True) + errors_qs = scheduled_qs.filter( + attempts__gt=0 + ).exclude(last_error__exact='') # Add to context data from ListView data['message'] = self.message diff --git a/tubesync/tubesync/settings.py b/tubesync/tubesync/settings.py index 3ab7f9ff..cd6d1dca 100644 --- a/tubesync/tubesync/settings.py +++ b/tubesync/tubesync/settings.py @@ -8,7 +8,7 @@ CONFIG_BASE_DIR = BASE_DIR DOWNLOADS_BASE_DIR = BASE_DIR -VERSION = '0.15.3' +VERSION = '0.15.4' SECRET_KEY = '' DEBUG = False ALLOWED_HOSTS = []