mirror of
https://github.com/meeb/tubesync.git
synced 2025-06-25 06:26:37 +00:00
parent
bc284568df
commit
465d584b8a
@ -13,7 +13,7 @@ DOMAINS = dict({
|
||||
})
|
||||
|
||||
|
||||
def V(*args):
|
||||
def Val(*args):
|
||||
results = list(
|
||||
a.value if isinstance(a, models.enums.Choices) else a for a in args
|
||||
)
|
||||
|
@ -5,7 +5,7 @@
|
||||
'''
|
||||
|
||||
|
||||
from .choices import V, Fallback
|
||||
from .choices import Val, Fallback
|
||||
from .utils import multi_key_sort
|
||||
from django.conf import settings
|
||||
|
||||
@ -390,10 +390,10 @@ def get_best_video_format(media):
|
||||
return True, best_match['id']
|
||||
elif media.source.can_fallback:
|
||||
# Allow the fallback if it meets requirements
|
||||
if (media.source.fallback == V(Fallback.NEXT_BEST_HD) and
|
||||
if (media.source.fallback == Val(Fallback.NEXT_BEST_HD) and
|
||||
best_match['height'] >= fallback_hd_cutoff):
|
||||
return False, best_match['id']
|
||||
elif media.source.fallback == V(Fallback.NEXT_BEST):
|
||||
elif media.source.fallback == Val(Fallback.NEXT_BEST):
|
||||
return False, best_match['id']
|
||||
# Nope, failed to find match
|
||||
return False, False
|
||||
|
@ -26,7 +26,7 @@ from .matching import (get_best_combined_format, get_best_audio_format,
|
||||
get_best_video_format)
|
||||
from .mediaservers import PlexMediaServer
|
||||
from .fields import CommaSepChoiceField
|
||||
from .choices import (V, CapChoices, Fallback, FileExtension,
|
||||
from .choices import (Val, CapChoices, Fallback, FileExtension,
|
||||
FilterSeconds, IndexSchedule, MediaServerType,
|
||||
MediaState, SourceResolution, SourceResolutionInteger,
|
||||
SponsorBlock_Category, YouTube_AudioCodec,
|
||||
@ -41,15 +41,15 @@ class Source(models.Model):
|
||||
or a YouTube playlist.
|
||||
'''
|
||||
|
||||
SOURCE_VCODEC_VP9 = V(YouTube_VideoCodec.VP9)
|
||||
SOURCE_VCODEC_VP9 = Val(YouTube_VideoCodec.VP9)
|
||||
SOURCE_VCODEC_CHOICES = list(reversed(YouTube_VideoCodec.choices[1:]))
|
||||
|
||||
SOURCE_ACODEC_OPUS = V(YouTube_AudioCodec.OPUS)
|
||||
SOURCE_ACODEC_OPUS = Val(YouTube_AudioCodec.OPUS)
|
||||
SOURCE_ACODEC_CHOICES = list(reversed(YouTube_AudioCodec.choices))
|
||||
|
||||
FALLBACK_FAIL = V(Fallback.FAIL)
|
||||
FALLBACK_NEXT_BEST = V(Fallback.NEXT_BEST)
|
||||
FALLBACK_NEXT_BEST_HD = V(Fallback.NEXT_BEST_HD)
|
||||
FALLBACK_FAIL = Val(Fallback.FAIL)
|
||||
FALLBACK_NEXT_BEST = Val(Fallback.NEXT_BEST)
|
||||
FALLBACK_NEXT_BEST_HD = Val(Fallback.NEXT_BEST_HD)
|
||||
|
||||
sponsorblock_categories = CommaSepChoiceField(
|
||||
_(''),
|
||||
@ -221,7 +221,7 @@ class Source(models.Model):
|
||||
filter_seconds_min = models.BooleanField(
|
||||
_('filter seconds min/max'),
|
||||
choices=FilterSeconds.choices,
|
||||
default=V(FilterSeconds.MIN),
|
||||
default=Val(FilterSeconds.MIN),
|
||||
help_text=_('When Filter Seconds is > 0, do we skip on minimum (video shorter than limit) or maximum (video '
|
||||
'greater than maximum) video duration')
|
||||
)
|
||||
@ -381,14 +381,14 @@ class Source(models.Model):
|
||||
depending on audio codec.
|
||||
'''
|
||||
if self.is_audio:
|
||||
if self.source_acodec == V(YouTube_AudioCodec.MP4A):
|
||||
return V(FileExtension.M4A)
|
||||
elif self.source_acodec == V(YouTube_AudioCodec.OPUS):
|
||||
return V(FileExtension.OGG)
|
||||
if self.source_acodec == Val(YouTube_AudioCodec.MP4A):
|
||||
return Val(FileExtension.M4A)
|
||||
elif self.source_acodec == Val(YouTube_AudioCodec.OPUS):
|
||||
return Val(FileExtension.OGG)
|
||||
else:
|
||||
raise ValueError('Unable to choose audio extension, uknown acodec')
|
||||
else:
|
||||
return V(FileExtension.MKV)
|
||||
return Val(FileExtension.MKV)
|
||||
|
||||
@classmethod
|
||||
def create_url(obj, source_type, key):
|
||||
@ -873,12 +873,12 @@ class Media(models.Model):
|
||||
resolution = self.downloaded_format.lower()
|
||||
elif self.downloaded_height:
|
||||
resolution = f'{self.downloaded_height}p'
|
||||
if self.downloaded_format != V(SourceResolution.AUDIO):
|
||||
if self.downloaded_format != Val(SourceResolution.AUDIO):
|
||||
vcodec = self.downloaded_video_codec.lower()
|
||||
fmt.append(vcodec)
|
||||
acodec = self.downloaded_audio_codec.lower()
|
||||
fmt.append(acodec)
|
||||
if self.downloaded_format != V(SourceResolution.AUDIO):
|
||||
if self.downloaded_format != Val(SourceResolution.AUDIO):
|
||||
fps = str(self.downloaded_fps)
|
||||
fmt.append(f'{fps}fps')
|
||||
if self.downloaded_hdr:
|
||||
@ -1203,15 +1203,15 @@ class Media(models.Model):
|
||||
if acodec is None:
|
||||
raise TypeError() # nothing here.
|
||||
acodec = acodec.upper()
|
||||
if acodec == V(YouTube_AudioCodec.MP4A):
|
||||
if acodec == Val(YouTube_AudioCodec.MP4A):
|
||||
return "audio/mp4"
|
||||
elif acodec == V(YouTube_AudioCodec.OPUS):
|
||||
elif acodec == Val(YouTube_AudioCodec.OPUS):
|
||||
return "audio/opus"
|
||||
else:
|
||||
# fall-fall-back.
|
||||
return 'audio/ogg'
|
||||
vcodec = vcodec.upper()
|
||||
if vcodec == V(YouTube_VideoCodec.AVC1):
|
||||
if vcodec == Val(YouTube_VideoCodec.AVC1):
|
||||
return 'video/mp4'
|
||||
else:
|
||||
return 'video/matroska'
|
||||
@ -1332,23 +1332,23 @@ class Media(models.Model):
|
||||
|
||||
def get_download_state(self, task=None):
|
||||
if self.downloaded:
|
||||
return V(MediaState.DOWNLOADED)
|
||||
return Val(MediaState.DOWNLOADED)
|
||||
if task:
|
||||
if task.locked_by_pid_running():
|
||||
return V(MediaState.DOWNLOADING)
|
||||
return Val(MediaState.DOWNLOADING)
|
||||
elif task.has_error():
|
||||
return V(MediaState.ERROR)
|
||||
return Val(MediaState.ERROR)
|
||||
else:
|
||||
return V(MediaState.SCHEDULED)
|
||||
return Val(MediaState.SCHEDULED)
|
||||
if self.skip:
|
||||
return V(MediaState.SKIPPED)
|
||||
return Val(MediaState.SKIPPED)
|
||||
if not self.source.download_media:
|
||||
return V(MediaState.DISABLED_AT_SOURCE)
|
||||
return V(MediaState.UNKNOWN)
|
||||
return Val(MediaState.DISABLED_AT_SOURCE)
|
||||
return Val(MediaState.UNKNOWN)
|
||||
|
||||
def get_download_state_icon(self, task=None):
|
||||
state = self.get_download_state(task)
|
||||
return self.STATE_ICONS.get(state, self.STATE_ICONS[V(MediaState.UNKNOWN)])
|
||||
return self.STATE_ICONS.get(state, self.STATE_ICONS[Val(MediaState.UNKNOWN)])
|
||||
|
||||
def download_media(self):
|
||||
format_str = self.get_format_str()
|
||||
@ -1489,10 +1489,10 @@ class MediaServer(models.Model):
|
||||
'''
|
||||
|
||||
ICONS = {
|
||||
V(MediaServerType.PLEX): '<i class="fas fa-server"></i>',
|
||||
Val(MediaServerType.PLEX): '<i class="fas fa-server"></i>',
|
||||
}
|
||||
HANDLERS = {
|
||||
V(MediaServerType.PLEX): PlexMediaServer,
|
||||
Val(MediaServerType.PLEX): PlexMediaServer,
|
||||
}
|
||||
|
||||
server_type = models.CharField(
|
||||
|
@ -17,7 +17,7 @@ from .tasks import (delete_task_by_source, delete_task_by_media, index_source_ta
|
||||
get_media_metadata_task, get_media_download_task)
|
||||
from .utils import delete_file, glob_quote
|
||||
from .filtering import filter_media
|
||||
from .choices import V, YouTube_SourceType
|
||||
from .choices import Val, YouTube_SourceType
|
||||
|
||||
|
||||
@receiver(pre_save, sender=Source)
|
||||
@ -53,7 +53,7 @@ def source_post_save(sender, instance, created, **kwargs):
|
||||
priority=0,
|
||||
verbose_name=verbose_name.format(instance.name)
|
||||
)
|
||||
if instance.source_type != V(YouTube_SourceType.PLAYLIST) and instance.copy_channel_images:
|
||||
if instance.source_type != Val(YouTube_SourceType.PLAYLIST) and instance.copy_channel_images:
|
||||
download_source_images(
|
||||
str(instance.pk),
|
||||
priority=2,
|
||||
|
@ -19,7 +19,7 @@ from .models import Source, Media
|
||||
from .tasks import cleanup_old_media
|
||||
from .filtering import filter_media
|
||||
from .utils import filter_response
|
||||
from .choices import (V, Fallback, IndexSchedule, SourceResolution,
|
||||
from .choices import (Val, Fallback, IndexSchedule, SourceResolution,
|
||||
YouTube_SourceType, youtube_long_source_types)
|
||||
|
||||
|
||||
@ -228,7 +228,7 @@ class FrontEndTestCase(TestCase):
|
||||
expected_categories)
|
||||
# Update the source key
|
||||
data = {
|
||||
'source_type': V(YouTube_SourceType.CHANNEL),
|
||||
'source_type': Val(YouTube_SourceType.CHANNEL),
|
||||
'key': 'updatedkey', # changed
|
||||
'name': 'testname',
|
||||
'directory': 'testdirectory',
|
||||
@ -236,15 +236,15 @@ class FrontEndTestCase(TestCase):
|
||||
'download_cap': 0,
|
||||
'filter_text': '.*',
|
||||
'filter_seconds_min': int(True),
|
||||
'index_schedule': V(IndexSchedule.EVERY_HOUR),
|
||||
'index_schedule': Val(IndexSchedule.EVERY_HOUR),
|
||||
'delete_old_media': False,
|
||||
'days_to_keep': 14,
|
||||
'source_resolution': V(SourceResolution.VIDEO_1080P),
|
||||
'source_resolution': Val(SourceResolution.VIDEO_1080P),
|
||||
'source_vcodec': Source.SOURCE_VCODEC_VP9,
|
||||
'source_acodec': Source.SOURCE_ACODEC_OPUS,
|
||||
'prefer_60fps': False,
|
||||
'prefer_hdr': False,
|
||||
'fallback': V(Fallback.FAIL),
|
||||
'fallback': Val(Fallback.FAIL),
|
||||
'sponsorblock_categories': data_categories,
|
||||
'sub_langs': 'en',
|
||||
}
|
||||
@ -265,7 +265,7 @@ class FrontEndTestCase(TestCase):
|
||||
expected_categories)
|
||||
# Update the source index schedule which should recreate the scheduled task
|
||||
data = {
|
||||
'source_type': V(YouTube_SourceType.CHANNEL),
|
||||
'source_type': Val(YouTube_SourceType.CHANNEL),
|
||||
'key': 'updatedkey',
|
||||
'name': 'testname',
|
||||
'directory': 'testdirectory',
|
||||
@ -273,15 +273,15 @@ class FrontEndTestCase(TestCase):
|
||||
'download_cap': 0,
|
||||
'filter_text': '.*',
|
||||
'filter_seconds_min': int(True),
|
||||
'index_schedule': V(IndexSchedule.EVERY_2_HOURS), # changed
|
||||
'index_schedule': Val(IndexSchedule.EVERY_2_HOURS), # changed
|
||||
'delete_old_media': False,
|
||||
'days_to_keep': 14,
|
||||
'source_resolution': V(SourceResolution.VIDEO_1080P),
|
||||
'source_resolution': Val(SourceResolution.VIDEO_1080P),
|
||||
'source_vcodec': Source.SOURCE_VCODEC_VP9,
|
||||
'source_acodec': Source.SOURCE_ACODEC_OPUS,
|
||||
'prefer_60fps': False,
|
||||
'prefer_hdr': False,
|
||||
'fallback': V(Fallback.FAIL),
|
||||
'fallback': Val(Fallback.FAIL),
|
||||
'sponsorblock_categories': data_categories,
|
||||
'sub_langs': 'en',
|
||||
}
|
||||
@ -335,19 +335,19 @@ class FrontEndTestCase(TestCase):
|
||||
self.assertEqual(response.status_code, 200)
|
||||
# Add a test source
|
||||
test_source = Source.objects.create(
|
||||
source_type=V(YouTube_SourceType.CHANNEL),
|
||||
source_type=Val(YouTube_SourceType.CHANNEL),
|
||||
key='testkey',
|
||||
name='testname',
|
||||
directory='testdirectory',
|
||||
index_schedule=V(IndexSchedule.EVERY_HOUR),
|
||||
index_schedule=Val(IndexSchedule.EVERY_HOUR),
|
||||
delete_old_media=False,
|
||||
days_to_keep=14,
|
||||
source_resolution=V(SourceResolution.VIDEO_1080P),
|
||||
source_resolution=Val(SourceResolution.VIDEO_1080P),
|
||||
source_vcodec=Source.SOURCE_VCODEC_VP9,
|
||||
source_acodec=Source.SOURCE_ACODEC_OPUS,
|
||||
prefer_60fps=False,
|
||||
prefer_hdr=False,
|
||||
fallback=V(Fallback.FAIL)
|
||||
fallback=Val(Fallback.FAIL)
|
||||
)
|
||||
# Add some media
|
||||
test_minimal_metadata = '''
|
||||
@ -516,7 +516,7 @@ class FilepathTestCase(TestCase):
|
||||
logging.disable(logging.CRITICAL)
|
||||
# Add a test source
|
||||
self.source = Source.objects.create(
|
||||
source_type=V(YouTube_SourceType.CHANNEL),
|
||||
source_type=Val(YouTube_SourceType.CHANNEL),
|
||||
key='testkey',
|
||||
name='testname',
|
||||
directory='testdirectory',
|
||||
@ -524,12 +524,12 @@ class FilepathTestCase(TestCase):
|
||||
index_schedule=3600,
|
||||
delete_old_media=False,
|
||||
days_to_keep=14,
|
||||
source_resolution=V(SourceResolution.VIDEO_1080P),
|
||||
source_resolution=Val(SourceResolution.VIDEO_1080P),
|
||||
source_vcodec=Source.SOURCE_VCODEC_VP9,
|
||||
source_acodec=Source.SOURCE_ACODEC_OPUS,
|
||||
prefer_60fps=False,
|
||||
prefer_hdr=False,
|
||||
fallback=V(Fallback.FAIL)
|
||||
fallback=Val(Fallback.FAIL)
|
||||
)
|
||||
# Add some test media
|
||||
self.media = Media.objects.create(
|
||||
@ -655,11 +655,11 @@ class FilepathTestCase(TestCase):
|
||||
self.assertTrue(isinstance(settings.SOURCE_DOWNLOAD_DIRECTORY_PREFIX, bool))
|
||||
# Test the default behavior for "True", forced "audio" or "video" parent directories for sources
|
||||
settings.SOURCE_DOWNLOAD_DIRECTORY_PREFIX = True
|
||||
self.source.source_resolution = V(SourceResolution.AUDIO)
|
||||
self.source.source_resolution = Val(SourceResolution.AUDIO)
|
||||
test_audio_prefix_path = Path(self.source.directory_path)
|
||||
self.assertEqual(test_audio_prefix_path.parts[-2], 'audio')
|
||||
self.assertEqual(test_audio_prefix_path.parts[-1], 'testdirectory')
|
||||
self.source.source_resolution = V(SourceResolution.VIDEO_1080P)
|
||||
self.source.source_resolution = Val(SourceResolution.VIDEO_1080P)
|
||||
test_video_prefix_path = Path(self.source.directory_path)
|
||||
self.assertEqual(test_video_prefix_path.parts[-2], 'video')
|
||||
self.assertEqual(test_video_prefix_path.parts[-1], 'testdirectory')
|
||||
@ -676,7 +676,7 @@ class MediaTestCase(TestCase):
|
||||
logging.disable(logging.CRITICAL)
|
||||
# Add a test source
|
||||
self.source = Source.objects.create(
|
||||
source_type=V(YouTube_SourceType.CHANNEL),
|
||||
source_type=Val(YouTube_SourceType.CHANNEL),
|
||||
key='testkey',
|
||||
name='testname',
|
||||
directory='testdirectory',
|
||||
@ -684,12 +684,12 @@ class MediaTestCase(TestCase):
|
||||
index_schedule=3600,
|
||||
delete_old_media=False,
|
||||
days_to_keep=14,
|
||||
source_resolution=V(SourceResolution.VIDEO_1080P),
|
||||
source_resolution=Val(SourceResolution.VIDEO_1080P),
|
||||
source_vcodec=Source.SOURCE_VCODEC_VP9,
|
||||
source_acodec=Source.SOURCE_ACODEC_OPUS,
|
||||
prefer_60fps=False,
|
||||
prefer_hdr=False,
|
||||
fallback=V(Fallback.FAIL)
|
||||
fallback=Val(Fallback.FAIL)
|
||||
)
|
||||
# Add some test media
|
||||
self.media = Media.objects.create(
|
||||
@ -749,7 +749,7 @@ class MediaFilterTestCase(TestCase):
|
||||
# logging.disable(logging.CRITICAL)
|
||||
# Add a test source
|
||||
self.source = Source.objects.create(
|
||||
source_type=V(YouTube_SourceType.CHANNEL),
|
||||
source_type=Val(YouTube_SourceType.CHANNEL),
|
||||
key="testkey",
|
||||
name="testname",
|
||||
directory="testdirectory",
|
||||
@ -757,12 +757,12 @@ class MediaFilterTestCase(TestCase):
|
||||
index_schedule=3600,
|
||||
delete_old_media=False,
|
||||
days_to_keep=14,
|
||||
source_resolution=V(SourceResolution.VIDEO_1080P),
|
||||
source_resolution=Val(SourceResolution.VIDEO_1080P),
|
||||
source_vcodec=Source.SOURCE_VCODEC_VP9,
|
||||
source_acodec=Source.SOURCE_ACODEC_OPUS,
|
||||
prefer_60fps=False,
|
||||
prefer_hdr=False,
|
||||
fallback=V(Fallback.FAIL),
|
||||
fallback=Val(Fallback.FAIL),
|
||||
)
|
||||
# Add some test media
|
||||
self.media = Media.objects.create(
|
||||
@ -919,19 +919,19 @@ class FormatMatchingTestCase(TestCase):
|
||||
logging.disable(logging.CRITICAL)
|
||||
# Add a test source
|
||||
self.source = Source.objects.create(
|
||||
source_type=V(YouTube_SourceType.CHANNEL),
|
||||
source_type=Val(YouTube_SourceType.CHANNEL),
|
||||
key='testkey',
|
||||
name='testname',
|
||||
directory='testdirectory',
|
||||
index_schedule=3600,
|
||||
delete_old_media=False,
|
||||
days_to_keep=14,
|
||||
source_resolution=V(SourceResolution.VIDEO_1080P),
|
||||
source_resolution=Val(SourceResolution.VIDEO_1080P),
|
||||
source_vcodec=Source.SOURCE_VCODEC_VP9,
|
||||
source_acodec=Source.SOURCE_ACODEC_OPUS,
|
||||
prefer_60fps=False,
|
||||
prefer_hdr=False,
|
||||
fallback=V(Fallback.FAIL)
|
||||
fallback=Val(Fallback.FAIL)
|
||||
)
|
||||
# Add some media
|
||||
self.media = Media.objects.create(
|
||||
@ -941,7 +941,7 @@ class FormatMatchingTestCase(TestCase):
|
||||
)
|
||||
|
||||
def test_combined_exact_format_matching(self):
|
||||
self.source.fallback = V(Fallback.FAIL)
|
||||
self.source.fallback = Val(Fallback.FAIL)
|
||||
self.media.metadata = all_test_metadata['boring']
|
||||
self.media.save()
|
||||
expected_matches = {
|
||||
@ -1071,7 +1071,7 @@ class FormatMatchingTestCase(TestCase):
|
||||
self.assertEqual(match_type, expected_match_type)
|
||||
|
||||
def test_audio_exact_format_matching(self):
|
||||
self.source.fallback = V(Fallback.FAIL)
|
||||
self.source.fallback = Val(Fallback.FAIL)
|
||||
self.media.metadata = all_test_metadata['boring']
|
||||
self.media.save()
|
||||
expected_matches = {
|
||||
@ -1217,7 +1217,7 @@ class FormatMatchingTestCase(TestCase):
|
||||
self.assertEqual(match_type, expeceted_match_type)
|
||||
|
||||
def test_video_exact_format_matching(self):
|
||||
self.source.fallback = V(Fallback.FAIL)
|
||||
self.source.fallback = Val(Fallback.FAIL)
|
||||
# Test no 60fps, no HDR metadata
|
||||
self.media.metadata = all_test_metadata['boring']
|
||||
self.media.save()
|
||||
@ -1427,7 +1427,7 @@ class FormatMatchingTestCase(TestCase):
|
||||
self.assertEqual(match_type, expeceted_match_type)
|
||||
|
||||
def test_video_next_best_format_matching(self):
|
||||
self.source.fallback = V(Fallback.NEXT_BEST)
|
||||
self.source.fallback = Val(Fallback.NEXT_BEST)
|
||||
# Test no 60fps, no HDR metadata
|
||||
self.media.metadata = all_test_metadata['boring']
|
||||
self.media.save()
|
||||
@ -1737,19 +1737,19 @@ class ResponseFilteringTestCase(TestCase):
|
||||
logging.disable(logging.CRITICAL)
|
||||
# Add a test source
|
||||
self.source = Source.objects.create(
|
||||
source_type=V(YouTube_SourceType.CHANNEL),
|
||||
source_type=Val(YouTube_SourceType.CHANNEL),
|
||||
key='testkey',
|
||||
name='testname',
|
||||
directory='testdirectory',
|
||||
index_schedule=3600,
|
||||
delete_old_media=False,
|
||||
days_to_keep=14,
|
||||
source_resolution=V(SourceResolution.VIDEO_1080P),
|
||||
source_resolution=Val(SourceResolution.VIDEO_1080P),
|
||||
source_vcodec=Source.SOURCE_VCODEC_VP9,
|
||||
source_acodec=Source.SOURCE_ACODEC_OPUS,
|
||||
prefer_60fps=False,
|
||||
prefer_hdr=False,
|
||||
fallback=V(Fallback.FAIL)
|
||||
fallback=Val(Fallback.FAIL)
|
||||
)
|
||||
# Add some media
|
||||
self.media = Media.objects.create(
|
||||
|
@ -31,7 +31,7 @@ from .utils import validate_url, delete_file
|
||||
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)
|
||||
from .choices import (V, MediaServerType, SourceResolution,
|
||||
from .choices import (Val, MediaServerType, SourceResolution,
|
||||
YouTube_SourceType, youtube_long_source_types,
|
||||
youtube_help, youtube_validation_urls)
|
||||
from . import signals
|
||||
@ -51,7 +51,7 @@ class DashboardView(TemplateView):
|
||||
# Sources
|
||||
data['num_sources'] = Source.objects.all().count()
|
||||
data['num_video_sources'] = Source.objects.filter(
|
||||
~Q(source_resolution=V(SourceResolution.AUDIO))
|
||||
~Q(source_resolution=Val(SourceResolution.AUDIO))
|
||||
).count()
|
||||
data['num_audio_sources'] = data['num_sources'] - data['num_video_sources']
|
||||
data['num_failed_sources'] = Source.objects.filter(has_failed=True).count()
|
||||
@ -170,9 +170,9 @@ class ValidateSourceView(FormView):
|
||||
help_examples = youtube_help.get('examples')
|
||||
validation_urls = youtube_validation_urls
|
||||
prepopulate_fields = {
|
||||
V(YouTube_SourceType.CHANNEL): ('source_type', 'key', 'name', 'directory'),
|
||||
V(YouTube_SourceType.CHANNEL_ID): ('source_type', 'key'),
|
||||
V(YouTube_SourceType.PLAYLIST): ('source_type', 'key'),
|
||||
Val(YouTube_SourceType.CHANNEL): ('source_type', 'key', 'name', 'directory'),
|
||||
Val(YouTube_SourceType.CHANNEL_ID): ('source_type', 'key'),
|
||||
Val(YouTube_SourceType.PLAYLIST): ('source_type', 'key'),
|
||||
}
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
@ -898,11 +898,11 @@ class AddMediaServerView(FormView):
|
||||
|
||||
template_name = 'sync/mediaserver-add.html'
|
||||
server_types = {
|
||||
'plex': V(MediaServerType.PLEX),
|
||||
'plex': Val(MediaServerType.PLEX),
|
||||
}
|
||||
server_type_names = dict(MediaServerType.choices)
|
||||
forms = {
|
||||
V(MediaServerType.PLEX): PlexMediaServerForm,
|
||||
Val(MediaServerType.PLEX): PlexMediaServerForm,
|
||||
}
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
@ -1019,7 +1019,7 @@ class UpdateMediaServerView(FormView, SingleObjectMixin):
|
||||
template_name = 'sync/mediaserver-update.html'
|
||||
model = MediaServer
|
||||
forms = {
|
||||
V(MediaServerType.PLEX): PlexMediaServerForm,
|
||||
Val(MediaServerType.PLEX): PlexMediaServerForm,
|
||||
}
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
|
Loading…
Reference in New Issue
Block a user