mirror of
https://github.com/meeb/tubesync.git
synced 2025-06-23 13:36:35 +00:00
Merge branch 'meeb:main' into patch-17
This commit is contained in:
commit
11ee871006
@ -112,8 +112,8 @@ def append_uri_params(uri, params):
|
|||||||
def clean_filename(filename):
|
def clean_filename(filename):
|
||||||
if not isinstance(filename, str):
|
if not isinstance(filename, str):
|
||||||
raise ValueError(f'filename must be a str, got {type(filename)}')
|
raise ValueError(f'filename must be a str, got {type(filename)}')
|
||||||
to_scrub = '<>\/:*?"|%'
|
to_scrub = r'<>\/:*?"|%'
|
||||||
for char in to_scrub:
|
for char in list(to_scrub):
|
||||||
filename = filename.replace(char, '')
|
filename = filename.replace(char, '')
|
||||||
clean_filename = ''
|
clean_filename = ''
|
||||||
for c in filename:
|
for c in filename:
|
||||||
|
@ -138,7 +138,7 @@ def media_post_save(sender, instance, created, **kwargs):
|
|||||||
can_download_changed = False
|
can_download_changed = False
|
||||||
# Reset the skip flag if the download cap has changed if the media has not
|
# Reset the skip flag if the download cap has changed if the media has not
|
||||||
# already been downloaded
|
# already been downloaded
|
||||||
if not instance.downloaded and instance.metadata:
|
if not instance.downloaded:
|
||||||
skip_changed = filter_media(instance)
|
skip_changed = filter_media(instance)
|
||||||
|
|
||||||
# Recalculate the "can_download" flag, this may
|
# Recalculate the "can_download" flag, this may
|
||||||
@ -152,11 +152,6 @@ def media_post_save(sender, instance, created, **kwargs):
|
|||||||
if instance.can_download:
|
if instance.can_download:
|
||||||
instance.can_download = False
|
instance.can_download = False
|
||||||
can_download_changed = True
|
can_download_changed = True
|
||||||
# Save the instance if any changes were required
|
|
||||||
if skip_changed or can_download_changed:
|
|
||||||
post_save.disconnect(media_post_save, sender=Media)
|
|
||||||
instance.save()
|
|
||||||
post_save.connect(media_post_save, sender=Media)
|
|
||||||
existing_media_metadata_task = get_media_metadata_task(str(instance.pk))
|
existing_media_metadata_task = get_media_metadata_task(str(instance.pk))
|
||||||
# If the media is missing metadata schedule it to be downloaded
|
# If the media is missing metadata schedule it to be downloaded
|
||||||
if not (instance.skip or instance.metadata or existing_media_metadata_task):
|
if not (instance.skip or instance.metadata or existing_media_metadata_task):
|
||||||
@ -188,6 +183,10 @@ def media_post_save(sender, instance, created, **kwargs):
|
|||||||
existing_media_download_task = get_media_download_task(str(instance.pk))
|
existing_media_download_task = get_media_download_task(str(instance.pk))
|
||||||
# If the media has not yet been downloaded schedule it to be downloaded
|
# If the media has not yet been downloaded schedule it to be downloaded
|
||||||
if not (instance.media_file_exists or existing_media_download_task):
|
if not (instance.media_file_exists or existing_media_download_task):
|
||||||
|
# The file was deleted after it was downloaded, skip this media.
|
||||||
|
if instance.can_download and instance.downloaded:
|
||||||
|
skip_changed = True != instance.skip
|
||||||
|
instance.skip = True
|
||||||
instance.downloaded = False
|
instance.downloaded = False
|
||||||
instance.media_file = None
|
instance.media_file = None
|
||||||
if (instance.source.download_media and instance.can_download) and not (
|
if (instance.source.download_media and instance.can_download) and not (
|
||||||
@ -200,6 +199,11 @@ def media_post_save(sender, instance, created, **kwargs):
|
|||||||
verbose_name=verbose_name.format(instance.name),
|
verbose_name=verbose_name.format(instance.name),
|
||||||
remove_existing_tasks=True
|
remove_existing_tasks=True
|
||||||
)
|
)
|
||||||
|
# Save the instance if any changes were required
|
||||||
|
if skip_changed or can_download_changed:
|
||||||
|
post_save.disconnect(media_post_save, sender=Media)
|
||||||
|
instance.save()
|
||||||
|
post_save.connect(media_post_save, sender=Media)
|
||||||
|
|
||||||
|
|
||||||
@receiver(pre_delete, sender=Media)
|
@receiver(pre_delete, sender=Media)
|
||||||
|
@ -268,12 +268,12 @@ class ValidateSourceView(FormView):
|
|||||||
|
|
||||||
class EditSourceMixin:
|
class EditSourceMixin:
|
||||||
model = Source
|
model = Source
|
||||||
|
# manual ordering
|
||||||
fields = ('source_type', 'key', 'name', 'directory', 'filter_text', 'filter_text_invert', 'filter_seconds', 'filter_seconds_min',
|
fields = ('source_type', 'key', 'name', 'directory', 'filter_text', 'filter_text_invert', 'filter_seconds', 'filter_seconds_min',
|
||||||
'media_format', 'index_schedule', 'index_videos', 'index_streams', 'download_media', 'download_cap', 'delete_old_media',
|
'media_format', 'index_schedule', 'index_videos', 'index_streams', 'download_media', 'download_cap', 'delete_old_media',
|
||||||
'delete_removed_media', 'days_to_keep', 'source_resolution', 'source_vcodec',
|
'days_to_keep', 'source_resolution', 'source_vcodec', 'source_acodec',
|
||||||
'source_acodec', 'prefer_60fps', 'prefer_hdr', 'fallback', 'copy_channel_images',
|
'prefer_60fps', 'prefer_hdr', 'fallback',
|
||||||
'delete_removed_media', 'delete_files_on_disk', 'days_to_keep', 'source_resolution',
|
'delete_removed_media', 'delete_files_on_disk', 'copy_channel_images',
|
||||||
'source_vcodec', 'source_acodec', 'prefer_60fps', 'prefer_hdr', 'fallback', 'copy_channel_images',
|
|
||||||
'copy_thumbnails', 'write_nfo', 'write_json', 'embed_metadata', 'embed_thumbnail',
|
'copy_thumbnails', 'write_nfo', 'write_json', 'embed_metadata', 'embed_thumbnail',
|
||||||
'enable_sponsorblock', 'sponsorblock_categories', 'write_subtitles',
|
'enable_sponsorblock', 'sponsorblock_categories', 'write_subtitles',
|
||||||
'auto_subtitles', 'sub_langs')
|
'auto_subtitles', 'sub_langs')
|
||||||
|
Loading…
Reference in New Issue
Block a user