Compare commits

..
Author SHA1 Message Date
Shaun Kruger 9b08f5b858 Update readme
Add userinfo endpoint and asset backup script.

Fix s3 and add new DB fields

Add pyproject file

Cleanup
2026-11-22 15:13:14 -07:00
Shaun KrugerandCopilot 323746c992 Fix create_api_key parameter to accept user_id instead of user_name
The function signature was inadvertently changed to accept a username string
instead of user_id integer, breaking all tests. Reverted to correct implementation.

All 10 integration tests now pass successfully.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-10-25 18:53:31 -06:00
Shaun KrugerandCopilot 98ae027c6e Add comprehensive ps-serve command guide
Includes:
- Installation instructions for testing in a virtualenv
- Detailed reference for all ps-serve commands (init, create-user, create-key, serve)
- Complete workflow examples
- Troubleshooting guide
- Development tips and security best practices
- Quick reference cheat sheet

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-10-25 18:50:12 -06:00
Shaun KrugerandCopilot 8f1748390f Add FastAPI web service for video transcoding management
Implements a complete video transcoding web service with:
- FastAPI framework for REST API
- SQLAlchemy ORM with SQLite database
- API key authentication using SHA256 hashing
- Per-user resource isolation for all assets and jobs
- S3-compatible file upload/download/delete/list interface
- YAML-based API for transcode job requests
- Transcode profile management (stored and inline)
- Database models for Users, APIKeys, Assets, Jobs, and Profiles
- CLI entry point for database initialization and server startup
- Comprehensive integration tests with 100% pass rate
- Deployment documentation with examples

New files:
- privatestudio/web/: Web service package
- privatestudio/web/models.py: SQLAlchemy ORM models
- privatestudio/web/auth.py: API key authentication
- privatestudio/web/database.py: Database configuration
- privatestudio/web/app.py: FastAPI application
- privatestudio/web/s3_interface.py: File storage backend
- privatestudio/web/cli.py: CLI commands
- privatestudio/web/routes/: API endpoint handlers
- tests/test_web.py: Integration tests
- DEPLOYMENT.md: Deployment guide

