mirror of
https://github.com/MasterAcnolo/Freedom-Loader.git
synced 2026-09-28 12:31:14 +02:00
Compare commits
4 Commits
fbce5e5b7b
...
1.6.2
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
730069a3c6 | ||
|
|
7a0cbd7456 | ||
|
|
5d676b45e7 | ||
|
|
a7f3d84a7d |
@@ -105,14 +105,6 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="setting-item">
|
|
||||||
<input type="checkbox" data-key="autoCheckInfo" id="autoCheckInfo">
|
|
||||||
<div class="setting-info">
|
|
||||||
<span class="setting-title">Auto Fetch Info</span>
|
|
||||||
<small>Automatically fetch information for new downloads.</small>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="setting-item">
|
<div class="setting-item">
|
||||||
<input data-key="keepPlaylistOrder" id="keepPlaylistOrder" type="checkbox">
|
<input data-key="keepPlaylistOrder" id="keepPlaylistOrder" type="checkbox">
|
||||||
<div class="setting-info">
|
<div class="setting-info">
|
||||||
@@ -143,6 +135,14 @@
|
|||||||
</div>
|
</div>
|
||||||
</div> -->
|
</div> -->
|
||||||
|
|
||||||
|
<div class="setting-item">
|
||||||
|
<input data-key="autoCheckInfo" id="autoCheckInfo" type="checkbox">
|
||||||
|
<div class="setting-info">
|
||||||
|
<span class="setting-title">Auto Fetch Info</span>
|
||||||
|
<small>Automatically fetch information for new downloads.</small>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="setting-item">
|
<div class="setting-item">
|
||||||
<input type="checkbox" data-key="addMetadata" id="addMetadata">
|
<input type="checkbox" data-key="addMetadata" id="addMetadata">
|
||||||
<div class="setting-info">
|
<div class="setting-info">
|
||||||
|
|||||||
@@ -30,15 +30,15 @@ function formatSize(bytes) {
|
|||||||
*/
|
*/
|
||||||
async function fetchVideoInfo(url) {
|
async function fetchVideoInfo(url) {
|
||||||
try {
|
try {
|
||||||
const res = await fetch("/info", {
|
const res = await fetch(`/info?url=${encodeURIComponent(url)}`, {
|
||||||
method: "POST",
|
method: "GET",
|
||||||
headers: { "Content-Type": "application/x-www-form-urlencoded" },
|
headers: {"Accept": "application/json"}
|
||||||
body: new URLSearchParams({ url }),
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const data = await res.json();
|
||||||
|
|
||||||
if (!res.ok) return {error: `An Error occured when fetching info`};
|
if (!res.ok) return {error: `An Error occured when fetching info`};
|
||||||
|
|
||||||
const data = await res.json();
|
|
||||||
if (!data) return { error: "Data is Missing" };
|
if (!data) return { error: "Data is Missing" };
|
||||||
|
|
||||||
return data;
|
return data;
|
||||||
|
|||||||
@@ -18,7 +18,9 @@ const { isValidUrl } = require("../helpers/validation.helpers");
|
|||||||
*/
|
*/
|
||||||
async function infoController(req, res) {
|
async function infoController(req, res) {
|
||||||
|
|
||||||
const url = req.body.url || req.query.url; // Supports POST and GET requests
|
// Previously, i support both POST and GET element, but it's kinda weird. So now it only support GET.
|
||||||
|
const url = req.query.url;
|
||||||
|
const encodedUrl = encodeURIComponent(url)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Basic validation:
|
* Basic validation:
|
||||||
@@ -30,9 +32,10 @@ async function infoController(req, res) {
|
|||||||
return res.status(400).send("Invalid URL Or Missing");
|
return res.status(400).send("Invalid URL Or Missing");
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.info(`Info request received. URL: ${url}`);
|
logger.info(`Info request received. RAW URL: ${url}`);
|
||||||
|
logger.info(`Info request received. ENCODED: ${encodedUrl}`);
|
||||||
|
|
||||||
// Lightweight heuristic to detect playlist URLs
|
// Lightweight heuristic to detect playlist URLs. It works for Youtube.
|
||||||
const isPlaylistUrl = url.includes("&list") || url.includes("?list");
|
const isPlaylistUrl = url.includes("&list") || url.includes("?list");
|
||||||
|
|
||||||
logger.info(
|
logger.info(
|
||||||
@@ -86,6 +89,16 @@ async function infoController(req, res) {
|
|||||||
*/
|
*/
|
||||||
if (data._type === "playlist") {
|
if (data._type === "playlist") {
|
||||||
|
|
||||||
|
// If the playlist got only one video, show it as a video.
|
||||||
|
if (data.entries && data.entries.length === 1) {
|
||||||
|
|
||||||
|
const singleVideo = parseVideo(data.entries[0]);
|
||||||
|
|
||||||
|
logger.info(`Playlist with 1 item converted to video: ${singleVideo.title}`);
|
||||||
|
|
||||||
|
return res.json(singleVideo);
|
||||||
|
}
|
||||||
|
|
||||||
const playlist = parsePlaylist(data);
|
const playlist = parsePlaylist(data);
|
||||||
|
|
||||||
logger.info(
|
logger.info(
|
||||||
|
|||||||
@@ -55,6 +55,7 @@ const logger = createLogger({
|
|||||||
*/
|
*/
|
||||||
function logSessionStart(logDir, downloadPath) {
|
function logSessionStart(logDir, downloadPath) {
|
||||||
logger.info(`--- Starting session: ${new Date().toISOString()} ---`);
|
logger.info(`--- Starting session: ${new Date().toISOString()} ---`);
|
||||||
|
logger.info("============================================================")
|
||||||
logger.info(`Application Version: ${config.version}`)
|
logger.info(`Application Version: ${config.version}`)
|
||||||
logSystemInfo(logger, logDir, downloadPath)
|
logSystemInfo(logger, logDir, downloadPath)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,6 @@ const express = require("express");
|
|||||||
const router = express.Router();
|
const router = express.Router();
|
||||||
const { infoController } = require("../controller/info.controller");
|
const { infoController } = require("../controller/info.controller");
|
||||||
|
|
||||||
router.post("/", infoController);
|
router.get("/", infoController);
|
||||||
|
|
||||||
module.exports = router;
|
module.exports = router;
|
||||||
@@ -14,6 +14,8 @@ app.use(express.static(path.join(__dirname, "../public")));
|
|||||||
// Routes
|
// Routes
|
||||||
app.use("/download", require("./routes/download.route"));
|
app.use("/download", require("./routes/download.route"));
|
||||||
app.use("/info", require("./routes/info.route"));
|
app.use("/info", require("./routes/info.route"));
|
||||||
|
|
||||||
|
// Interface
|
||||||
app.get("/", rateLimit, (req, res) => {
|
app.get("/", rateLimit, (req, res) => {
|
||||||
res.sendFile(path.join(__dirname, "../public/index.html"));
|
res.sendFile(path.join(__dirname, "../public/index.html"));
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user