stem95su: scheduled Drive->site sync CronJob (every 10m)

CronJob stem95su-gdrive-sync (*/10) mounts the content PVC RW and
rclone-syncs the read-only Drive folder "claude" (stem claude/files) onto
it (rclone/rclone:1.74.3, scope=drive.readonly, empty-source guard +
--max-delete 25). ESO ExternalSecret stem95su-rclone <- Vault
secret/stem95su. Requires the GCP OAuth app published to Production or the
refresh token expires ~weekly.

Lands the gdrive-sync stack on master (it had landed on a feature branch
by accident on the shared devvm checkout).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Viktor Barzin 2026-06-09 08:42:26 +00:00
parent 05b50d2b96
commit 6d224861c4
1168 changed files with 120 additions and 358547 deletions

View file

@ -1,71 +0,0 @@
# This file is maintained automatically by "terraform init".
# Manual edits may be lost in future updates.
provider "registry.terraform.io/cloudflare/cloudflare" {
version = "4.52.7"
constraints = "~> 4.0"
hashes = [
"h1:pPItIWii5oymR+geZB219ROSPuSODPLTlM4S/u8xLvM=",
"zh:0c904ce31a4c6c4a5b3bf7ff1560e77c0cc7e2450c8553ded8e8c90398e1418b",
"zh:36183d310c36373fe4cb936b83c595c6fd3b0a94bc7827f28e5789ccbf59752e",
"zh:556a568a6f0235e8f41647de9e4d3a1e7b1d6502df8b19b54ec441f1c653ea10",
"zh:633ebbd5b0245e75e500ef9be4d9e62288f97e8da3baaa51323892a786d90285",
"zh:6acfe60cf52a65ba8f044f748548d2119e7f4fd7f8ebcb14698960d87c68f529",
"zh:890df766e9b839623b1f0437355032a3c006226a6c200cd911e15ee1a9014e9f",
"zh:904acc31ebb9d6ef68c792074b30532ee61bf515f19e0a3c75b46f126cca1f13",
"zh:a1d0a81246afc8750286d3f6fe7a8fbe6460dd2662407b28dbfbabb612e5fa9d",
"zh:a41a36fe253fc365fe2b7ffc749624688b2693b4634862fda161179ab100029f",
"zh:a7ef269e77ffa8715c8945a2c14322c7ff159ea44c15f62505f3cbb2cae3b32d",
"zh:b01aa3bed30610633b762df64332b26f8844a68c3960cebcb30f04918efc67fe",
"zh:b069cc2cd18cae10757df3ae030508eac8d55de7e49eda7a5e3e11f2f7fe6455",
"zh:b2d2c6313729ebb7465dceece374049e2d08bda34473901be9ff46a8836d42b2",
"zh:db0e114edaf4bc2f3d4769958807c83022bfbc619a00bdf4c4bd17faa4ab2d8b",
"zh:ecc0aa8b9044f664fd2aaf8fa992d976578f78478980555b4b8f6148e8d1a5fe",
]
}
provider "registry.terraform.io/hashicorp/helm" {
version = "3.1.1"
hashes = [
"h1:5b2ojWKT0noujHiweCds37ZreRFRQLNaErdJLusJN88=",
"zh:1a6d5ce931708aec29d1f3d9e360c2a0c35ba5a54d03eeaff0ce3ca597cd0275",
"zh:3411919ba2a5941801e677f0fea08bdd0ae22ba3c9ce3309f55554699e06524a",
"zh:81b36138b8f2320dc7f877b50f9e38f4bc614affe68de885d322629dd0d16a29",
"zh:95a2a0a497a6082ee06f95b38bd0f0d6924a65722892a856cfd914c0d117f104",
"zh:9d3e78c2d1bb46508b972210ad706dd8c8b106f8b206ecf096cd211c54f46990",
"zh:a79139abf687387a6efdbbb04289a0a8e7eaca2bd91cdc0ce68ea4f3286c2c34",
"zh:aaa8784be125fbd50c48d84d6e171d3fb6ef84a221dbc5165c067ce05faab4c8",
"zh:afecd301f469975c9d8f350cc482fe656e082b6ab0f677d1a816c3c615837cc1",
"zh:c54c22b18d48ff9053d899d178d9ffef7d9d19785d9bf310a07d648b7aac075b",
"zh:db2eefd55aea48e73384a555c72bac3f7d428e24147bedb64e1a039398e5b903",
"zh:ee61666a233533fd2be971091cecc01650561f1585783c381b6f6e8a390198a4",
"zh:f569b65999264a9416862bca5cd2a6177d94ccb0424f3a4ef424428912b9cb3c",
]
}
provider "registry.terraform.io/hashicorp/kubernetes" {
version = "3.1.0"
hashes = [
"h1:oodIAuFMikXNmEtil5MQgP4dfSctUBYQiGJfjbsF3NY=",
]
}
provider "registry.terraform.io/hashicorp/vault" {
version = "4.8.0"
constraints = "~> 4.0"
hashes = [
"h1:aHqgWQhDBMeZO9iUKwJYMlh4q+xNMUlMIcjRbF4d02Y=",
"zh:269ab13433f67684012ae7e15876532b0312f5d0d2002a9cf9febb1279ce5ea6",
"zh:4babc95bf0c40eb85005db1dc2ca403c46be4a71dd3e409db3711a56f7a5ca0e",
"zh:78d5eefdd9e494defcb3c68d282b8f96630502cac21d1ea161f53cfe9bb483b3",
"zh:86e27c1c625ecc24446a11eeffc3ac319b36c2b4e51251db8579256a0dbcf136",
"zh:a32f31da94824009e26b077374440b52098aecb93c92ff55dc3d31dd37c4ea25",
"zh:be0a18c6c0425518bab4fbffd82078b82036a88503b5d76064de551c9f646cbf",
"zh:be5a77fdfd36863ebeec79cd12b1d13322ffad6821d157a0b279789fa06b5937",
"zh:be8317d142a3caad74c7d936039ae27076a1b2b8312ef5208e2871a5f525977c",
"zh:c94a84895a3d9954b80e983eed4603330a5cdbbd8eef5b3c99278c2d1402ef3c",
"zh:de1fb712784dd8415f011ca5346a34f87fab6046c730557615247e511dbc7d98",
"zh:e3eafae7da550f86cae395d6660b2a0e93ec8d2b0e0e5ef982ec762e961fc952",
"zh:ff35fb1ab6add288f0f368981e56f780b50405accd1937131cba1137999c8d83",
]
}

