fixed a bug & replicated all changes to docker version
This commit is contained in:
@@ -182,14 +182,25 @@ export async function streamUnit(request: FastifyRequest, reply: FastifyReply) {
|
||||
const range = request.headers.range;
|
||||
|
||||
if (!range) {
|
||||
reply.header('Content-Length', stat.size);
|
||||
reply.header('Content-Type', 'video/mp4'); // o dinámico
|
||||
reply
|
||||
.header('Content-Length', stat.size)
|
||||
.header('Content-Type', 'video/mp4');
|
||||
return fs.createReadStream(file.file_path);
|
||||
}
|
||||
|
||||
const [startStr, endStr] = range.replace(/bytes=/, '').split('-');
|
||||
const start = parseInt(startStr, 10);
|
||||
const end = endStr ? parseInt(endStr, 10) : stat.size - 1;
|
||||
const parts = range.replace(/bytes=/, '').split('-');
|
||||
const start = Number(parts[0]);
|
||||
let end = parts[1] ? Number(parts[1]) : stat.size - 1;
|
||||
|
||||
if (
|
||||
Number.isNaN(start) ||
|
||||
Number.isNaN(end) ||
|
||||
start < 0 ||
|
||||
end < start ||
|
||||
end >= stat.size
|
||||
) {
|
||||
end = stat.size - 1;
|
||||
}
|
||||
|
||||
reply
|
||||
.status(206)
|
||||
@@ -199,6 +210,7 @@ export async function streamUnit(request: FastifyRequest, reply: FastifyReply) {
|
||||
.header('Content-Type', 'video/mp4');
|
||||
|
||||
return fs.createReadStream(file.file_path, { start, end });
|
||||
|
||||
}
|
||||
|
||||
type MatchBody = {
|
||||
@@ -225,8 +237,8 @@ export async function matchEntry(
|
||||
|
||||
await run(
|
||||
`UPDATE local_entries
|
||||
SET matched_source = ?, matched_id = ?
|
||||
WHERE id = ?`,
|
||||
SET matched_source = ?, matched_id = ?
|
||||
WHERE id = ?`,
|
||||
[source, matched_id, id],
|
||||
'local_library'
|
||||
);
|
||||
|
||||
@@ -239,8 +239,9 @@ async function loadExtensions() {
|
||||
const select = document.getElementById('extension-select');
|
||||
let extensions = data.extensions || [];
|
||||
|
||||
// Añadimos local manualmente
|
||||
if (!extensions.includes('local')) extensions.push('local');
|
||||
if (extName === 'local' && !extensions.includes('local')) {
|
||||
extensions.push('local');
|
||||
}
|
||||
|
||||
select.innerHTML = '';
|
||||
extensions.forEach(ext => {
|
||||
@@ -251,8 +252,8 @@ async function loadExtensions() {
|
||||
|
||||
if (extName && extensions.includes(extName)) {
|
||||
select.value = extName;
|
||||
} else {
|
||||
select.value = 'local'; // Default a local
|
||||
} else if (extensions.length > 0) {
|
||||
select.value = extensions[0];
|
||||
}
|
||||
|
||||
currentExtension = select.value;
|
||||
|
||||
Reference in New Issue
Block a user