feat: dedup downloads by (url, format_id) index, reuse existing files
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
"""SQLAlchemy models."""
|
||||
from datetime import datetime
|
||||
from sqlalchemy import Column, Integer, String, DateTime, BigInteger, Text
|
||||
from sqlalchemy import Column, Integer, String, DateTime, BigInteger, Text, Index
|
||||
from app.database import Base
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ class Video(Base):
|
||||
|
||||
id = Column(Integer, primary_key=True, autoincrement=True)
|
||||
task_id = Column(String(64), unique=True, index=True, nullable=False)
|
||||
url = Column(String(512), nullable=False)
|
||||
url = Column(String(512), nullable=False, index=True)
|
||||
title = Column(String(512), default="")
|
||||
platform = Column(String(32), default="twitter")
|
||||
thumbnail = Column(String(1024), default="")
|
||||
@@ -24,3 +24,7 @@ class Video(Base):
|
||||
progress = Column(Integer, default=0) # 0-100
|
||||
created_at = Column(DateTime, default=datetime.utcnow)
|
||||
updated_at = Column(DateTime, default=datetime.utcnow, onupdate=datetime.utcnow)
|
||||
|
||||
__table_args__ = (
|
||||
Index("ix_video_url_format_id", "url", "format_id"),
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user