View file

@ -1,392 +0,0 @@
variable "tls_secret_name" {
type = string
sensitive = true
}
variable "slack_channel" { type = string }
variable "nfs_server" { type = string }
resource "kubernetes_manifest" "external_secret" {
manifest = {
apiVersion = "external-secrets.io/v1beta1"
kind = "ExternalSecret"
metadata = {
name = "ytdlp-secrets"
namespace = "ytdlp"
}
spec = {
refreshInterval = "15m"
secretStoreRef = {
name = "vault-kv"
kind = "ClusterSecretStore"
}
target = {
name = "ytdlp-secrets"
}
dataFrom = [{
extract = {
key = "ytdlp"
}
}]
}
}
depends_on = [kubernetes_namespace.ytdlp]
}
variable "redis_host" { type = string }
resource "kubernetes_namespace" "ytdlp" {
metadata {
name = "ytdlp"
labels = {
"istio-injection" : "disabled"
tier = local.tiers.aux
"keel.sh/enrolled" = "true"
}
}
lifecycle {
# KYVERNO_LIFECYCLE_V1: goldilocks-vpa-auto-mode ClusterPolicy stamps this label on every namespace
ignore_changes = [metadata[0].labels["goldilocks.fairwinds.com/vpa-update-mode"]]
}
}
module "tls_secret" {
source = "../../modules/kubernetes/setup_tls_secret"
namespace = kubernetes_namespace.ytdlp.metadata[0].name
tls_secret_name = var.tls_secret_name
}
module "nfs_data_host" {
source = "../../modules/kubernetes/nfs_volume"
name = "ytdlp-data-host"
namespace = kubernetes_namespace.ytdlp.metadata[0].name
nfs_server = "192.168.1.127"
nfs_path = "/srv/nfs/ytdlp"
}
module "nfs_highlights_data_host" {
source = "../../modules/kubernetes/nfs_volume"
name = "ytdlp-highlights-data-host"
namespace = kubernetes_namespace.ytdlp.metadata[0].name
nfs_server = "192.168.1.127"
nfs_path = "/srv/nfs/ytdlp-highlights"
}
resource "kubernetes_deployment" "ytdlp" {
# resource "kubernetes_daemonset" "technitium" {
metadata {
name = "ytdlp"
namespace = kubernetes_namespace.ytdlp.metadata[0].name
labels = {
app = "ytdlp"
tier = local.tiers.aux
}
annotations = {
"diun.enable" = "true"
}
}
spec {
# strategy {
# type = "Recreate"
# }
# replicas = 1
selector {
match_labels = {
app = "ytdlp"
}
}
template {
metadata {
labels = {
app = "ytdlp"
}
}
spec {
container {
image = "tzahi12345/youtubedl-material:nightly"
name = "ytdlp"
resources {
requests = {
cpu = "25m"
memory = "512Mi"
}
limits = {
memory = "512Mi"
}
}
port {
container_port = 17442
}
volume_mount {
mount_path = "/app/appdata"
name = "data"
}
volume_mount {
mount_path = "/app/audio"
name = "data"
}
volume_mount {
mount_path = "/app/video"
name = "data"
}
volume_mount {
mount_path = "/app/users"
name = "data"
}
volume_mount {
mount_path = "/app/subscriptions"
name = "data"
}
}
volume {
name = "data"
persistent_volume_claim {
claim_name = module.nfs_data_host.claim_name
}
}
# }
}
}
}
lifecycle {
ignore_changes = [
spec[0].template[0].spec[0].dns_config, # KYVERNO_LIFECYCLE_V1
metadata[0].annotations["keel.sh/policy"],
metadata[0].annotations["keel.sh/trigger"],
metadata[0].annotations["keel.sh/pollSchedule"], # KYVERNO_LIFECYCLE_V2
metadata[0].annotations["keel.sh/match-tag"],
spec[0].template[0].spec[0].container[0].image, # KEEL_IGNORE_IMAGE Keel manages tag updates
metadata[0].annotations["kubernetes.io/change-cause"],
metadata[0].annotations["deployment.kubernetes.io/revision"],
spec[0].template[0].metadata[0].annotations["keel.sh/update-time"], # KEEL_LIFECYCLE_V1
]
}
}
resource "kubernetes_service" "ytdlp" {
metadata {
name = "ytdlp"
namespace = kubernetes_namespace.ytdlp.metadata[0].name
labels = {
"app" = "ytdlp"
}
}
spec {
selector = {
app = "ytdlp"
}
port {
name = "ytdlp"
port = 80
target_port = 17442
protocol = "TCP"
}
}
}
module "ingress" {
source = "../../modules/kubernetes/ingress_factory"
auth = "required"
namespace = kubernetes_namespace.ytdlp.metadata[0].name
name = "ytdlp"
tls_secret_name = var.tls_secret_name
host = "yt"
dns_type = "non-proxied"
extra_annotations = {
"gethomepage.dev/enabled" = "true"
"gethomepage.dev/name" = "yt-dlp"
"gethomepage.dev/description" = "Video downloader"
"gethomepage.dev/icon" = "youtube-dl.png"
"gethomepage.dev/group" = "Media & Entertainment"
"gethomepage.dev/pod-selector" = ""
}
}
# ----------------------
# yt-highlights service
# ----------------------
resource "kubernetes_deployment" "yt_highlights" {
metadata {
name = "yt-highlights"
namespace = kubernetes_namespace.ytdlp.metadata[0].name
labels = {
app = "yt-highlights"
tier = local.tiers.aux
}
annotations = {
"diun.enable" = "true"
"reloader.stakater.com/auto" = "true"
}
}
spec {
replicas = 1
strategy {
type = "Recreate"
}
selector {
match_labels = {
app = "yt-highlights"
}
}
template {
metadata {
labels = {
app = "yt-highlights"
}
}
spec {
node_selector = {
"nvidia.com/gpu.present" : "true"
}
toleration {
key = "nvidia.com/gpu"
value = "true"
effect = "NoSchedule"
}
container {
name = "yt-highlights"
image = "viktorbarzin/yt-highlights:v20-20260127"
image_pull_policy = "Always"
port {
container_port = 8000
}
env {
name = "ASR_MODEL"
value = "large-v3"
}
env {
name = "ASR_DEVICE"
value = "cuda"
}
env {
name = "OPENROUTER_MODEL"
value = "deepseek/deepseek-r1-0528:free"
}
env {
name = "OPENROUTER_API_KEY"
value_from {
secret_key_ref {
name = "ytdlp-secrets"
key = "openrouter_api_key"
}
}
}
env {
name = "DATA_PATH"
value = "/data"
}
env {
name = "SLACK_BOT_TOKEN"
value_from {
secret_key_ref {
name = "ytdlp-secrets"
key = "slack_bot_token"
}
}
}
env {
name = "SLACK_CHANNEL"
value = var.slack_channel
}
env {
name = "REDIS_URL"
value = "redis://${var.redis_host}:6379/0"
}
# Store model cache on NFS to avoid ephemeral storage eviction
env {
name = "HF_HOME"
value = "/data/cache/huggingface"
}
env {
name = "TORCH_HOME"
value = "/data/cache/torch"
}
volume_mount {
name = "data"
mount_path = "/data"
}
resources {
limits = {
"nvidia.com/gpu" = "1"
}
}
liveness_probe {
http_get {
path = "/health"
port = 8000
}
initial_delay_seconds = 180
period_seconds = 60
timeout_seconds = 60
failure_threshold = 10
}
}
volume {
name = "data"
persistent_volume_claim {
claim_name = module.nfs_highlights_data_host.claim_name
}
}
}
}
}
lifecycle {
ignore_changes = [
spec[0].template[0].spec[0].dns_config, # KYVERNO_LIFECYCLE_V1
metadata[0].annotations["keel.sh/policy"],
metadata[0].annotations["keel.sh/trigger"],
metadata[0].annotations["keel.sh/pollSchedule"], # KYVERNO_LIFECYCLE_V2
metadata[0].annotations["keel.sh/match-tag"],
spec[0].template[0].spec[0].container[0].image, # KEEL_IGNORE_IMAGE Keel manages tag updates
metadata[0].annotations["kubernetes.io/change-cause"],
metadata[0].annotations["deployment.kubernetes.io/revision"],
spec[0].template[0].metadata[0].annotations["keel.sh/update-time"], # KEEL_LIFECYCLE_V1
]
}
}
resource "kubernetes_service" "yt_highlights" {
metadata {
name = "yt-highlights"
namespace = kubernetes_namespace.ytdlp.metadata[0].name
labels = {
"app" = "yt-highlights"
}
}
spec {
selector = {
app = "yt-highlights"
}
port {
name = "http"
port = 80
target_port = 8000
protocol = "TCP"
}
}
}
module "highlights_ingress" {
source = "../../modules/kubernetes/ingress_factory"
dns_type = "non-proxied"
namespace = kubernetes_namespace.ytdlp.metadata[0].name
name = "yt-highlights"
tls_secret_name = var.tls_secret_name
host = "yt-highlights"
auth = "required"
extra_annotations = {
"gethomepage.dev/enabled" = "true"
"gethomepage.dev/name" = "YT Highlights"
"gethomepage.dev/description" = "AI video highlights"
"gethomepage.dev/icon" = "youtube.png"
"gethomepage.dev/group" = "Media & Entertainment"
"gethomepage.dev/pod-selector" = ""
}
}
# CI retrigger 2026-05-16T13:42:57+00:00 bulk enrollment apply (pipeline #689 killed)
# CI retrigger v2 2026-05-16T13:46:35+00:00
# CI retrigger v3 2026-05-16T14:06:39Z

