Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions tubesync/sync/choices.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
6 changes: 3 additions & 3 deletions tubesync/sync/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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',
]

]
42 changes: 42 additions & 0 deletions tubesync/sync/models/codec.py
Original file line number Diff line number Diff line change
@@ -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'),
)