File size: 1,549 Bytes
32ddb29
 
bf34e9d
32ddb29
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
bf34e9d
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
from datetime import datetime

from sqlalchemy import Boolean, DateTime, Index, Integer, String, func
from sqlalchemy.orm import Mapped, mapped_column

from app.database import Base


class VodSource(Base):
    __tablename__ = "vod_source"

    id: Mapped[int] = mapped_column(Integer, primary_key=True, autoincrement=True)
    vod_id: Mapped[int] = mapped_column(Integer, nullable=False, comment="影片ID")
    source_id: Mapped[int] = mapped_column(Integer, nullable=False, comment="资源站ID")
    source_vod_id: Mapped[int] = mapped_column(Integer, nullable=False, comment="源站影片ID")
    play_from: Mapped[str] = mapped_column(String(30), nullable=False, comment="播放来源")
    play_url: Mapped[str] = mapped_column(String, nullable=False, comment="播放地址(原始)")
    parse_url: Mapped[str | None] = mapped_column(String, comment="解析后URL")
    is_available: Mapped[bool] = mapped_column(Boolean, default=True, comment="是否可用")
    last_check_at: Mapped[datetime | None] = mapped_column(DateTime, comment="可用性检查时间")
    created_at: Mapped[datetime] = mapped_column(DateTime, server_default=func.now())
    updated_at: Mapped[datetime] = mapped_column(DateTime, server_default=func.now(), onupdate=func.now())

    __table_args__ = (
        # 影片详情页加载播放源(最高频查询)
        Index("ix_vod_source_vod_id", "vod_id"),
        # 采集器去重:source_id + source_vod_id 定位已有记录
        Index("ix_vod_source_source_vod", "source_id", "source_vod_id"),
    )