Hide Matroska attachments from Byse so it accepts the video
CI / verify (push) Canceled after 0s

Byse rejects MKV files that carry an attachment (for example an embedded
.nfo text file) with "Not video file format". Verified with clips cut from
a rejected episode: the full clip is rejected, the same clip without the
attachment track is accepted.

For Byse uploads the Attachments element header is now rewritten into EBML
Void elements of the same length while streaming. File size, offsets and
all video, audio and subtitle tracks stay unchanged, the source file on disk
is not modified, and other hosters receive the original bytes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
SucukdeluxeandClaude Opus 5.5 committed 2026-10-21 22:38:29 +02:00
1 parent 1b588ea167
commit 09374476e0
4 files changed
+168 -3

No files matched your search

+8 -3
View File
@@ -1,4 +1,5 @@
const { statUploadFile, readUploadFile } = require('./upload-file-io');
const { findAttachmentVoidPatches, applyPatches } = require('./matroska-attachments');
const path = require('path');
const crypto = require('crypto');
const { request } = require('undici');
@@ -284,7 +285,7 @@ async function buildMultipart(filePath, formFields) {
return { boundary, preambleBuf, epilogueBuf, totalSize, fileSize };
}
async function createUploadBody(filePath, formFields, onProgress, throttle, signal) {
async function createUploadBody(filePath, formFields, onProgress, throttle, signal, patches = []) {
const { boundary, preambleBuf, epilogueBuf, totalSize, fileSize } = await buildMultipart(filePath, formFields);
let bytesRead = 0;
@@ -294,8 +295,9 @@ async function createUploadBody(filePath, formFields, onProgress, throttle, sign
for await (const chunk of readUploadFile(filePath, signal)) {
if (signal && signal.aborted) throw new Error('Aborted');
if (throttle) await throttle.consume(chunk.length, signal);
const chunkOffset = bytesRead;
bytesRead += chunk.length;
yield chunk;
yield patches.length ? applyPatches(chunk, chunkOffset, patches) : chunk;
if (onProgress) onProgress(bytesRead, fileSize);
}
yield epilogueBuf;
@@ -556,7 +558,9 @@ async function uploadFile(hosterName, filePath, apiKey, onProgress, signal, thro
const targetUrl = config.buildUploadUrl(uploadUrl, apiKey);
const formFields = config.formFields(apiKey);
const { iterable, boundary, totalSize } = await createUploadBody(filePath, formFields, onProgress, throttle, signal);
const patches = hosterName === 'byse.sx' ? await findAttachmentVoidPatches(filePath).catch(() => []) : [];
if (patches.length && opts && typeof opts.onAttachmentsHidden === 'function') opts.onAttachmentsHidden(patches.length);
const { iterable, boundary, totalSize } = await createUploadBody(filePath, formFields, onProgress, throttle, signal, patches);
const { body, statusCode, headers } = await request(targetUrl, {
method: 'POST',
@@ -717,6 +721,7 @@ module.exports = {
prefetchBaseline,
HOSTER_CONFIGS,
__test: {
createUploadBody,
extractUploadServerUrl,
parseVoeResult,
parseDoodstreamResult,