Download app/models/vod.py from binhugg2/api: direct link, hf CLI and curl.
- Browser
- Download file 2.88 kB
-
https://huggingface.co/spaces/binhugg2/api/resolve/main/app/models/vod.py
- Command line
-
hf download hf://spaces/binhugg2/api/app/models/vod.py
-
curl -L -o vod.py https://huggingface.co/spaces/binhugg2/api/resolve/main/app/models/vod.py
2.88 kB
| from datetime import datetime | |
| from sqlalchemy import Boolean, DateTime, Float, Index, Integer, String, Text, func | |
| from sqlalchemy.orm import Mapped, mapped_column | |
| from app.database import Base | |
| class Vod(Base): | |
| __tablename__ = "vod" | |
| id: Mapped[int] = mapped_column(Integer, primary_key=True, autoincrement=True) | |
| name: Mapped[str] = mapped_column(String(200), nullable=False, comment="影片名称") | |
| sub_name: Mapped[str | None] = mapped_column(String(500), comment="副标题/别名") | |
| en_name: Mapped[str | None] = mapped_column(String(200), comment="英文拼音") | |
| category_id: Mapped[int] = mapped_column(Integer, nullable=False, comment="分类ID") | |
| cover: Mapped[str | None] = mapped_column(String(500), comment="封面图URL") | |
| actor: Mapped[str | None] = mapped_column(String(2000), comment="演员,逗号分隔") | |
| director: Mapped[str | None] = mapped_column(String(200), comment="导演") | |
| area: Mapped[str | None] = mapped_column(String(50), comment="地区") | |
| lang: Mapped[str | None] = mapped_column(String(50), comment="语言") | |
| year: Mapped[str | None] = mapped_column(String(10), comment="年份") | |
| duration: Mapped[str | None] = mapped_column(String(20), comment="时长") | |
| score: Mapped[float | None] = mapped_column(Float, comment="评分 0-10") | |
| douban_id: Mapped[int | None] = mapped_column(Integer, comment="豆瓣ID") | |
| blurb: Mapped[str | None] = mapped_column(Text, comment="简介") | |
| content: Mapped[str | None] = mapped_column(Text, comment="详细介绍(HTML)") | |
| remarks: Mapped[str | None] = mapped_column(String(100), comment="备注(如第39集)") | |
| is_end: Mapped[bool] = mapped_column(Boolean, default=False, comment="是否完结") | |
| is_hidden: Mapped[bool] = mapped_column(Boolean, default=False, comment="是否隐藏") | |
| is_recommended: Mapped[bool] = mapped_column(Boolean, default=False, comment="是否推荐") | |
| view_count: Mapped[int] = mapped_column(Integer, default=0, 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_category_updated", "category_id", "updated_at"), | |
| # 隐藏状态 + 时间排序(用户端列表 WHERE is_hidden=0 ORDER BY updated_at) | |
| Index("ix_vod_hidden_updated", "is_hidden", "updated_at"), | |
| # 推荐列表:is_recommended + score 排序 | |
| Index("ix_vod_recommended_score", "is_recommended", "score"), | |
| # 去重查询:按名称+年份 | |
| Index("ix_vod_name_year", "name", "year"), | |
| # 去重查询:按 douban_id(唯一性较高,单列即可) | |
| Index("ix_vod_douban_id", "douban_id"), | |
| ) | |