View file

@ -1,33 +0,0 @@
# Generated by Terragrunt. Sig: nIlQXj57tbuaRZEa
terraform {
required_providers {
vault = {
source = "hashicorp/vault"
version = "~> 4.0"
}
cloudflare = {
source = "cloudflare/cloudflare"
version = "~> 4"
}
}
}
variable "kube_config_path" {
type = string
default = "~/.kube/config"
}
provider "kubernetes" {
config_path = var.kube_config_path
}
provider "helm" {
kubernetes = {
config_path = var.kube_config_path
}
}
provider "vault" {
address = "https://vault.viktorbarzin.me"
skip_child_token = true
}

View file

@ -1 +0,0 @@
../../secrets

View file

@ -1,13 +0,0 @@
include "root" {
path = find_in_parent_folders()
}
dependency "platform" {
config_path = "../platform"
skip_outputs = true
}
dependency "vault" {
config_path = "../vault"
skip_outputs = true
}

View file

@ -1,38 +0,0 @@
FROM nvidia/cuda:12.6.3-cudnn-runtime-ubuntu22.04
ENV DEBIAN_FRONTEND=noninteractive
ENV PYTHONUNBUFFERED=1
ENV PATH="/root/.local/bin:$PATH"
# Install system dependencies
RUN apt-get update && apt-get install -y \
python3 \
python3-pip \
python3-venv \
ffmpeg \
git \
curl \
&& rm -rf /var/lib/apt/lists/*
# Create app directory
WORKDIR /app
# Install Python dependencies
COPY requirements.txt .
RUN pip3 install --no-cache-dir -r requirements.txt
# Copy application code
COPY app/ ./app/
# Create data directories
RUN mkdir -p /data/audio /data/transcripts /data/highlights /data/config /data/state
# Expose port
EXPOSE 8000
# Health check
HEALTHCHECK --interval=30s --timeout=10s --start-period=60s --retries=3 \
CMD curl -f http://localhost:8000/health || exit 1
# Run the application
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000"]

View file

@ -1 +0,0 @@
# YouTube Highlights Extraction Service

File diff suppressed because it is too large Load diff

View file

@ -1,667 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>YouTube Highlights</title>
<style>
* {
box-sizing: border-box;
margin: 0;
padding: 0;
}
body {
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
background: #0f0f0f;
color: #f1f1f1;
min-height: 100vh;
padding: 20px;
}
.container {
max-width: 1200px;
margin: 0 auto;
}
h1 {
color: #ff0000;
margin-bottom: 30px;
display: flex;
align-items: center;
gap: 10px;
}
h1::before {
content: "▶";
}
h2 {
color: #aaa;
font-size: 1.1rem;
margin-bottom: 15px;
text-transform: uppercase;
letter-spacing: 1px;
}
.section {
background: #1a1a1a;
border-radius: 12px;
padding: 20px;
margin-bottom: 20px;
}
.form-row {
display: flex;
gap: 10px;
margin-bottom: 15px;
}
input[type="text"], input[type="url"] {
flex: 1;
padding: 12px 16px;
border: 1px solid #333;
border-radius: 8px;
background: #0f0f0f;
color: #f1f1f1;
font-size: 14px;
}
input:focus {
outline: none;
border-color: #ff0000;
}
button {
padding: 12px 24px;
border: none;
border-radius: 8px;
background: #ff0000;
color: white;
font-size: 14px;
font-weight: 600;
cursor: pointer;
transition: background 0.2s;
}
button:hover {
background: #cc0000;
}
button:disabled {
background: #666;
cursor: not-allowed;
}
button.secondary {
background: #333;
}
button.secondary:hover {
background: #444;
}
button.danger {
background: #333;
color: #ff6b6b;
padding: 6px 10px;
font-size: 16px;
min-width: 32px;
flex-shrink: 0;
}
button.danger:hover {
background: #552222;
color: #ff4444;
}
.channel-list {
display: flex;
flex-wrap: wrap;
gap: 10px;
}
.channel-tag {
display: flex;
align-items: center;
gap: 8px;
background: #2a2a2a;
padding: 8px 12px;
border-radius: 20px;
font-size: 13px;
}
.channel-tag .remove {
background: none;
border: none;
color: #888;
cursor: pointer;
padding: 0;
font-size: 16px;
}
.channel-tag .remove:hover {
color: #ff6b6b;
}
.jobs-list {
display: flex;
flex-direction: column;
gap: 10px;
}
.job-item {
display: flex;
align-items: center;
gap: 15px;
padding: 15px;
background: #0f0f0f;
border-radius: 8px;
}
.job-status {
width: 12px;
height: 12px;
border-radius: 50%;
flex-shrink: 0;
}
.job-status.queued { background: #888; }
.job-status.downloading { background: #3498db; animation: pulse 1s infinite; }
.job-status.transcribing { background: #9b59b6; animation: pulse 1s infinite; }
.job-status.analyzing { background: #f39c12; animation: pulse 1s infinite; }
.job-status.completed { background: #5cb85c; }
.job-status.failed { background: #d9534f; }
@keyframes pulse {
0%, 100% { opacity: 1; }
50% { opacity: 0.5; }
}
.job-info {
flex: 1;
min-width: 0;
}
.job-title {
font-weight: 500;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.job-url {
font-size: 12px;
color: #888;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.job-progress {
font-size: 12px;
color: #aaa;
margin-top: 4px;
}
.job-progress.downloading { color: #3498db; }
.job-progress.transcribing { color: #9b59b6; }
.job-progress.analyzing { color: #f39c12; }
.job-error {
font-size: 12px;
color: #d9534f;
margin-top: 4px;
}
.job-time {
font-size: 11px;
color: #666;
white-space: nowrap;
}
.video-grid {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
gap: 20px;
}
.video-card {
background: #0f0f0f;
border-radius: 12px;
overflow: hidden;
}
.video-thumbnail {
width: 100%;
aspect-ratio: 16/9;
object-fit: cover;
background: #333;
}
.video-content {
padding: 15px;
}
.video-title {
font-weight: 600;
margin-bottom: 8px;
display: -webkit-box;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
overflow: hidden;
}
.video-title a {
color: #f1f1f1;
text-decoration: none;
}
.video-title a:hover {
color: #ff0000;
}
.video-channel {
font-size: 13px;
color: #aaa;
margin-bottom: 10px;
}
.video-summary {
font-size: 13px;
color: #ccc;
line-height: 1.5;
display: -webkit-box;
-webkit-line-clamp: 3;
-webkit-box-orient: vertical;
overflow: hidden;
}
.highlights-list {
margin-top: 10px;
padding-top: 10px;
border-top: 1px solid #333;
}
.highlight-item {
display: flex;
gap: 10px;
margin-bottom: 8px;
font-size: 12px;
}
.highlight-time {
color: #ff0000;
font-family: monospace;
white-space: nowrap;
}
.highlight-time a {
color: #ff0000;
text-decoration: none;
}
.highlight-time a:hover {
text-decoration: underline;
}
.empty-state {
text-align: center;
padding: 40px;
color: #666;
}
.tabs {
display: flex;
gap: 5px;
margin-bottom: 20px;
}
.tab {
padding: 10px 20px;
background: #1a1a1a;
border: none;
border-radius: 8px 8px 0 0;
color: #888;
cursor: pointer;
}
.tab.active {
background: #2a2a2a;
color: #f1f1f1;
}
.loading {
display: inline-block;
width: 16px;
height: 16px;
border: 2px solid #333;
border-top-color: #ff0000;
border-radius: 50%;
animation: spin 1s linear infinite;
}
@keyframes spin {
to { transform: rotate(360deg); }
}
.message {
padding: 12px 16px;
border-radius: 8px;
margin-bottom: 15px;
}
.message.success {
background: #1a3a1a;
color: #5cb85c;
}
.message.error {
background: #3a1a1a;
color: #d9534f;
}
.health-status {
font-size: 12px;
color: #888;
margin-left: auto;
}
.health-status.healthy {
color: #5cb85c;
}
.health-status.unhealthy {
color: #d9534f;
}
</style>
</head>
<body>
<div class="container">
<h1>YouTube Highlights <span class="health-status" id="healthStatus">Checking...</span></h1>
<div id="message"></div>
<!-- Process Video Section -->
<div class="section">
<h2>Process a Video</h2>
<div class="form-row">
<input type="url" id="videoUrl" placeholder="Paste YouTube URL here..." />
<button id="processBtn" onclick="processVideo()">Process</button>
</div>
</div>
<!-- Channel Subscriptions -->
<div class="section">
<h2>Subscribed Channels</h2>
<div class="form-row">
<input type="text" id="channelId" placeholder="Channel ID or @handle..." />
<button class="secondary" onclick="addChannel()">Add Channel</button>
<button id="checkNewBtn" onclick="checkNewVideos()">Check for New Videos</button>
</div>
<div class="channel-list" id="channelList">
<div class="empty-state">No channels subscribed yet</div>
</div>
</div>
<!-- Active Jobs -->
<div class="section">
<h2>Processing Queue</h2>
<div class="jobs-list" id="jobsList">
<div class="empty-state">No active jobs</div>
</div>
</div>
<!-- Processed Videos -->
<div class="section">
<h2>Processed Videos</h2>
<div class="video-grid" id="videoGrid">
<div class="empty-state">No videos processed yet</div>
</div>
</div>
</div>
<script>
const API_BASE = '';
// Check health on load
async function checkHealth() {
try {
const res = await fetch(`${API_BASE}/health`);
const data = await res.json();
const el = document.getElementById('healthStatus');
if (data.status === 'healthy') {
el.textContent = `Healthy (${data.model} on ${data.device})`;
el.className = 'health-status healthy';
} else {
el.textContent = 'Unhealthy';
el.className = 'health-status unhealthy';
}
} catch (e) {
document.getElementById('healthStatus').textContent = 'Offline';
document.getElementById('healthStatus').className = 'health-status unhealthy';
}
}
function showMessage(text, type = 'success') {
const el = document.getElementById('message');
el.innerHTML = `<div class="message ${type}">${text}</div>`;
setTimeout(() => el.innerHTML = '', 5000);
}
async function processVideo() {
const url = document.getElementById('videoUrl').value.trim();
if (!url) return;
const btn = document.getElementById('processBtn');
btn.disabled = true;
btn.innerHTML = '<span class="loading"></span>';
try {
const res = await fetch(`${API_BASE}/process`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ video_url: url })
});
const data = await res.json();
if (res.ok) {
showMessage(`Job queued: ${data.job_id}`);
document.getElementById('videoUrl').value = '';
loadJobs();
} else {
showMessage(data.detail || 'Failed to process', 'error');
}
} catch (e) {
showMessage('Failed to connect', 'error');
} finally {
btn.disabled = false;
btn.textContent = 'Process';
}
}
async function loadChannels() {
try {
const res = await fetch(`${API_BASE}/channels`);
const data = await res.json();
const el = document.getElementById('channelList');
if (data.channels && data.channels.length > 0) {
el.innerHTML = data.channels.map(ch => `
<div class="channel-tag">
<span>${escapeHtml(ch.name || ch.id)}</span>
<button class="remove" onclick="removeChannel('${ch.id}')">&times;</button>
</div>
`).join('');
} else {
el.innerHTML = '<div class="empty-state">No channels subscribed yet</div>';
}
} catch (e) {
console.error('Failed to load channels', e);
}
}
async function addChannel() {
const id = document.getElementById('channelId').value.trim();
if (!id) return;
try {
const res = await fetch(`${API_BASE}/channels`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ channel_id: id })
});
if (res.ok) {
document.getElementById('channelId').value = '';
loadChannels();
showMessage('Channel added');
} else {
const data = await res.json();
showMessage(data.detail || 'Failed to add channel', 'error');
}
} catch (e) {
showMessage('Failed to connect', 'error');
}
}
async function removeChannel(id) {
try {
await fetch(`${API_BASE}/channels/${encodeURIComponent(id)}`, { method: 'DELETE' });
loadChannels();
} catch (e) {
console.error('Failed to remove channel', e);
}
}
async function checkNewVideos() {
const btn = document.getElementById('checkNewBtn');
btn.disabled = true;
btn.innerHTML = '<span class="loading"></span> Checking...';
try {
const res = await fetch(`${API_BASE}/auto-process`, { method: 'POST' });
const data = await res.json();
if (res.ok) {
const count = data.queued ? data.queued.length : 0;
if (count > 0) {
showMessage(`Found and queued ${count} new video(s) for processing`);
} else {
showMessage(`Checked ${data.channels_checked} channel(s) - no new videos found`);
}
loadJobs();
} else {
showMessage(data.detail || 'Failed to check for new videos', 'error');
}
} catch (e) {
showMessage('Failed to connect', 'error');
} finally {
btn.disabled = false;
btn.textContent = 'Check for New Videos';
}
}
async function deleteJob(jobId) {
try {
await fetch(`${API_BASE}/jobs/${encodeURIComponent(jobId)}`, { method: 'DELETE' });
loadJobs();
} catch (e) {
console.error('Failed to delete job', e);
}
}
async function loadJobs() {
try {
const res = await fetch(`${API_BASE}/jobs`);
const data = await res.json();
const el = document.getElementById('jobsList');
const jobs = data.jobs || [];
// Sort by created_at descending (newest first)
jobs.sort((a, b) => new Date(b.created_at) - new Date(a.created_at));
// Filter to show only recent jobs (last 24 hours) or active ones
const recentJobs = jobs.filter(job => {
const isActive = ['queued', 'downloading', 'transcribing', 'analyzing'].includes(job.status);
const age = Date.now() - new Date(job.created_at).getTime();
const isRecent = age < 24 * 60 * 60 * 1000; // 24 hours
return isActive || isRecent;
});
if (recentJobs.length > 0) {
el.innerHTML = recentJobs.map(job => {
const title = job.video_title || extractVideoId(job.video_url) || 'Processing...';
const timeAgo = formatTimeAgo(job.created_at);
let statusBadge = '';
if (job.status === 'completed') {
statusBadge = '<span style="color:#5cb85c">✓ Completed</span>';
} else if (job.status === 'failed') {
statusBadge = '<span style="color:#d9534f">✗ Failed</span>';
} else {
statusBadge = `<span style="color:#f39c12">${capitalize(job.status)}</span>`;
}
return `
<div class="job-item">
<div class="job-status ${job.status}"></div>
<div class="job-info">
<div class="job-title">${escapeHtml(title)}</div>
<div class="job-url">
Job: ${job.job_id} | ${statusBadge}
</div>
${job.progress ? `<div class="job-progress ${job.status}">${escapeHtml(job.progress)}</div>` : ''}
${job.error ? `<div class="job-error">Error: ${escapeHtml(job.error)}</div>` : ''}
</div>
<div class="job-time">${timeAgo}</div>
<button class="danger" onclick="deleteJob('${job.job_id}')" title="Remove from queue">&times;</button>
</div>
`;
}).join('');
} else {
el.innerHTML = '<div class="empty-state">No active jobs</div>';
}
} catch (e) {
console.error('Failed to load jobs', e);
}
}
function formatTimeAgo(dateStr) {
const date = new Date(dateStr);
const now = new Date();
const diff = Math.floor((now - date) / 1000);
if (diff < 60) return 'Just now';
if (diff < 3600) return `${Math.floor(diff / 60)}m ago`;
if (diff < 86400) return `${Math.floor(diff / 3600)}h ago`;
return `${Math.floor(diff / 86400)}d ago`;
}
function capitalize(str) {
return str.charAt(0).toUpperCase() + str.slice(1);
}
function escapeHtml(str) {
if (!str) return '';
return str.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;');
}
async function loadProcessed() {
try {
const res = await fetch(`${API_BASE}/processed`);
const data = await res.json();
const el = document.getElementById('videoGrid');
if (data.videos && data.videos.length > 0) {
el.innerHTML = data.videos.map(v => {
const highlights = v.highlights || [];
const summary = v.summary || 'No summary available';
const videoId = extractVideoId(v.video_url);
return `
<div class="video-card">
<img class="video-thumbnail" src="https://img.youtube.com/vi/${videoId}/mqdefault.jpg" alt="" />
<div class="video-content">
<div class="video-title">
<a href="${v.video_url}" target="_blank">${escapeHtml(v.video_title || 'Untitled')}</a>
</div>
<div class="video-channel">${formatDuration(v.duration_seconds)}</div>
<div class="video-summary">${escapeHtml(summary)}</div>
${highlights.length > 0 ? `
<div class="highlights-list">
${highlights.slice(0, 5).map(h => `
<div class="highlight-item">
<span class="highlight-time">
<a href="${v.video_url}&t=${h.timestamp_seconds || 0}" target="_blank">
${h.timestamp || formatTime(h.timestamp_seconds)}
</a>
</span>
<span>${escapeHtml(h.title || h.description || '')}</span>
</div>
`).join('')}
</div>
` : ''}
</div>
</div>
`;
}).join('');
} else {
el.innerHTML = '<div class="empty-state">No videos processed yet</div>';
}
} catch (e) {
console.error('Failed to load processed videos', e);
}
}
function formatDuration(seconds) {
if (!seconds) return '';
const h = Math.floor(seconds / 3600);
const m = Math.floor((seconds % 3600) / 60);
const s = Math.floor(seconds % 60);
if (h > 0) return `${h}:${m.toString().padStart(2, '0')}:${s.toString().padStart(2, '0')}`;
return `${m}:${s.toString().padStart(2, '0')}`;
}
function extractVideoId(url) {
const match = url.match(/(?:v=|\/)([\w-]{11})(?:&|$)/);
return match ? match[1] : '';
}
function formatTime(seconds) {
if (!seconds) return '0:00';
const m = Math.floor(seconds / 60);
const s = Math.floor(seconds % 60);
return `${m}:${s.toString().padStart(2, '0')}`;
}
// Initial load
checkHealth();
loadChannels();
loadJobs();
loadProcessed();
// Auto-refresh
setInterval(loadJobs, 5000);
setInterval(loadProcessed, 30000);
</script>
</body>
</html>

View file

@ -1,10 +0,0 @@
fastapi>=0.104.0
uvicorn>=0.24.0
yt-dlp==2025.12.8
faster-whisper>=1.0.0
httpx>=0.25.0
requests>=2.31.0
pydantic>=2.0.0
python-multipart>=0.0.6
feedparser>=6.0.0
redis>=5.0.0