Compare commits

..
10 Commits
Author SHA1 Message Date
enrilinux 096ce23e3a fixed workflow
Build and Push Docker Image / build-and-push (push) Failing after 1m54s
2026-07-19 22:29:51 +02:00
enrilinux 2b7d7d228d fixed workflow 2026-07-19 22:28:19 +02:00
enrilinux d7a5238fbf fixed workflow 2026-07-19 22:15:02 +02:00
enrilinux 112f806942 fixed workflow 2026-07-19 21:55:41 +02:00
enrilinux 2ca9dacb8b fixed app.py 2026-07-19 21:52:02 +02:00
enrilinux a0b38ad75b Update .gitea/workflows/publish-package.yml 2026-03-27 15:26:13 +00:00
enrilinux c04c480ab7 Update .gitea/workflows/publish-package.yml 2026-03-27 15:24:00 +00:00
enrilinux 91c25a177f added workflow in gitea 2026-03-27 16:21:08 +01:00
enrilinux 14585880df added workflow in gitea 2026-03-27 16:20:01 +01:00
enrilinux 492c60d3df Added JS runtime (Deno) 2026-03-14 17:29:16 +01:00
3 changed files with 112 additions and 22 deletions
+61
View File
@@ -0,0 +1,61 @@
# .gitea/workflows/build.yaml
name: Build and Push Docker Image
on:
push:
branches:
- 'main'
- 'master'
jobs:
build-and-push:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install Docker (for Debian bullseye)
run: |
# Aggiorna i pacchetti
apt-get update
apt-get install -y ca-certificates curl gnupg lsb-release
# Aggiungi la chiave GPG di Docker
mkdir -p /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/debian/gpg | gpg --dearmor -o /etc/apt/keyrings/docker.gpg
# Aggiungi il repository DOCKER (usa bullseye, non bookworm!)
echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/debian bullseye stable" | tee /etc/apt/sources.list.d/docker.list > /dev/null
# Installa Docker
apt-get update
apt-get install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
# Verifica
docker --version
docker compose version
- name: Log in to Gitea Container Registry
run: |
echo "${{ secrets.AUTHTOKEN }}" | docker login \
-u "${{ secrets.REGISTRY_USER }}" \
--password-stdin \
gitea.enrilinux.ovh
- name: Extract metadata
id: meta
run: |
echo "REPO_NAME=$(echo ${GITHUB_REPOSITORY} | awk -F'/' '{print $2}')" >> $GITHUB_OUTPUT
echo "SHORT_SHA=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
- name: Build and push Docker image
run: |
REPO_NAME=$(echo ${GITHUB_REPOSITORY} | awk -F'/' '{print $2}')
SHORT_SHA=$(git rev-parse --short HEAD)
docker build -t gitea.enrilinux.ovh/${{ github.repository_owner }}/${REPO_NAME}:latest .
docker tag gitea.enrilinux.ovh/${{ github.repository_owner }}/${REPO_NAME}:latest \
gitea.enrilinux.ovh/${{ github.repository_owner }}/${REPO_NAME}:${SHORT_SHA}
docker push gitea.enrilinux.ovh/${{ github.repository_owner }}/${REPO_NAME}:latest
docker push gitea.enrilinux.ovh/${{ github.repository_owner }}/${REPO_NAME}:${SHORT_SHA}
+4 -1
View File
@@ -2,7 +2,7 @@ FROM python:3.11
WORKDIR /app WORKDIR /app
RUN apt-get update && apt-get install -y ffmpeg RUN apt-get update && apt-get install -y ffmpeg curl
COPY requirements.txt . COPY requirements.txt .
@@ -11,6 +11,9 @@ RUN pip install -r requirements.txt
RUN curl -fsSL https://deb.nodesource.com/setup_20.x | bash - \ RUN curl -fsSL https://deb.nodesource.com/setup_20.x | bash - \
&& apt-get install -y nodejs && apt-get install -y nodejs
RUN curl -fsSL https://deno.land/install.sh | sh \
&& mv /root/.deno/bin/deno /usr/local/bin/deno
COPY app ./app COPY app ./app
RUN mkdir downloads RUN mkdir downloads
+47 -21
View File
@@ -1,6 +1,5 @@
from fastapi import FastAPI, Request, Form from fastapi import FastAPI, Request, Form
from fastapi.responses import HTMLResponse, FileResponse, JSONResponse from fastapi.responses import HTMLResponse, FileResponse, JSONResponse
from fastapi.templating import Jinja2Templates
import os import os
import json import json
from datetime import datetime from datetime import datetime
@@ -9,10 +8,9 @@ from app.downloader import download_video
app = FastAPI() app = FastAPI()
templates = Jinja2Templates(directory="app/templates")
DOWNLOAD_DIR = "downloads" DOWNLOAD_DIR = "downloads"
HISTORY_FILE = "history.json" HISTORY_FILE = "history.json"
LOG_FILE = "data/app.log"
os.makedirs(DOWNLOAD_DIR, exist_ok=True) os.makedirs(DOWNLOAD_DIR, exist_ok=True)
os.makedirs("data", exist_ok=True) os.makedirs("data", exist_ok=True)
@@ -21,43 +19,71 @@ if not os.path.exists(HISTORY_FILE):
with open(HISTORY_FILE, "w") as f: with open(HISTORY_FILE, "w") as f:
json.dump([], f) json.dump([], f)
if not os.path.exists(LOG_FILE):
with open(LOG_FILE, "w") as f:
f.write("")
def write_log(message): def write_log(message):
with open(LOG_FILE, "a") as f: with open(LOG_FILE, "a") as f:
f.write(f"{datetime.now().strftime('%H:%M:%S')} - {message}\n") f.write(f"{datetime.now().strftime('%H:%M:%S')} - {message}\n")
@app.get("/", response_class=HTMLResponse) @app.get("/", response_class=HTMLResponse)
async def home(request: Request): async def home(request: Request):
return templates.TemplateResponse("index.html", {"request": request}) # Legge il file HTML direttamente
try:
with open("/app/app/templates/index.html", "r") as f:
html_content = f.read()
return HTMLResponse(content=html_content)
except Exception as e:
return HTMLResponse(content=f"<h1>Errore</h1><p>{str(e)}</p>", status_code=500)
@app.get("/test")
async def test():
return {"status": "ok", "message": "Server funzionante"}
@app.post("/download") @app.post("/download")
async def download(url: str = Form(...), mode: str = Form(...)): async def download(url: str = Form(...), mode: str = Form(...)):
path = download_video(url, mode) try:
path = download_video(url, mode)
write_log(f"Downloaded: {url} -> {path}")
# salva nella cronologia with open(HISTORY_FILE, "r") as f:
with open(HISTORY_FILE, "r") as f: history = json.load(f)
history = json.load(f)
history.append({ history.append({
"url": url, "url": url,
"mode": mode, "mode": mode,
"path": path, "path": path,
"time": datetime.now().strftime("%Y-%m-%d %H:%M") "time": datetime.now().strftime("%Y-%m-%d %H:%M")
}) })
with open(HISTORY_FILE, "w") as f: with open(HISTORY_FILE, "w") as f:
json.dump(history, f, indent=2) json.dump(history, f, indent=2)
return {"path": path} return {"path": path}
except Exception as e:
write_log(f"Error: {str(e)}")
return JSONResponse(status_code=500, content={"error": str(e)})
@app.get("/history") @app.get("/history")
async def history(): async def history():
with open(HISTORY_FILE) as f: try:
return JSONResponse(json.load(f)) with open(HISTORY_FILE) as f:
return JSONResponse(json.load(f))
except Exception as e:
return JSONResponse(status_code=500, content={"error": str(e)})
@app.get("/file") @app.get("/file")
async def file(path: str): async def file(path: str):
return FileResponse(path) try:
safe_path = os.path.join(DOWNLOAD_DIR, os.path.basename(path))
if not os.path.exists(safe_path):
return JSONResponse(status_code=404, content={"error": "File not found"})
return FileResponse(safe_path)
except Exception as e:
return JSONResponse(status_code=500, content={"error": str(e)})