Merge branch 'meeb:main' into patch-14

This commit is contained in:
tcely 2025-04-09 12:44:17 -04:00 committed by GitHub
commit bfd9bdf8f2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
8 changed files with 52 additions and 19 deletions

View File

@ -5,7 +5,6 @@ from django.core.management.base import BaseCommand, CommandError
from django.db.models import signals from django.db.models import signals
from common.logger import log from common.logger import log
from sync.models import Source, Media, MediaServer from sync.models import Source, Media, MediaServer
from sync.signals import media_post_delete
from sync.tasks import schedule_media_servers_update from sync.tasks import schedule_media_servers_update

View File

@ -13,21 +13,28 @@ class Command(BaseCommand):
help = 'Resets all tasks' help = 'Resets all tasks'
@atomic(durable=True)
def handle(self, *args, **options): def handle(self, *args, **options):
log.info('Resettings all tasks...') log.info('Resettings all tasks...')
with atomic(durable=True):
# Delete all tasks # Delete all tasks
Task.objects.all().delete() Task.objects.all().delete()
# Iter all tasks # Iter all sources, creating new tasks
for source in Source.objects.all(): for source in Source.objects.all():
verbose_name = _('Check download directory exists for source "{}"')
check_source_directory_exists(
str(source.pk),
verbose_name=verbose_name.format(source.name),
)
# Recreate the initial indexing task # Recreate the initial indexing task
log.info(f'Resetting tasks for source: {source}') log.info(f'Resetting tasks for source: {source}')
verbose_name = _('Index media from source "{}"') verbose_name = _('Index media from source "{}"')
index_source_task( index_source_task(
str(source.pk), str(source.pk),
repeat=source.index_schedule, repeat=source.index_schedule,
verbose_name=verbose_name.format(source.name) verbose_name=verbose_name.format(source.name),
) )
with atomic(durable=True):
for source in Source.objects.all():
# This also chains down to call each Media objects .save() as well # This also chains down to call each Media objects .save() as well
source.save() source.save()
log.info('Done') log.info('Done')

View File

@ -221,7 +221,7 @@ def media_post_save(sender, instance, created, **kwargs):
else: else:
# Downloaded media might need to be renamed # Downloaded media might need to be renamed
# Check settings before any rename tasks are scheduled # Check settings before any rename tasks are scheduled
rename_sources_setting = settings.RENAME_SOURCES or list() rename_sources_setting = getattr(settings, 'RENAME_SOURCES') or list()
create_rename_task = ( create_rename_task = (
( (
media.source.directory and media.source.directory and

View File

@ -746,7 +746,7 @@ def rename_all_media_for_source(source_id):
f'source exists with ID: {source_id}') f'source exists with ID: {source_id}')
raise InvalidTaskError(_('no such source')) from e raise InvalidTaskError(_('no such source')) from e
# Check that the settings allow renaming # Check that the settings allow renaming
rename_sources_setting = getattr(settings, 'RENAME_SOURCES', list()) rename_sources_setting = getattr(settings, 'RENAME_SOURCES') or list()
create_rename_tasks = ( create_rename_tasks = (
( (
source.directory and source.directory and

View File

@ -99,6 +99,18 @@
</div> </div>
</div> </div>
</div> </div>
<div class="row">
<div class="col s12">
<h2 class="truncate">Warnings</h2>
<div class="collection-item">
An upcoming release, after <b>2025-006-01</b>, will introduce automated file renaming.<br>
To prevent this change from taking effect, you can set an environment variable before that date.<br>
See the <a href="https://github.com/meeb/tubesync#warnings" rel="external noreferrer">GitHub README</a>
for more details or ask questions using
issue <a href="https://github.com/meeb/tubesync/issues/785" rel="external noreferrer">#785</a>.<br>
</div>
</div>
</div>
<div class="row"> <div class="row">
<div class="col s12"> <div class="col s12">
<h2 class="truncate">Runtime information</h2> <h2 class="truncate">Runtime information</h2>

View File

@ -931,6 +931,11 @@ class ResetTasks(FormView):
Task.objects.all().delete() Task.objects.all().delete()
# Iter all tasks # Iter all tasks
for source in Source.objects.all(): for source in Source.objects.all():
verbose_name = _('Check download directory exists for source "{}"')
check_source_directory_exists(
str(source.pk),
verbose_name=verbose_name.format(source.name),
)
# Recreate the initial indexing task # Recreate the initial indexing task
verbose_name = _('Index media from source "{}"') verbose_name = _('Index media from source "{}"')
index_source_task( index_source_task(

View File

@ -14,6 +14,7 @@ from tempfile import TemporaryDirectory
from urllib.parse import urlsplit, parse_qs from urllib.parse import urlsplit, parse_qs
from django.conf import settings from django.conf import settings
from .choices import Val, FileExtension
from .hooks import postprocessor_hook, progress_hook from .hooks import postprocessor_hook, progress_hook
from .utils import mkdir_p from .utils import mkdir_p
import yt_dlp import yt_dlp
@ -301,6 +302,15 @@ def download_media(
).options.sponsorblock_mark ).options.sponsorblock_mark
pp_opts.sponsorblock_remove.update(sponsor_categories or {}) pp_opts.sponsorblock_remove.update(sponsor_categories or {})
# Enable audio extraction for audio-only extensions
audio_exts = set(Val(
FileExtension.M4A,
FileExtension.OGG,
))
if extension in audio_exts:
pp_opts.extractaudio = True
pp_opts.nopostoverwrites = False
ytopts = { ytopts = {
'format': media_format, 'format': media_format,
'merge_output_format': extension, 'merge_output_format': extension,

View File

@ -7,7 +7,7 @@ CONFIG_BASE_DIR = BASE_DIR
DOWNLOADS_BASE_DIR = BASE_DIR DOWNLOADS_BASE_DIR = BASE_DIR
VERSION = '0.13.7' VERSION = '0.14.1'
SECRET_KEY = '' SECRET_KEY = ''
DEBUG = False DEBUG = False
ALLOWED_HOSTS = [] ALLOWED_HOSTS = []