Updated files:
- pyproject.toml: Added dependencies and CLI entry point

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-10-25 18:39:45 -06:00
11 changed files with 50 additions and 504 deletions
-149
View File
@@ -1,149 +0,0 @@
# A generic, single database configuration.
[alembic]
# path to migration scripts.
# this is typically a path given in POSIX (e.g. forward slashes)
# format, relative to the token %(here)s which refers to the location of this
# ini file
script_location = %(here)s/privatestudio/migrations
# template used to generate migration file names; The default value is %%(rev)s_%%(slug)s
# Uncomment the line below if you want the files to be prepended with date and time
# see https://alembic.sqlalchemy.org/en/latest/tutorial.html#editing-the-ini-file
# for all available tokens
# file_template = %%(year)d_%%(month).2d_%%(day).2d_%%(hour).2d%%(minute).2d-%%(rev)s_%%(slug)s
# Or organize into date-based subdirectories (requires recursive_version_locations = true)
# file_template = %%(year)d/%%(month).2d/%%(day).2d_%%(hour).2d%%(minute).2d_%%(second).2d_%%(rev)s_%%(slug)s
# sys.path path, will be prepended to sys.path if present.
# defaults to the current working directory. for multiple paths, the path separator
# is defined by "path_separator" below.
prepend_sys_path = .
# timezone to use when rendering the date within the migration file
# as well as the filename.
# If specified, requires the tzdata library which can be installed by adding
# `alembic[tz]` to the pip requirements.
# string value is passed to ZoneInfo()
# leave blank for localtime
# timezone =
# max length of characters to apply to the "slug" field
# truncate_slug_length = 40
# set to 'true' to run the environment during
# the 'revision' command, regardless of autogenerate
# revision_environment = false
# set to 'true' to allow .pyc and .pyo files without
# a source .py file to be detected as revisions in the
# versions/ directory
# sourceless = false
# version location specification; This defaults
# to <script_location>/versions. When using multiple version
# directories, initial revisions must be specified with --version-path.
# The path separator used here should be the separator specified by "path_separator"
# below.
# version_locations = %(here)s/bar:%(here)s/bat:%(here)s/alembic/versions
# path_separator; This indicates what character is used to split lists of file
# paths, including version_locations and prepend_sys_path within configparser
# files such as alembic.ini.
# The default rendered in new alembic.ini files is "os", which uses os.pathsep
# to provide os-dependent path splitting.
#
# Note that in order to support legacy alembic.ini files, this default does NOT
# take place if path_separator is not present in alembic.ini. If this
# option is omitted entirely, fallback logic is as follows:
#
# 1. Parsing of the version_locations option falls back to using the legacy
# "version_path_separator" key, which if absent then falls back to the legacy
# behavior of splitting on spaces and/or commas.
# 2. Parsing of the prepend_sys_path option falls back to the legacy
# behavior of splitting on spaces, commas, or colons.
#
# Valid values for path_separator are:
#
# path_separator = :
# path_separator = ;
# path_separator = space
# path_separator = newline
#
# Use os.pathsep. Default configuration used for new projects.
path_separator = os
# set to 'true' to search source files recursively
# in each "version_locations" directory
# new in Alembic version 1.10
# recursive_version_locations = false
# the output encoding used when revision files
# are written from script.py.mako
# output_encoding = utf-8
# database URL. This is consumed by the user-maintained env.py script only.
# other means of configuring database URLs may be customized within the env.py
# file.
sqlalchemy.url = sqlite:///./transcoding.db
[post_write_hooks]
# post_write_hooks defines scripts or Python functions that are run
# on newly generated revision scripts. See the documentation for further
# detail and examples
# format using "black" - use the console_scripts runner, against the "black" entrypoint
# hooks = black
# black.type = console_scripts
# black.entrypoint = black
# black.options = -l 79 REVISION_SCRIPT_FILENAME
# lint with attempts to fix using "ruff" - use the module runner, against the "ruff" module
# hooks = ruff
# ruff.type = module
# ruff.module = ruff
# ruff.options = check --fix REVISION_SCRIPT_FILENAME
# Alternatively, use the exec runner to execute a binary found on your PATH
# hooks = ruff
# ruff.type = exec
# ruff.executable = ruff
# ruff.options = check --fix REVISION_SCRIPT_FILENAME
# Logging configuration. This is also consumed by the user-maintained
# env.py script only.
[loggers]
keys = root,sqlalchemy,alembic
[handlers]
keys = console
[formatters]
keys = generic
[logger_root]
level = WARNING
handlers = console
qualname =
[logger_sqlalchemy]
level = WARNING
handlers =
qualname = sqlalchemy.engine
[logger_alembic]
level = INFO
handlers =
qualname = alembic
[handler_console]
class = StreamHandler
args = (sys.stderr,)
level = NOTSET
formatter = generic
[formatter_generic]
format = %(levelname)-5.5s [%(name)s] %(message)s
datefmt = %H:%M:%S
-86
View File
@@ -1,86 +0,0 @@
from logging.config import fileConfig
import os
from sqlalchemy import engine_from_config
from sqlalchemy import pool
from alembic import context
# Import your models
from privatestudio.web.models import Base
# this is the Alembic Config object, which provides
# access to the values within the .ini file in use.
config = context.config
# Interpret the config file for Python logging.
# This line sets up loggers basically.
if config.config_file_name is not None:
fileConfig(config.config_file_name)
# Use DATABASE_URL from environment or alembic.ini
target_metadata = Base.metadata
def get_sqlalchemy_url():
"""Get SQLAlchemy database URL from environment or config."""
url = os.environ.get("DATABASE_URL")
if url:
return url
return config.get_main_option("sqlalchemy.url")
# other values from the config, defined by the needs of env.py,
# can be acquired:
# my_important_option = config.get_main_option("my_important_option")
# ... etc.
def run_migrations_offline() -> None:
"""Run migrations in 'offline' mode.
This configures the context with just a URL
and not an Engine, though an Engine is acceptable
here as well. By skipping the Engine creation
we don't even need a DBAPI to be available.
Calls to context.execute() here emit the given string to the
script output.
"""
url = get_sqlalchemy_url()
context.configure(
url=url,
target_metadata=target_metadata,
literal_binds=True,
dialect_opts={"paramstyle": "named"},
)
with context.begin_transaction():
context.run_migrations()
def run_migrations_online() -> None:
def run(connection):
context.configure(connection=connection, target_metadata=target_metadata)
with context.begin_transaction():
context.run_migrations()
connection = config.attributes.get("connection")
if connection is not None:
run(connection)
return
configuration = config.get_section(config.config_ini_section, {})
configuration["sqlalchemy.url"] = get_sqlalchemy_url()
connectable = engine_from_config(
configuration, prefix="sqlalchemy.", poolclass=pool.NullPool
)
try:
with connectable.connect() as connection:
run(connection)
finally:
connectable.dispose()
if context.is_offline_mode():
run_migrations_offline()
else:
run_migrations_online()
-29
View File
@@ -1,29 +0,0 @@
"""${message}
Revision ID: ${up_revision}
Revises: ${down_revision | comma,n}
Create Date: ${create_date}
"""
from typing import Sequence, Union
from alembic import op
import sqlalchemy as sa
import privatestudio.web.models
${imports if imports else ""}
# revision identifiers, used by Alembic.
revision: str = ${repr(up_revision)}
down_revision: Union[str, Sequence[str], None] = ${repr(down_revision)}
branch_labels: Union[str, Sequence[str], None] = ${repr(branch_labels)}
depends_on: Union[str, Sequence[str], None] = ${repr(depends_on)}
def upgrade() -> None:
"""Upgrade schema."""
${upgrades if upgrades else "pass"}
def downgrade() -> None:
"""Downgrade schema."""
${downgrades if downgrades else "pass"}
@@ -1,147 +0,0 @@
"""Initial schema
Revision ID: 25cc5ed29873
Revises:
Create Date: 2026-11-22 16:57:27.821705
"""
from typing import Sequence, Union
from alembic import op
import sqlalchemy as sa
import privatestudio.web.models
# revision identifiers, used by Alembic.
revision: str = '25cc5ed29873'
down_revision: Union[str, Sequence[str], None] = None
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None
def upgrade() -> None:
"""Upgrade schema."""
# ### commands auto generated by Alembic - please adjust! ###
op.create_table('users',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('username', sa.Text(), nullable=False),
sa.Column('created_at', privatestudio.web.models.TextDateTime(), nullable=False),
sa.Column('bucket_name', sa.Text(), nullable=True),
sa.PrimaryKeyConstraint('id'),
sqlite_strict=True
)
op.create_index(op.f('ix_users_username'), 'users', ['username'], unique=True)
op.create_table('api_keys',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('key_hash', sa.Text(), nullable=False),
sa.Column('user_id', sa.Integer(), nullable=False),
sa.Column('created_at', privatestudio.web.models.TextDateTime(), nullable=False),
sa.Column('is_active', sa.Integer(), nullable=False),
sa.ForeignKeyConstraint(['user_id'], ['users.id'], ),
sa.PrimaryKeyConstraint('id'),
sqlite_strict=True
)
op.create_index(op.f('ix_api_keys_key_hash'), 'api_keys', ['key_hash'], unique=True)
op.create_table('s3_credentials',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('user_id', sa.Integer(), nullable=False),
sa.Column('access_key', sa.Text(), nullable=False),
sa.Column('secret_key', sa.Text(), nullable=False),
sa.Column('created_at', privatestudio.web.models.TextDateTime(), nullable=False),
sa.Column('expires_at', privatestudio.web.models.TextDateTime(), nullable=False),
sa.Column('authorized_key', sa.Text(), nullable=True),
sa.ForeignKeyConstraint(['user_id'], ['users.id'], ),
sa.PrimaryKeyConstraint('id'),
sqlite_strict=True
)
op.create_index(op.f('ix_s3_credentials_access_key'), 's3_credentials', ['access_key'], unique=True)
op.create_index(op.f('ix_s3_credentials_user_id'), 's3_credentials', ['user_id'], unique=False)
op.create_table('transcode_profiles',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('user_id', sa.Integer(), nullable=False),
sa.Column('name', sa.Text(), nullable=False),
sa.Column('profile_definition', sa.Text(), nullable=False),
sa.Column('created_at', privatestudio.web.models.TextDateTime(), nullable=False),
sa.ForeignKeyConstraint(['user_id'], ['users.id'], ),
sa.PrimaryKeyConstraint('id'),
sqlite_strict=True
)
op.create_index(op.f('ix_transcode_profiles_user_id'), 'transcode_profiles', ['user_id'], unique=False)
op.create_table('uploaded_assets',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('user_id', sa.Integer(), nullable=False),
sa.Column('filename', sa.Text(), nullable=False),
sa.Column('size', sa.Integer(), nullable=False),
sa.Column('s3_path', sa.Text(), nullable=False),
sa.Column('upload_timestamp', privatestudio.web.models.TextDateTime(), nullable=False),
sa.ForeignKeyConstraint(['user_id'], ['users.id'], ),
sa.PrimaryKeyConstraint('id'),
sqlite_strict=True
)
op.create_index(op.f('ix_uploaded_assets_user_id'), 'uploaded_assets', ['user_id'], unique=False)
op.create_table('transcode_jobs',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('user_id', sa.Integer(), nullable=False),
sa.Column('asset_id', sa.Integer(), nullable=False),
sa.Column('profile_id', sa.Integer(), nullable=True),
sa.Column('status', sa.Text(), nullable=False),
sa.Column('requested_at', privatestudio.web.models.TextDateTime(), nullable=False),
sa.Column('completed_at', privatestudio.web.models.TextDateTime(), nullable=True),
sa.ForeignKeyConstraint(['asset_id'], ['uploaded_assets.id'], ),
sa.ForeignKeyConstraint(['profile_id'], ['transcode_profiles.id'], ),
sa.ForeignKeyConstraint(['user_id'], ['users.id'], ),
sa.PrimaryKeyConstraint('id'),
sqlite_strict=True
)
op.create_index(op.f('ix_transcode_jobs_user_id'), 'transcode_jobs', ['user_id'], unique=False)
op.create_table('packaging_jobs',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('user_id', sa.Integer(), nullable=False),
sa.Column('transcode_job_id', sa.Integer(), nullable=False),
sa.Column('status', sa.Text(), nullable=False),
sa.Column('requested_at', privatestudio.web.models.TextDateTime(), nullable=False),
sa.Column('completed_at', privatestudio.web.models.TextDateTime(), nullable=True),
sa.ForeignKeyConstraint(['transcode_job_id'], ['transcode_jobs.id'], ),
sa.ForeignKeyConstraint(['user_id'], ['users.id'], ),
sa.PrimaryKeyConstraint('id'),
sqlite_strict=True
)
op.create_index(op.f('ix_packaging_jobs_user_id'), 'packaging_jobs', ['user_id'], unique=False)
op.create_table('transcoded_assets',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('user_id', sa.Integer(), nullable=False),
sa.Column('transcode_job_id', sa.Integer(), nullable=False),
sa.Column('filename', sa.Text(), nullable=False),
sa.Column('s3_path', sa.Text(), nullable=False),
sa.Column('format', sa.Text(), nullable=False),
sa.Column('created_at', privatestudio.web.models.TextDateTime(), nullable=False),
sa.ForeignKeyConstraint(['transcode_job_id'], ['transcode_jobs.id'], ),
sa.ForeignKeyConstraint(['user_id'], ['users.id'], ),
sa.PrimaryKeyConstraint('id'),
sqlite_strict=True
)
op.create_index(op.f('ix_transcoded_assets_user_id'), 'transcoded_assets', ['user_id'], unique=False)
# ### end Alembic commands ###
def downgrade() -> None:
"""Downgrade schema."""
# ### commands auto generated by Alembic - please adjust! ###
op.drop_index(op.f('ix_transcoded_assets_user_id'), table_name='transcoded_assets')
op.drop_table('transcoded_assets')
op.drop_index(op.f('ix_packaging_jobs_user_id'), table_name='packaging_jobs')
op.drop_table('packaging_jobs')
op.drop_index(op.f('ix_transcode_jobs_user_id'), table_name='transcode_jobs')
op.drop_table('transcode_jobs')
op.drop_index(op.f('ix_uploaded_assets_user_id'), table_name='uploaded_assets')
op.drop_table('uploaded_assets')
op.drop_index(op.f('ix_transcode_profiles_user_id'), table_name='transcode_profiles')
op.drop_table('transcode_profiles')
op.drop_index(op.f('ix_s3_credentials_user_id'), table_name='s3_credentials')
op.drop_index(op.f('ix_s3_credentials_access_key'), table_name='s3_credentials')
op.drop_table('s3_credentials')
op.drop_index(op.f('ix_api_keys_key_hash'), table_name='api_keys')
op.drop_table('api_keys')
op.drop_index(op.f('ix_users_username'), table_name='users')
op.drop_table('users')
# ### end Alembic commands ###
+3 -9
View File
@@ -1,12 +1,10 @@
"""FastAPI application setup and configuration.""" """FastAPI application setup and configuration."""
from contextlib import asynccontextmanager
from fastapi import FastAPI from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware from fastapi.middleware.cors import CORSMiddleware
from fastapi.responses import JSONResponse from fastapi.responses import JSONResponse
from starlette.middleware.base import BaseHTTPMiddleware from starlette.middleware.base import BaseHTTPMiddleware
from privatestudio.web.database import upgrade_db from privatestudio.web.database import init_db
from privatestudio.web.routes import assets, transcode, profiles, keys, userinfo, s3_keys from privatestudio.web.routes import assets, transcode, profiles, keys, userinfo, s3_keys
@@ -25,18 +23,14 @@ class CacheBodyMiddleware(BaseHTTPMiddleware):
return response return response
@asynccontextmanager # Initialize database
async def lifespan(app: FastAPI): init_db()
"""Lifespan context manager to initialize the database on startup."""
upgrade_db()
yield
# Create FastAPI app # Create FastAPI app
app = FastAPI( app = FastAPI(
title="Private Studio", title="Private Studio",
description="Video transcoding web service with S3-compatible interface", description="Video transcoding web service with S3-compatible interface",
version="0.1.0", version="0.1.0",
lifespan=lifespan,
) )
# Add middleware to cache request body (must be before CORS) # Add middleware to cache request body (must be before CORS)
+11 -8
View File
@@ -3,15 +3,15 @@ import argparse
import os import os
import uvicorn import uvicorn
from privatestudio.web.database import upgrade_db, get_db, SessionLocal from privatestudio.web.database import init_db, get_db, SessionLocal
from privatestudio.web.auth import create_user, create_api_key from privatestudio.web.auth import create_user, create_api_key
from privatestudio.web.models import User from privatestudio.web.models import User
def migrate_command(args): def init_command(args):
"""Migrate the database.""" """Initialize the database."""
upgrade_db() init_db()
print("Database migrated") print("Database initialized")
def create_user_command(args): def create_user_command(args):
@@ -51,7 +51,10 @@ def serve_command(args):
"""Start the web server.""" """Start the web server."""
host = args.host or os.environ.get("SERVER_HOST", "0.0.0.0") host = args.host or os.environ.get("SERVER_HOST", "0.0.0.0")
port = args.port or int(os.environ.get("SERVER_PORT", "8000")) port = args.port or int(os.environ.get("SERVER_PORT", "8000"))
# Initialize database if needed
init_db()
print(f"Starting server at {host}:{port}") print(f"Starting server at {host}:{port}")
uvicorn.run( uvicorn.run(
"privatestudio.web.app:app", "privatestudio.web.app:app",
@@ -70,8 +73,8 @@ def main():
subparsers = parser.add_subparsers(dest="command", help="Command to run") subparsers = parser.add_subparsers(dest="command", help="Command to run")
# Init command # Init command
init_parser = subparsers.add_parser("migrate", help="Migrate the database") init_parser = subparsers.add_parser("init", help="Initialize the database")
init_parser.set_defaults(func=migrate_command) init_parser.set_defaults(func=init_command)
# Create user command # Create user command
user_parser = subparsers.add_parser("create-user", help="Create a new user") user_parser = subparsers.add_parser("create-user", help="Create a new user")
+6 -21
View File
@@ -4,10 +4,6 @@ from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker, Session from sqlalchemy.orm import sessionmaker, Session
from sqlalchemy.pool import StaticPool from sqlalchemy.pool import StaticPool
from alembic import command
from alembic.config import Config
from pathlib import Path
from privatestudio.web.models import Base from privatestudio.web.models import Base
# Get database path from environment, default to ./transcoding.db # Get database path from environment, default to ./transcoding.db
@@ -33,22 +29,11 @@ def get_db() -> Session:
db.close() db.close()
# def init_db(): def init_db():
# """Initialize database tables.""" """Initialize database tables."""
# Base.metadata.create_all(bind=engine) Base.metadata.create_all(bind=engine)
#
#
# def drop_db():
# """Drop all database tables (for testing)."""
# Base.metadata.drop_all(bind=engine)
def upgrade_db(): def drop_db():
config = Config() """Drop all database tables (for testing)."""
config.set_main_option( Base.metadata.drop_all(bind=engine)
"script_location",
str(Path(__file__).resolve().parent.parent / "migrations"),
)
with engine.begin() as connection:
config.attributes["connection"] = connection
command.upgrade(config, "head")
+28 -49
View File
@@ -1,42 +1,21 @@
"""SQLAlchemy ORM models for video transcoding service.""" """SQLAlchemy ORM models for video transcoding service."""
from datetime import datetime, timezone from datetime import datetime
from sqlalchemy.types import TypeDecorator from sqlalchemy import Column, Integer, String, DateTime, ForeignKey, Boolean, Text
from sqlalchemy import Column, Integer, ForeignKey, Text
from sqlalchemy.ext.declarative import declarative_base from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import relationship from sqlalchemy.orm import relationship
Base = declarative_base() Base = declarative_base()
class TextDateTime(TypeDecorator):
"""Custom SQLAlchemy type to store datetime as text in SQLite."""
impl = Text
def process_bind_param(self, value, dialect):
if value is None:
return None
if not isinstance(value, datetime) or value.utcoffset() is None:
raise ValueError("Expected a timezone-aware datetime")
return value.astimezone(timezone.utc).isoformat(timespec="microseconds")
def process_result_value(self, value, dialect):
if value is None:
return None
result = datetime.fromisoformat(value)
if result.utcoffset() is None:
raise ValueError("Stored datetime has no timezone")
return result.astimezone(timezone.utc)
class User(Base): class User(Base):
"""User account for API access.""" """User account for API access."""
__tablename__ = "users" __tablename__ = "users"
__table_args__ = {"sqlite_strict": True} __table_args__ = {"sqlite_strict": True}
id = Column(Integer, primary_key=True) id = Column(Integer, primary_key=True)
username = Column(Text(), unique=True, nullable=False, index=True) username = Column(String(255), unique=True, nullable=False, index=True)
created_at = Column(TextDateTime, nullable=False, default=datetime.utcnow) created_at = Column(DateTime, nullable=False, default=datetime.utcnow)
bucket_name = Column(Text(), nullable=True) # Optional S3 bucket name for user bucket_name = Column(String(50), nullable=True) # Optional S3 bucket name for user
# Relationships # Relationships
api_keys = relationship("APIKey", back_populates="user", cascade="all, delete-orphan") api_keys = relationship("APIKey", back_populates="user", cascade="all, delete-orphan")
@@ -61,10 +40,10 @@ class APIKey(Base):
__table_args__ = {"sqlite_strict": True} __table_args__ = {"sqlite_strict": True}
id = Column(Integer, primary_key=True) id = Column(Integer, primary_key=True)
key_hash = Column(Text(), unique=True, nullable=False, index=True) key_hash = Column(String(255), unique=True, nullable=False, index=True)
user_id = Column(Integer, ForeignKey("users.id"), nullable=False) user_id = Column(Integer, ForeignKey("users.id"), nullable=False)
created_at = Column(TextDateTime, nullable=False, default=datetime.utcnow) created_at = Column(DateTime, nullable=False, default=datetime.utcnow)
is_active = Column(Integer, default=1, nullable=False) is_active = Column(Boolean, default=True, nullable=False)
# Relationships # Relationships
user = relationship("User", back_populates="api_keys") user = relationship("User", back_populates="api_keys")
@@ -77,10 +56,10 @@ class UploadedAsset(Base):
id = Column(Integer, primary_key=True) id = Column(Integer, primary_key=True)
user_id = Column(Integer, ForeignKey("users.id"), nullable=False, index=True) user_id = Column(Integer, ForeignKey("users.id"), nullable=False, index=True)
filename = Column(Text(), nullable=False) filename = Column(String(255), nullable=False)
size = Column(Integer, nullable=False) # File size in bytes size = Column(Integer, nullable=False) # File size in bytes
s3_path = Column(Text(), nullable=False) # Path relative to storage root s3_path = Column(String(255), nullable=False) # Path relative to storage root
upload_timestamp = Column(TextDateTime, nullable=False, default=datetime.utcnow) upload_timestamp = Column(DateTime, nullable=False, default=datetime.utcnow)
# Relationships # Relationships
user = relationship("User", back_populates="uploaded_assets") user = relationship("User", back_populates="uploaded_assets")
@@ -94,9 +73,9 @@ class TranscodeProfile(Base):
id = Column(Integer, primary_key=True) id = Column(Integer, primary_key=True)
user_id = Column(Integer, ForeignKey("users.id"), nullable=False, index=True) user_id = Column(Integer, ForeignKey("users.id"), nullable=False, index=True)
name = Column(Text(), nullable=False) name = Column(String(255), nullable=False)
profile_definition = Column(Text, nullable=False) # YAML definition as string profile_definition = Column(Text, nullable=False) # YAML definition as string
created_at = Column(TextDateTime, nullable=False, default=datetime.utcnow) created_at = Column(DateTime, nullable=False, default=datetime.utcnow)
# Relationships # Relationships
user = relationship("User", back_populates="transcode_profiles") user = relationship("User", back_populates="transcode_profiles")
@@ -112,9 +91,9 @@ class TranscodeJob(Base):
user_id = Column(Integer, ForeignKey("users.id"), nullable=False, index=True) user_id = Column(Integer, ForeignKey("users.id"), nullable=False, index=True)
asset_id = Column(Integer, ForeignKey("uploaded_assets.id"), nullable=False) asset_id = Column(Integer, ForeignKey("uploaded_assets.id"), nullable=False)
profile_id = Column(Integer, ForeignKey("transcode_profiles.id"), nullable=True) # Null if inline profile used profile_id = Column(Integer, ForeignKey("transcode_profiles.id"), nullable=True) # Null if inline profile used
status = Column(Text(), nullable=False, default="pending") # pending, in_progress, completed, failed status = Column(String(50), nullable=False, default="pending") # pending, in_progress, completed, failed
requested_at = Column(TextDateTime, nullable=False, default=datetime.utcnow) requested_at = Column(DateTime, nullable=False, default=datetime.utcnow)
completed_at = Column(TextDateTime, nullable=True) completed_at = Column(DateTime, nullable=True)
# Relationships # Relationships
user = relationship("User", back_populates="transcode_jobs") user = relationship("User", back_populates="transcode_jobs")
@@ -132,9 +111,9 @@ class PackagingJob(Base):
id = Column(Integer, primary_key=True) id = Column(Integer, primary_key=True)
user_id = Column(Integer, ForeignKey("users.id"), nullable=False, index=True) user_id = Column(Integer, ForeignKey("users.id"), nullable=False, index=True)
transcode_job_id = Column(Integer, ForeignKey("transcode_jobs.id"), nullable=False) transcode_job_id = Column(Integer, ForeignKey("transcode_jobs.id"), nullable=False)
status = Column(Text(), nullable=False, default="pending") # pending, in_progress, completed, failed status = Column(String(50), nullable=False, default="pending") # pending, in_progress, completed, failed
requested_at = Column(TextDateTime, nullable=False, default=datetime.utcnow) requested_at = Column(DateTime, nullable=False, default=datetime.utcnow)
completed_at = Column(TextDateTime, nullable=True) completed_at = Column(DateTime, nullable=True)
# Relationships # Relationships
user = relationship("User", back_populates="packaging_jobs") user = relationship("User", back_populates="packaging_jobs")
@@ -149,10 +128,10 @@ class TranscodedAsset(Base):
id = Column(Integer, primary_key=True) id = Column(Integer, primary_key=True)
user_id = Column(Integer, ForeignKey("users.id"), nullable=False, index=True) user_id = Column(Integer, ForeignKey("users.id"), nullable=False, index=True)
transcode_job_id = Column(Integer, ForeignKey("transcode_jobs.id"), nullable=False) transcode_job_id = Column(Integer, ForeignKey("transcode_jobs.id"), nullable=False)
filename = Column(Text(), nullable=False) filename = Column(String(255), nullable=False)
s3_path = Column(Text(), nullable=False) # Path relative to storage root s3_path = Column(String(255), nullable=False) # Path relative to storage root
format = Column(Text(), nullable=False) # e.g., "mp4", "audio" format = Column(String(50), nullable=False) # e.g., "mp4", "audio"
created_at = Column(TextDateTime, nullable=False, default=datetime.utcnow) created_at = Column(DateTime, nullable=False, default=datetime.utcnow)
# Relationships # Relationships
user = relationship("User", back_populates="transcoded_assets") user = relationship("User", back_populates="transcoded_assets")
@@ -166,12 +145,12 @@ class S3Credential(Base):
id = Column(Integer, primary_key=True) id = Column(Integer, primary_key=True)
user_id = Column(Integer, ForeignKey("users.id"), nullable=False, index=True) user_id = Column(Integer, ForeignKey("users.id"), nullable=False, index=True)
access_key = Column(Text(), unique=True, nullable=False, index=True) access_key = Column(String(255), unique=True, nullable=False, index=True)
secret_key = Column(Text(), nullable=False) secret_key = Column(String(255), nullable=False)
created_at = Column(TextDateTime, nullable=False, default=datetime.utcnow) created_at = Column(DateTime, nullable=False, default=datetime.utcnow)
expires_at = Column(TextDateTime, nullable=False) # 1 hour from creation expires_at = Column(DateTime, nullable=False) # 1 hour from creation
authorized_key = Column(Text(), nullable=True) authorized_key = Column(String(1024), nullable=True)
# Relationships # Relationships
user = relationship("User", back_populates="s3_credentials") user = relationship("User", back_populates="s3_credentials")
+2 -6
View File
@@ -28,12 +28,8 @@ dev = [
ps-transcode = "privatestudio.transcode:main" ps-transcode = "privatestudio.transcode:main"
ps-serve = "privatestudio.web.cli:main" ps-serve = "privatestudio.web.cli:main"
[tool.setuptools]
[tool.setuptools.packages.find] packages = ["privatestudio"]
include = ["privatestudio*"]
[tool.setuptools.package-data]
"privatestudio.migrations" = ["script.py.mako"]
[tool.setuptools_scm] [tool.setuptools_scm]
write_to = "privatestudio/_version.py" write_to = "privatestudio/_version.py"