Initial commit: KiraTV IPTV proxy server
Full-stack IPTV management system with Xtream Codes API compatibility, multi-account provider fan-out, Jellyfin local library integration, real-time dashboard, EPG support, and A/V-sync-safe stream recovery.
This commit is contained in:
@@ -0,0 +1,61 @@
|
||||
import enum
|
||||
from sqlalchemy import Column, Integer, String, Boolean, DateTime, ForeignKey, Enum, UniqueConstraint, func
|
||||
from sqlalchemy.orm import relationship
|
||||
from ..database import Base
|
||||
|
||||
|
||||
class ContentType(str, enum.Enum):
|
||||
live = "live"
|
||||
movie = "movie"
|
||||
series = "series"
|
||||
|
||||
|
||||
class Category(Base):
|
||||
__tablename__ = "categories"
|
||||
|
||||
id = Column(Integer, primary_key=True, index=True)
|
||||
name = Column(String(300), nullable=False)
|
||||
type = Column(Enum(ContentType), nullable=False)
|
||||
provider_category_id = Column(String(100), nullable=True)
|
||||
provider_account_id = Column(Integer, ForeignKey("provider_accounts.id", ondelete="CASCADE"), nullable=False)
|
||||
created_at = Column(DateTime(timezone=True), server_default=func.now())
|
||||
|
||||
channels = relationship("Channel", back_populates="category")
|
||||
catalog_entries = relationship("UserCatalogEntry", back_populates="category", cascade="all, delete-orphan")
|
||||
|
||||
__table_args__ = (
|
||||
UniqueConstraint("provider_category_id", "provider_account_id", "type", name="uq_category_provider"),
|
||||
)
|
||||
|
||||
|
||||
class Channel(Base):
|
||||
__tablename__ = "channels"
|
||||
|
||||
id = Column(Integer, primary_key=True, index=True)
|
||||
name = Column(String(500), nullable=False)
|
||||
tvg_id = Column(String(200), nullable=True, index=True)
|
||||
tvg_logo = Column(String(1000), nullable=True)
|
||||
stream_id_at_provider = Column(String(100), nullable=False)
|
||||
category_id = Column(Integer, ForeignKey("categories.id", ondelete="SET NULL"), nullable=True)
|
||||
type = Column(Enum(ContentType), nullable=False, default=ContentType.live)
|
||||
is_active = Column(Boolean, default=True, nullable=False)
|
||||
created_at = Column(DateTime(timezone=True), server_default=func.now())
|
||||
|
||||
category = relationship("Category", back_populates="channels")
|
||||
provider_maps = relationship("ChannelProviderMap", back_populates="channel", cascade="all, delete-orphan")
|
||||
|
||||
|
||||
class ChannelProviderMap(Base):
|
||||
__tablename__ = "channel_provider_map"
|
||||
|
||||
id = Column(Integer, primary_key=True, index=True)
|
||||
channel_id = Column(Integer, ForeignKey("channels.id", ondelete="CASCADE"), nullable=False)
|
||||
provider_account_id = Column(Integer, ForeignKey("provider_accounts.id", ondelete="CASCADE"), nullable=False)
|
||||
stream_url = Column(String(2000), nullable=False)
|
||||
|
||||
channel = relationship("Channel", back_populates="provider_maps")
|
||||
provider_account = relationship("ProviderAccount", back_populates="channel_maps")
|
||||
|
||||
__table_args__ = (
|
||||
UniqueConstraint("channel_id", "provider_account_id", name="uq_channel_provider"),
|
||||
)
|
||||
Reference in New Issue
Block a user