init
This commit is contained in:
1 parent
b9d2f99c3b
commit
ed58376600
18 files changed
+2349
-2
No files matched your search
@@ -0,0 +1,11 @@
|
||||
# .env.example — copy to .env and fill values
|
||||
MONGO_URI=mongodb://username:password@192.168.20.21:27023
|
||||
MONGO_DB=downloads
|
||||
TOKEN_PREFIX=prefix=
|
||||
WORKERS=4
|
||||
OUTPUT_DIR=/mnt/media/WIP/
|
||||
PORT=3000
|
||||
|
||||
|
||||
# Optional
|
||||
LOG_LEVEL=info
|
||||
@@ -1,4 +1,5 @@
|
||||
# ---> Java
|
||||
node_modules
|
||||
# Compiled class file
|
||||
*.class
|
||||
|
||||
|
||||
@@ -1,2 +1,32 @@
|
||||
# Proxer-Downloader
|
||||
|
||||
Proxer (Token) -> Proxer-Downloader Web (Parameter) -> Python Script (Execution)
|
||||
|
||||
### Available Parameters
|
||||
scripts/proxer-dl-series.py:
|
||||
-i id [Number] [Required]
|
||||
-n name [String] (Default: id_episode_language) [Optional (uncertain about that)]
|
||||
-e episode range (delimiter "-") [String] [Required]
|
||||
-l language [String] ["engsub", "engdub", "gersub", "gerdub"]
|
||||
-t token [String] [Required]
|
||||
-o output dir [String] (Default: /mnt/media/WIP/)
|
||||
|
||||
scripts/proxer-dl-video.py:
|
||||
-u url [String] [Required]
|
||||
-f filename [String] (Default: id_episode_language) [Optional (uncertain about that)]
|
||||
-t token [String] [Required]
|
||||
-o output dir [String] (Default: /mnt/media/WIP/)
|
||||
|
||||
|
||||
### Behaviour
|
||||
|
||||
- builds urls from parameters or vice versa, e.g.: https://proxer.me/watch/<id>/<episode>/<language>
|
||||
- save urls in a queue mongodb at 192.168.20.21:27023
|
||||
- should support multi-downloading up to 4 simultaenously using the queue db=downloads, collection=queue
|
||||
- remove after downloaded and add success message, and download params to collection=done
|
||||
- the token is always appened to a existing prefix
|
||||
- use dotenv to store sensitive information, like mongodb connection string, and the token prefix
|
||||
- Interface is a WebApp using express.js and ejs views in a dark/grey with red accent colors
|
||||
- bootstrap flip/toggle switch at the top to toggle between Video and Series
|
||||
- parameters manually appear depending on the mode
|
||||
- at any error from the python script, it should prompt the website saying 'Token expired or Captcha required' with a confirm button to refresh and try again
|
||||
@@ -0,0 +1,118 @@
|
||||
const { getDb } = require("../lib/mongo");
|
||||
|
||||
exports.enqueue = async (req, res) => {
|
||||
try {
|
||||
const db = await getDb();
|
||||
const body = req.body;
|
||||
|
||||
// Token always required
|
||||
if (!body.token) throw new Error("token required");
|
||||
|
||||
const token_prefix = process.env.TOKEN_PREFIX;
|
||||
const token = token_prefix + body.token;
|
||||
|
||||
// =========================================
|
||||
// VIDEO MODE
|
||||
// =========================================
|
||||
if (body.mode === "video") {
|
||||
if (!body.url) throw new Error("url required");
|
||||
var filename
|
||||
if (!body.filename) {
|
||||
let split_slash = body.url.split('/')
|
||||
let split_hash = `${split_slash[4]} E${split_slash[5]} ${split_slash[6]}`.split('#')
|
||||
filename = split_hash[0]
|
||||
} else {
|
||||
filename = body.filename;
|
||||
}
|
||||
|
||||
await db.collection("queue").insertOne({
|
||||
url: body.url,
|
||||
token,
|
||||
filename,
|
||||
created_at: new Date()
|
||||
});
|
||||
|
||||
return res.redirect("/status");
|
||||
}
|
||||
|
||||
// =========================================
|
||||
// SERIES MODE
|
||||
// =========================================
|
||||
if (body.mode === "series") {
|
||||
if (!body.id) throw new Error("id required");
|
||||
if (!body.language) throw new Error("language required");
|
||||
if (!body.episode_from) throw new Error("episode_from required");
|
||||
if (!body.episode_to) throw new Error("episode_to required");
|
||||
|
||||
const id = body.id;
|
||||
const lang = body.language;
|
||||
const name = body.name?.trim() || null;
|
||||
|
||||
const from = parseInt(body.episode_from);
|
||||
const to = parseInt(body.episode_to);
|
||||
|
||||
if (isNaN(from) || from <= 0)
|
||||
throw new Error("episode_from must be a valid number");
|
||||
|
||||
if (isNaN(to) || to < from)
|
||||
throw new Error("episode_to must be >= episode_from");
|
||||
|
||||
// Insert one queue item per episode
|
||||
const ops = [];
|
||||
|
||||
for (let ep = from; ep <= to; ep++) {
|
||||
const url = `https://proxer.me/watch/${id}/${ep}/${lang}`;
|
||||
|
||||
const filename =
|
||||
name
|
||||
? `${name}_E${ep}.mp4`
|
||||
: `${id}_${ep}_${lang}.mp4`;
|
||||
|
||||
ops.push({
|
||||
insertOne: {
|
||||
document: {
|
||||
url,
|
||||
token,
|
||||
filename,
|
||||
created_at: new Date()
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
await db.collection("queue").bulkWrite(ops);
|
||||
|
||||
return res.redirect("/status");
|
||||
}
|
||||
|
||||
throw new Error("Invalid mode");
|
||||
|
||||
} catch (err) {
|
||||
res.render("error", {
|
||||
title: "Enqueue Failed",
|
||||
message: err.message,
|
||||
details: err.stack
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
exports.status = async (req, res) => {
|
||||
const db = await getDb();
|
||||
|
||||
const queued = await db.collection("queue")
|
||||
.find({}).sort({ created_at: 1 }).toArray();
|
||||
|
||||
const done = await db.collection("done")
|
||||
.find({}).sort({ finished_at: -1 }).toArray();
|
||||
|
||||
const failed = await db.collection("failed")
|
||||
.find({}).sort({ failed_at: -1 }).toArray();
|
||||
|
||||
res.render("status", {
|
||||
title: "Queue Status",
|
||||
queued,
|
||||
finished: done,
|
||||
failed
|
||||
});
|
||||
};
|
||||
Generated
+1480
File diff suppressed because it is too large.
Load diff
+12
-2
@@ -2,7 +2,7 @@
|
||||
"name": "proxer-downloader",
|
||||
"version": "2.0.0",
|
||||
"description": "",
|
||||
"main": "index.js",
|
||||
"main": "server.js",
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
@@ -11,5 +11,15 @@
|
||||
"url": "https://git.desq-gaming.de/admin_rb/Proxer-Downloader.git"
|
||||
},
|
||||
"author": "DeSqBlocki",
|
||||
"license": "MIT"
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"body-parser": "^2.2.1",
|
||||
"dotenv": "^17.2.3",
|
||||
"ejs": "^3.1.10",
|
||||
"express": "^5.2.1",
|
||||
"express-validator": "^7.3.1",
|
||||
"mongodb": "^7.0.0",
|
||||
"morgan": "^1.10.1",
|
||||
"nodemon": "^3.1.11"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,168 @@
|
||||
/* ===============================
|
||||
GLOBAL STYLING — Dark Grey Theme
|
||||
=============================== */
|
||||
|
||||
body {
|
||||
background: #2C2C2C; /* dark grey */
|
||||
color: #E0E0E0; /* soft light grey text */
|
||||
font-family: Arial, sans-serif;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
/* Container boundaries (Bootstrap container inside layout.ejs) */
|
||||
.container {
|
||||
max-width: 1100px;
|
||||
}
|
||||
|
||||
/* ===============================
|
||||
HEADER / NAVIGATION
|
||||
=============================== */
|
||||
|
||||
header h1 {
|
||||
font-size: 2.4rem;
|
||||
font-weight: 700;
|
||||
margin: 0;
|
||||
color: #8A190B; /* deep red accent */
|
||||
text-shadow: 2px 2px 4px rgba(0,0,0,0.6);
|
||||
}
|
||||
|
||||
.btn-outline-light {
|
||||
color: #E0E0E0;
|
||||
border-color: #5A5A5A;
|
||||
}
|
||||
.btn-outline-light:hover {
|
||||
background-color: #5A5A5A;
|
||||
}
|
||||
|
||||
/* ===============================
|
||||
CARDS / PANELS
|
||||
=============================== */
|
||||
|
||||
.card-dark,
|
||||
.card {
|
||||
background-color: #3A3A3A !important; /* mid-grey panels */
|
||||
border-radius: 10px;
|
||||
padding: 20px;
|
||||
border: 1px solid #444;
|
||||
box-shadow: 0 4px 20px rgba(0, 0, 0, 0.35);
|
||||
}
|
||||
|
||||
/* list group items in status.ejs */
|
||||
.list-group-item {
|
||||
background-color: #3A3A3A;
|
||||
border-color: #4A4A4A;
|
||||
color: #E0E0E0;
|
||||
}
|
||||
.list-group-item:hover {
|
||||
background-color: #4A4A4A;
|
||||
}
|
||||
|
||||
/* ===============================
|
||||
FORM ELEMENTS
|
||||
=============================== */
|
||||
|
||||
.form-text {
|
||||
color: #BEBEBE !important; /* same as form label */
|
||||
}
|
||||
|
||||
.form-label {
|
||||
color: #BEBEBE;
|
||||
}
|
||||
|
||||
.form-control,
|
||||
.form-select {
|
||||
background-color: #4A4A4A;
|
||||
color: #E0E0E0;
|
||||
border: 1px solid #5A5A5A;
|
||||
}
|
||||
|
||||
.form-control:focus,
|
||||
.form-select:focus {
|
||||
border-color: #2980B9; /* same blue accent as reference */
|
||||
box-shadow: 0 0 0 0.25rem rgba(41, 128, 185, 0.25);
|
||||
}
|
||||
|
||||
/* Toggle switch label */
|
||||
.form-check-label {
|
||||
color: #BEBEBE !important;
|
||||
}
|
||||
|
||||
::placeholder {
|
||||
color: #BEBEBE !important; /* Same as label color */
|
||||
}
|
||||
|
||||
|
||||
/* ===============================
|
||||
BUTTONS
|
||||
=============================== */
|
||||
|
||||
.btn-danger {
|
||||
background-color: #8A190B; /* deeper red accent */
|
||||
border: none;
|
||||
color: white;
|
||||
transition: background 0.3s ease;
|
||||
}
|
||||
.btn-danger:hover {
|
||||
background-color: #A32012;
|
||||
}
|
||||
|
||||
button,
|
||||
.btn {
|
||||
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
|
||||
}
|
||||
|
||||
/* ===============================
|
||||
ALERTS
|
||||
=============================== */
|
||||
|
||||
.alert-danger {
|
||||
background-color: #4A1C1C;
|
||||
border-color: #8A190B;
|
||||
color: #E0E0E0;
|
||||
}
|
||||
|
||||
/* ===============================
|
||||
SCROLLBAR (dark theme)
|
||||
=============================== */
|
||||
|
||||
::-webkit-scrollbar {
|
||||
width: 8px;
|
||||
}
|
||||
::-webkit-scrollbar-thumb {
|
||||
background-color: #5A5A5A;
|
||||
border-radius: 4px;
|
||||
}
|
||||
::-webkit-scrollbar-thumb:hover {
|
||||
background-color: #7D7D7D;
|
||||
}
|
||||
|
||||
/* ===============================
|
||||
LINKS
|
||||
=============================== */
|
||||
|
||||
a {
|
||||
color: #B04232;
|
||||
}
|
||||
a:hover {
|
||||
color: #E05D4A;
|
||||
}
|
||||
|
||||
/* ===============================
|
||||
FOOTER
|
||||
=============================== */
|
||||
|
||||
footer {
|
||||
color: #BEBEBE !important;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
/* ===============================
|
||||
RESPONSIVE
|
||||
=============================== */
|
||||
|
||||
@media (max-width: 768px) {
|
||||
header h1 {
|
||||
font-size: 1.8rem;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
const express = require("express");
|
||||
const router = express.Router();
|
||||
const queue = require("../controllers/queueController");
|
||||
|
||||
router.get("/", (req, res) =>
|
||||
res.render("index", { title: "Proxer Downloader" })
|
||||
);
|
||||
|
||||
router.post("/queue", queue.enqueue); // <-- FIXED
|
||||
|
||||
router.get("/status", queue.status);
|
||||
|
||||
module.exports = router;
|
||||
@@ -0,0 +1,62 @@
|
||||
import sys
|
||||
import argparse
|
||||
from lib.proxer_utils import get_embed_url, get_mp4_url, download_mp4
|
||||
from time import sleep
|
||||
|
||||
def download_series_series(serie_id, pretty_name, episode_range, language, auth_token, output_dir):
|
||||
"""
|
||||
Downloads all episodes in a specified range of a series.
|
||||
|
||||
:param serie_id: The ID of the series (Proxer)
|
||||
:param pretty_name: Pretty name for the series used in file names
|
||||
:param episode_range: A string in the format of "start-end" (inclusive range of episodes)
|
||||
:param language: The preferred language (e.g., 'engsub', 'gerdub')
|
||||
:param auth_token: A tuple containing (cookie_name, cookie_value)
|
||||
:param output_dir: Directory to store downloaded videos
|
||||
"""
|
||||
start, end = map(int, episode_range.split("-"))
|
||||
for episode_number in range(start, end + 1):
|
||||
episode_url = f"https://proxer.me/watch/{serie_id}/{episode_number}/{language}"
|
||||
try:
|
||||
print(f"Fetching embed URL for episode {episode_number} for {episode_url}...")
|
||||
embed_url = get_embed_url(episode_url, auth_token)
|
||||
print(f"Embed URL fetched for episode {episode_number}: {embed_url}")
|
||||
|
||||
print(f"Fetching MP4 URL for episode {episode_number}...")
|
||||
mp4_url = get_mp4_url(embed_url)
|
||||
print(f"MP4 URL fetched for episode {episode_number}: {mp4_url}")
|
||||
|
||||
# Prepare the output file path
|
||||
output_file = f"{output_dir}/{pretty_name}_Episode_{episode_number}_{language}.mp4"
|
||||
|
||||
# Download the episode
|
||||
print(f"Downloading episode {episode_number}...")
|
||||
download_mp4(mp4_url, output_file, label=f"Episode {episode_number} ({language})")
|
||||
print(f"Episode {episode_number} downloaded successfully!")
|
||||
|
||||
except Exception as e:
|
||||
print(f"Error downloading episode {episode_number}: {e}")
|
||||
# Optional: Sleep between downloads to avoid being rate-limited
|
||||
sleep(1)
|
||||
|
||||
def parse_args():
|
||||
"""Parse command-line arguments"""
|
||||
parser = argparse.ArgumentParser(description="Download a series from Proxer.me")
|
||||
parser.add_argument('-i', '--id', required=True, type=str, help="The series ID on Proxer.me")
|
||||
parser.add_argument('-n', '--name', required=True, type=str, help="The pretty name of the series")
|
||||
parser.add_argument('-e', '--episodes', required=True, type=str, help="Episode range (start-end), e.g. 1-10")
|
||||
parser.add_argument('-l', '--language', required=True, choices=['engsub', 'engdub', 'gersub', 'gerdub'], help="Language of the subtitles/audio")
|
||||
parser.add_argument('-t', '--token', required=True, type=str, help="Proxer authentication token")
|
||||
parser.add_argument('-o', '--output', required=True, type=str, help="Directory to store downloaded videos")
|
||||
|
||||
return parser.parse_args()
|
||||
|
||||
if __name__ == "__main__":
|
||||
# Parse command-line arguments
|
||||
args = parse_args()
|
||||
|
||||
# Assuming the Proxer authentication token comes as a cookie string (name=value)
|
||||
auth_token = tuple(args.token.split("="))
|
||||
|
||||
# Call the function to download the series
|
||||
download_series_series(args.id, args.name, args.episodes, args.language, auth_token, args.output)
|
||||
@@ -0,0 +1,52 @@
|
||||
import sys
|
||||
import argparse
|
||||
from lib.proxer_utils import get_mp4_url, download_mp4, get_embed_url
|
||||
|
||||
def download_video(url, filename, auth_token, output_dir):
|
||||
"""
|
||||
Downloads a video from Proxer and saves it to the specified directory.
|
||||
|
||||
:param url: The URL of the Proxer video page
|
||||
:param filename: The desired filename for the downloaded video
|
||||
:param auth_token: A tuple containing (cookie_name, cookie_value) for Proxer authentication
|
||||
:param output_dir: Directory to save the downloaded video
|
||||
"""
|
||||
try:
|
||||
print(f"Fetching embed URL for video: {url}...")
|
||||
embed_url = get_embed_url(url, auth_token)
|
||||
print(f"Embed URL fetched: {embed_url}")
|
||||
|
||||
print(f"Fetching MP4 URL for video: {url}...")
|
||||
mp4_url = get_mp4_url(embed_url)
|
||||
print(f"MP4 URL fetched: {mp4_url}")
|
||||
|
||||
# Prepare the output file path
|
||||
output_file = f"{output_dir}/{filename}.mp4"
|
||||
|
||||
# Download the video
|
||||
print(f"Downloading video {filename}...")
|
||||
download_mp4(mp4_url, output_file, label=f"Downloading {filename}")
|
||||
print(f"Video {filename} downloaded successfully!")
|
||||
|
||||
except Exception as e:
|
||||
print(f"Error downloading video: {e}")
|
||||
|
||||
def parse_args():
|
||||
"""Parse command-line arguments"""
|
||||
parser = argparse.ArgumentParser(description="Download a video from Proxer.me")
|
||||
parser.add_argument('-u', '--url', required=True, type=str, help="URL of the Proxer video page")
|
||||
parser.add_argument('-f', '--filename', required=True, type=str, help="Filename for the downloaded video (without extension)")
|
||||
parser.add_argument('-t', '--token', required=True, type=str, help="Proxer authentication token (cookie)")
|
||||
parser.add_argument('-o', '--output', required=True, type=str, help="Directory to save the downloaded video")
|
||||
|
||||
return parser.parse_args()
|
||||
|
||||
if __name__ == "__main__":
|
||||
# Parse command-line arguments
|
||||
args = parse_args()
|
||||
|
||||
# Assuming the Proxer authentication token comes as a cookie string (name=value)
|
||||
auth_token = tuple(args.token.split("="))
|
||||
|
||||
# Call the function to download the video
|
||||
download_video(args.url, args.filename, auth_token, args.output)
|
||||
@@ -0,0 +1,135 @@
|
||||
#!/usr/bin/env python3
|
||||
import os
|
||||
import time
|
||||
import subprocess
|
||||
from datetime import datetime
|
||||
from pymongo import MongoClient
|
||||
from dotenv import load_dotenv # <-- import dotenv
|
||||
|
||||
# ========================
|
||||
# LOAD .env
|
||||
# ========================
|
||||
|
||||
# .env is one directory up
|
||||
env_path = os.path.join(os.path.dirname(os.path.dirname(__file__)), ".env")
|
||||
load_dotenv(dotenv_path=env_path)
|
||||
|
||||
# ========================
|
||||
# CONFIG
|
||||
# ========================
|
||||
|
||||
MONGO_URI = os.environ.get("MONGO_URI")
|
||||
DB_NAME = os.environ.get("MONGO_DB", "downloads")
|
||||
OUTPUT_DIR = os.environ.get("OUTPUT_DIR", "/mnt/media/WIP/")
|
||||
|
||||
client = MongoClient(MONGO_URI)
|
||||
db = client[DB_NAME]
|
||||
|
||||
queue_col = db["queue"]
|
||||
done_col = db["done"]
|
||||
failed_col = db["failed"]
|
||||
|
||||
# ========================
|
||||
# RUN A JOB
|
||||
# ========================
|
||||
|
||||
def run_job(job):
|
||||
"""Runs proxer-dl-video.py with job parameters."""
|
||||
|
||||
url = job["url"]
|
||||
filename = job["filename"]
|
||||
token = job["token"]
|
||||
|
||||
# Only filename *without extension* must be passed to script.
|
||||
clean_name = filename.replace(".mp4", "")
|
||||
|
||||
script_path = os.path.join(os.path.dirname(__file__), "proxer-dl-video.py")
|
||||
|
||||
cmd = [
|
||||
"python",
|
||||
script_path,
|
||||
"-u", url,
|
||||
"-f", f'"{clean_name}"', # wrap filename in quotes
|
||||
"-t", f'"{token}"', # wrap token in quotes
|
||||
"-o", OUTPUT_DIR
|
||||
]
|
||||
|
||||
|
||||
print("Running:", " ".join(cmd))
|
||||
|
||||
try:
|
||||
proc = subprocess.run(
|
||||
cmd,
|
||||
stdout=subprocess.PIPE,
|
||||
stderr=subprocess.PIPE,
|
||||
text=True
|
||||
)
|
||||
|
||||
stdout = proc.stdout.strip()
|
||||
stderr = proc.stderr.strip()
|
||||
|
||||
# Merge for logs
|
||||
output_log = (stdout + "\n" + stderr).strip()
|
||||
|
||||
# Return code determines success/failure
|
||||
if proc.returncode == 0:
|
||||
print("SUCCESS:", clean_name)
|
||||
|
||||
done_col.insert_one({
|
||||
"filename": filename,
|
||||
"url": url,
|
||||
"finished_at": datetime.utcnow(),
|
||||
"output_log": output_log,
|
||||
"result": "success"
|
||||
})
|
||||
|
||||
# Remove from queue
|
||||
queue_col.delete_one({"_id": job["_id"]})
|
||||
else:
|
||||
print("FAILED:", clean_name)
|
||||
failed_col.insert_one({
|
||||
"filename": filename,
|
||||
"url": url,
|
||||
"failed_at": datetime.utcnow(),
|
||||
"output_log": output_log,
|
||||
"return_code": proc.returncode
|
||||
})
|
||||
|
||||
# Remove or mark as failed
|
||||
queue_col.delete_one({"_id": job["_id"]})
|
||||
|
||||
except Exception as e:
|
||||
|
||||
failed_col.insert_one({
|
||||
"filename": filename,
|
||||
"url": url,
|
||||
"failed_at": datetime.utcnow(),
|
||||
"output_log": str(e),
|
||||
"exception": True
|
||||
})
|
||||
|
||||
queue_col.delete_one({"_id": job["_id"]})
|
||||
|
||||
|
||||
# ========================
|
||||
# MAIN LOOP
|
||||
# ========================
|
||||
|
||||
def main():
|
||||
print("Worker started. Watching queue...")
|
||||
|
||||
while True:
|
||||
job = queue_col.find_one_and_update(
|
||||
{},
|
||||
{"$set": {"processing": True}},
|
||||
sort=[("created_at", 1)]
|
||||
)
|
||||
|
||||
if job:
|
||||
run_job(job)
|
||||
else:
|
||||
time.sleep(1)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Binary file not shown.
@@ -0,0 +1,37 @@
|
||||
// server.js
|
||||
require('dotenv').config();
|
||||
const express = require('express');
|
||||
const path = require('path');
|
||||
const morgan = require('morgan');
|
||||
const bodyParser = require('body-parser');
|
||||
|
||||
const indexRouter = require('./routes/index');
|
||||
|
||||
const app = express();
|
||||
const PORT = process.env.PORT || 3000;
|
||||
|
||||
// View engine
|
||||
app.set('view engine', 'ejs');
|
||||
app.set('views', path.join(__dirname, 'views'));
|
||||
|
||||
// Middleware
|
||||
app.use(express.static(path.join(__dirname, 'public')));
|
||||
app.use(bodyParser.urlencoded({ extended: true }));
|
||||
app.use(bodyParser.json());
|
||||
app.use(morgan('dev'));
|
||||
|
||||
// Routes
|
||||
app.use('/', indexRouter);
|
||||
|
||||
// Error handler
|
||||
app.use((err, req, res, next) => {
|
||||
console.error(err);
|
||||
res.status(500).render('error', {
|
||||
message: 'Internal Server Error',
|
||||
detail: err.message
|
||||
});
|
||||
});
|
||||
|
||||
app.listen(PORT, () =>
|
||||
console.log(`Proxer-Downloader running on http://localhost:${PORT}`)
|
||||
);
|
||||
@@ -0,0 +1,17 @@
|
||||
<%- include("partials/header") %>
|
||||
|
||||
<div class="alert alert-danger mt-4">
|
||||
<h4>Error</h4>
|
||||
|
||||
<p>
|
||||
<%= message %>
|
||||
</p>
|
||||
|
||||
<% if (details) { %>
|
||||
<pre class="bg-dark text-white p-3 mt-3"><%= details %></pre>
|
||||
<% } %>
|
||||
|
||||
<a href="/" class="btn btn-danger mt-3">Return to Home</a>
|
||||
</div>
|
||||
|
||||
<%- include("partials/footer") %>
|
||||
@@ -0,0 +1,99 @@
|
||||
<%- include("partials/header") %>
|
||||
|
||||
<div class="card card-dark p-4">
|
||||
<div class="d-flex justify-content-center mb-3">
|
||||
<div class="form-check form-switch">
|
||||
<input class="form-check-input" type="checkbox" id="modeToggle">
|
||||
<label class="form-check-label text-muted" for="modeToggle" id="modeLabel">Series</label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<form method="POST" action="/queue" id="jobForm">
|
||||
<input type="hidden" name="mode" id="modeInput" value="series">
|
||||
|
||||
<!-- SERIES FIELDS -->
|
||||
<div id="seriesFields">
|
||||
<div class="mb-3">
|
||||
<label class="form-label">Series ID</label>
|
||||
<input class="form-control" name="id" placeholder="12345">
|
||||
</div>
|
||||
|
||||
<!-- UPDATED: EPISODE RANGE (FROM / TO) -->
|
||||
<div class="mb-3">
|
||||
<label class="form-label">Episode Range</label>
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<input class="form-control" name="episode_from" placeholder="From (e.g. 1)">
|
||||
</div>
|
||||
<div class="col">
|
||||
<input class="form-control" name="episode_to" placeholder="To (e.g. 12)">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="mb-3">
|
||||
<label class="form-label">Language</label>
|
||||
<select class="form-select" name="language">
|
||||
<option value="engsub">engsub</option>
|
||||
<option value="engdub">engdub</option>
|
||||
<option value="gersub">gersub</option>
|
||||
<option value="gerdub">gerdub</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="mb-3">
|
||||
<label class="form-label">Name (optional)</label>
|
||||
<input class="form-control" name="name" placeholder="OnePiece_1_engsub">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- VIDEO FIELDS -->
|
||||
<div id="videoFields" style="display:none">
|
||||
<div class="mb-3">
|
||||
<label class="form-label">Video URL</label>
|
||||
<input class="form-control" name="url" placeholder="https://proxer.me/watch/...">
|
||||
</div>
|
||||
|
||||
<div class="mb-3">
|
||||
<label class="form-label">Filename (optional)</label>
|
||||
<input class="form-control" name="filename" placeholder="MyVideo.mp4">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- TOKEN -->
|
||||
<div class="mb-3">
|
||||
<label class="form-label">Token suffix</label>
|
||||
<input class="form-control" name="token" placeholder="user-token">
|
||||
<div class="form-text">Full token = TOKEN_PREFIX + this value</div>
|
||||
</div>
|
||||
|
||||
<div class="d-flex justify-content-between">
|
||||
<button class="btn btn-danger">Queue Download</button>
|
||||
<a class="btn btn-outline-light" href="/status">View Queue</a>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
const toggle = document.getElementById('modeToggle');
|
||||
const modeLabel = document.getElementById('modeLabel');
|
||||
const modeInput = document.getElementById('modeInput');
|
||||
const seriesFields = document.getElementById('seriesFields');
|
||||
const videoFields = document.getElementById('videoFields');
|
||||
|
||||
toggle.addEventListener('change', () => {
|
||||
if (toggle.checked) {
|
||||
modeLabel.innerText = 'Video';
|
||||
modeInput.value = 'video';
|
||||
seriesFields.style.display = 'none';
|
||||
videoFields.style.display = '';
|
||||
} else {
|
||||
modeLabel.innerText = 'Series';
|
||||
modeInput.value = 'series';
|
||||
seriesFields.style.display = '';
|
||||
videoFields.style.display = 'none';
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<%- include("partials/footer") %>
|
||||
@@ -0,0 +1,5 @@
|
||||
<footer class="mt-5 small">Built by DeSqBlocki</footer>
|
||||
</div>
|
||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,18 @@
|
||||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>Proxer-Downloader</title>
|
||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
|
||||
<link rel="stylesheet" href="/style.css">
|
||||
</head>
|
||||
<body>
|
||||
<div class="container py-4">
|
||||
<header class="d-flex justify-content-between align-items-center mb-4">
|
||||
<h1>Proxer-Downloader</h1>
|
||||
<nav>
|
||||
<a class="btn btn-outline-light" href="/">Home</a>
|
||||
<a class="btn btn-outline-light" href="/status">Status</a>
|
||||
</nav>
|
||||
</header>
|
||||
@@ -0,0 +1,91 @@
|
||||
<%- include("partials/header") %>
|
||||
|
||||
<div class="row">
|
||||
|
||||
<!-- ======================= -->
|
||||
<!-- QUEUED -->
|
||||
<!-- ======================= -->
|
||||
<div class="col-md-4">
|
||||
<h3>Queued</h3>
|
||||
<ul class="list-group">
|
||||
|
||||
<% queued.forEach(job => { %>
|
||||
<li class="list-group-item">
|
||||
<strong><%= job.filename %></strong><br>
|
||||
<small><%= job.url %></small><br>
|
||||
<small><%= new Date(job.created_at).toLocaleString() %></small>
|
||||
</li>
|
||||
<% }) %>
|
||||
|
||||
<% if (queued.length === 0) { %>
|
||||
<li class="list-group-item">No pending downloads</li>
|
||||
<% } %>
|
||||
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<!-- ======================= -->
|
||||
<!-- DONE -->
|
||||
<!-- ======================= -->
|
||||
<div class="col-md-4">
|
||||
<h3 class="text-success">Done</h3>
|
||||
<ul class="list-group">
|
||||
|
||||
<% finished.forEach(job => { %>
|
||||
<li class="list-group-item">
|
||||
<strong class="text-success"><%= job.filename %></strong><br>
|
||||
<small><%= new Date(job.finished_at).toLocaleString() %></small><br>
|
||||
|
||||
<% if (job.output_log) { %>
|
||||
<details class="mt-2">
|
||||
<summary class="text-light">Show Log</summary>
|
||||
<pre style="background:#222; color:#e0e0e0; padding:10px; border-radius:5px; white-space:pre-wrap;">
|
||||
<%= job.output_log %>
|
||||
</pre>
|
||||
</details>
|
||||
<% } %>
|
||||
|
||||
</li>
|
||||
<% }) %>
|
||||
|
||||
<% if (finished.length === 0) { %>
|
||||
<li class="list-group-item">No completed downloads</li>
|
||||
<% } %>
|
||||
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<!-- ======================= -->
|
||||
<!-- FAILED -->
|
||||
<!-- ======================= -->
|
||||
<div class="col-md-4">
|
||||
<h3 class="text-danger">Failed</h3>
|
||||
<ul class="list-group">
|
||||
|
||||
<% failed && failed.forEach(job => { %>
|
||||
<li class="list-group-item">
|
||||
<strong class="text-danger"><%= job.filename %></strong><br>
|
||||
<small><%= new Date(job.failed_at).toLocaleString() %></small><br>
|
||||
|
||||
<% if (job.output_log) { %>
|
||||
<details class="mt-2">
|
||||
<summary class="text-danger">Show Error Log</summary>
|
||||
<pre style="background:#330000; color:#ffb3b3; padding:10px; border-radius:5px; white-space:pre-wrap;">
|
||||
<%= job.output_log %>
|
||||
</pre>
|
||||
</details>
|
||||
<% } %>
|
||||
|
||||
</li>
|
||||
<% }) %>
|
||||
|
||||
<% if (!failed || failed.length === 0) { %>
|
||||
<li class="list-group-item">No failed jobs</li>
|
||||
<% } %>
|
||||
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<%- include("partials/footer") %>
|
||||
Reference in new issue
Block a user