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