Implement Phase 6: MeTube download integration
- MeTubeClient encapsulates all MeTube HTTP/Socket.IO calls (verified against
the real MeTube source: /add returns no job id, GET /history gives a queue
snapshot for reconciliation, filenames arrive already relative, percent is
a 0-100 float)
- download_jobs table + service: request/dedup active downloads, apply live
Socket.IO events (added/updated/completed/canceled/cleared) matched by
canonical YouTube URL, safe relative-path -> public media URL construction
- Reconciliation on startup against MeTube's live queue/done state (section 19):
non-terminal jobs recovered where possible, else marked "unknown"; already
completed jobs are left untouched
- POST/GET /api/videos/{id}/download(-status), recheck-local; feed/video
detail now report real local availability instead of a stub
- Frontend: download button with live status polling (queued/downloading %/
postprocessing/completed/failed+retry), local <video> playback with
YouTube fallback on playback error
- health.py now delegates to MeTubeClient (single place for MeTube calls)
26 new backend tests (63 total). Verified live: Socket.IO connects
successfully to the real MeTube instance on deploy.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
parent
0ed20bb838
commit
fe16c08daa
27 changed files with 1125 additions and 48 deletions
40
migrations/versions/0005_download_jobs.py
Normal file
40
migrations/versions/0005_download_jobs.py
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
"""download_jobs
|
||||
|
||||
Revision ID: 0005_download_jobs
|
||||
Revises: 0004_videos
|
||||
Create Date: 2026-09-16
|
||||
|
||||
"""
|
||||
from typing import Sequence, Union
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
revision: str = "0005_download_jobs"
|
||||
down_revision: Union[str, None] = "0004_videos"
|
||||
branch_labels: Union[str, Sequence[str], None] = None
|
||||
depends_on: Union[str, Sequence[str], None] = None
|
||||
|
||||
|
||||
def upgrade() -> None:
|
||||
op.create_table(
|
||||
"download_jobs",
|
||||
sa.Column("id", sa.Integer(), primary_key=True, autoincrement=True),
|
||||
sa.Column("video_id", sa.Integer(), sa.ForeignKey("videos.id"), nullable=False),
|
||||
sa.Column("status", sa.String(length=20), nullable=False, server_default="queued"),
|
||||
sa.Column("metube_job_id", sa.String(length=255), nullable=True),
|
||||
sa.Column("metube_filename", sa.String(), nullable=True),
|
||||
sa.Column("media_url", sa.String(), nullable=True),
|
||||
sa.Column("progress_percent", sa.Integer(), nullable=True),
|
||||
sa.Column("error_message", sa.Text(), nullable=True),
|
||||
sa.Column("requested_at", sa.DateTime(timezone=True), server_default=sa.func.now(), nullable=False),
|
||||
sa.Column("started_at", sa.DateTime(timezone=True), nullable=True),
|
||||
sa.Column("completed_at", sa.DateTime(timezone=True), nullable=True),
|
||||
sa.Column("updated_at", sa.DateTime(timezone=True), server_default=sa.func.now(), nullable=False),
|
||||
)
|
||||
op.create_index("ix_download_jobs_video_id", "download_jobs", ["video_id"])
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
op.drop_index("ix_download_jobs_video_id", table_name="download_jobs")
|
||||
op.drop_table("download_jobs")
|
||||
Loading…
Add table
Add a link
Reference in a new issue