diff --git a/tubesync/sync/choices.py b/tubesync/sync/choices.py index 80cf62139..38b721010 100644 --- a/tubesync/sync/choices.py +++ b/tubesync/sync/choices.py @@ -257,6 +257,28 @@ class YouTube_VideoCodec(models.TextChoices): AVC1 = 'AVC1', _('AVC1 (H.264)') +class AssetType(models.TextChoices): + THUMBNAIL = 'thumbnail', _('Thumbnail') + AUDIO = 'audio', _('Audio') + VIDEO = 'video', _('Video') + SUBTITLE = 'subtitle', _('Subtitle') + + +class AssetCodec(models.TextChoices): + JPEG = 'jpg', _('JPEG') + WEBP = 'webp', _('WEBP') + PNG = 'png', _('PNG') + OPUS = 'OPUS', _('Opus') + MP4A = 'M4A', _('MP4A') + AV1 = 'AV1', _('AV1') + VP9 = 'VP9', _('VP9') + AVC1 = 'AVC1', _('AVC1 (H.264)') + VTT = 'vtt', _('WebVTT') + TTML = 'ttml', _('TTML') + SRT = 'srt', _('SubRip') + ASS = 'ass', _('Advanced SubStation Alpha') + + SourceResolutionInteger = SourceResolution._integer_mapping() youtube_long_source_types = YouTube_SourceType._long_type_mapping() youtube_validation_urls = YouTube_SourceType._validation_urls() diff --git a/tubesync/sync/models/__init__.py b/tubesync/sync/models/__init__.py index a850a4e03..bb13a6ff7 100644 --- a/tubesync/sync/models/__init__.py +++ b/tubesync/sync/models/__init__.py @@ -10,6 +10,7 @@ # The order starts with independent classes # then the classes that depend on them follow. +from .codec import Codec from .media_server import MediaServer from .source import Source @@ -19,7 +20,6 @@ __all__ = [ 'get_media_file_path', 'get_media_thumb_path', - 'media_file_storage', 'MediaServer', 'Source', + 'media_file_storage', 'Codec', 'MediaServer', 'Source', 'Media', 'Metadata', 'MetadataFormat', -] - +] \ No newline at end of file diff --git a/tubesync/sync/models/codec.py b/tubesync/sync/models/codec.py new file mode 100644 index 000000000..72b800c98 --- /dev/null +++ b/tubesync/sync/models/codec.py @@ -0,0 +1,42 @@ +import uuid +from django.db import models +from django.utils.translation import gettext_lazy as _ +from ..choices import AssetType, AssetCodec + + +class Codec(models.Model): + ''' + Codec is a supported codec for a given asset type. + ''' + + uuid = models.UUIDField( + _('uuid'), + primary_key=True, + editable=False, + default=uuid.uuid4, + help_text=_('UUID of the codec'), + ) + asset_type = models.CharField( + _('asset type'), + max_length=16, + db_index=True, + choices=AssetType.choices, + help_text=_('The type of asset this codec is used for'), + ) + codec = models.CharField( + _('codec'), + max_length=16, + db_index=True, + choices=AssetCodec.choices, + help_text=_('The codec name'), + ) + + def __str__(self): + return f'{self.asset_type} / {self.codec}' + + class Meta: + verbose_name = _('Codec') + verbose_name_plural = _('Codecs') + unique_together = ( + ('asset_type', 'codec'), + ) \ No newline at end of file