58 lines
2.0 KiB
Python
58 lines
2.0 KiB
Python
from sqlalchemy import Column, Integer, String, Boolean, DateTime, Text
|
|
from sqlalchemy.sql import func
|
|
from ..core.database import Base
|
|
|
|
|
|
class ContentVideo(Base):
|
|
"""YouTube videos for Projects, Solutions, and Products"""
|
|
__tablename__ = "content_videos"
|
|
|
|
id = Column(Integer, primary_key=True, index=True)
|
|
|
|
# YouTube video ID (e.g., "dQw4w9WgXcQ" from https://youtube.com/watch?v=dQw4w9WgXcQ)
|
|
youtube_id = Column(String(20), nullable=False)
|
|
|
|
# Title in multiple languages
|
|
title_ko = Column(String(200), nullable=False)
|
|
title_en = Column(String(200))
|
|
title_ja = Column(String(200))
|
|
title_zh = Column(String(200))
|
|
|
|
# Optional description
|
|
description_ko = Column(Text)
|
|
description_en = Column(Text)
|
|
description_ja = Column(Text)
|
|
description_zh = Column(Text)
|
|
|
|
# Entity reference (polymorphic association)
|
|
entity_type = Column(String(20), nullable=False, index=True) # "project", "solution", "product"
|
|
entity_id = Column(Integer, nullable=False, index=True)
|
|
|
|
# Display settings
|
|
display_order = Column(Integer, default=0)
|
|
is_active = Column(Boolean, default=True)
|
|
|
|
# Timestamps
|
|
created_at = Column(DateTime(timezone=True), server_default=func.now())
|
|
updated_at = Column(DateTime(timezone=True), onupdate=func.now())
|
|
|
|
@property
|
|
def youtube_url(self) -> str:
|
|
"""Full YouTube URL"""
|
|
return f"https://www.youtube.com/watch?v={self.youtube_id}"
|
|
|
|
@property
|
|
def youtube_embed_url(self) -> str:
|
|
"""YouTube embed URL for iframe"""
|
|
return f"https://www.youtube.com/embed/{self.youtube_id}"
|
|
|
|
@property
|
|
def thumbnail_url(self) -> str:
|
|
"""YouTube thumbnail URL (max resolution)"""
|
|
return f"https://img.youtube.com/vi/{self.youtube_id}/maxresdefault.jpg"
|
|
|
|
@property
|
|
def thumbnail_url_hq(self) -> str:
|
|
"""YouTube thumbnail URL (high quality fallback)"""
|
|
return f"https://img.youtube.com/vi/{self.youtube_id}/hqdefault.jpg"
|