goon/alembic/versions/20260512_0016_realdebrid_cache.py
goon-foss ad0284585b Initial commit
Goon — self-hosted aggregator for adult-content scene metadata.

Indexes scenes from TPDB, StashDB, and 30+ public adult tube sites.
Cross-source deduplication via perceptual hash + Levenshtein distance.
FastAPI backend + APScheduler worker + React Native (Expo) mobile client.

FOSS, ad-free, donation-funded. See README for details.
2026-05-20 10:10:22 +02:00

44 lines
1.3 KiB
Python

"""realdebrid_cache — direct stream URL cache dla RD /unrestrict/link wyników
Revision ID: 0016_realdebrid_cache
Revises: 0015_bug_reports_movie_id
Create Date: 2026-05-12
RD direct linki technically valid ~7 dni, ale cache'ujemy 24h (configurable
przez RD_CACHE_TTL_HOURS) żeby oszczędzać API quota przy replay tej samej
sceny.
"""
from collections.abc import Sequence
import sqlalchemy as sa
from alembic import op
revision: str = "0016_realdebrid_cache"
down_revision: str | None = "0015_bug_reports_movie_id"
branch_labels: str | Sequence[str] | None = None
depends_on: str | Sequence[str] | None = None
def upgrade() -> None:
op.create_table(
"realdebrid_cache",
sa.Column("hoster_url", sa.Text(), primary_key=True),
sa.Column("direct_url", sa.Text(), nullable=False),
sa.Column(
"created_at",
sa.TIMESTAMP(timezone=True),
nullable=False,
server_default=sa.text("now()"),
),
sa.Column("expires_at", sa.TIMESTAMP(timezone=True), nullable=False),
)
op.create_index(
"ix_realdebrid_cache_expires_at",
"realdebrid_cache",
["expires_at"],
)
def downgrade() -> None:
op.drop_index("ix_realdebrid_cache_expires_at", table_name="realdebrid_cache")
op.drop_table("realdebrid_cache")