Show VOE storage usage from the existing web account check
CI / verify (push) Canceled after 0s

This commit is contained in:
Sucukdeluxe committed 2026-09-29 10:27:49 +02:00
1 parent 2ba21993c8
commit f2c96bd9c5
7 files changed
+53 -6

No files matched your search

+23
View File
@@ -0,0 +1,23 @@
function parseStorageAmount(html) {
const text = String(html).replace(/<[^>]*>/g, '').replace(/&nbsp;|&#160;|&#xA0;/gi, ' ').trim();
const match = text.match(/^([\d.,]+)\s*(B|[KMGTPE]i?B)$/i);
if (!match) return null;
const value = Number(match[1].replace(',', '.'));
if (!Number.isFinite(value) || value < 0) return null;
return { value, unit: match[2].toUpperCase() };
}
function parseVoeAccountStorage(html) {
const sidebar = String(html || '').match(/<nav\b[^>]*\bid\s*=\s*["']sidebarMenu["'][^>]*>([\s\S]*?)<\/nav\s*>/i)?.[1];
if (!sidebar) return null;
for (const match of sidebar.matchAll(/<small\b[^>]*>([\s\S]*?)<\/small\s*>/gi)) {
const spans = [...match[1].matchAll(/<span\b([^>]*)>([\s\S]*?)<\/span\s*>/gi)];
if (spans.length !== 2 || !/\bfloat-end\b/.test(spans[1][1])) continue;
const used = parseStorageAmount(spans[0][2]);
const total = parseStorageAmount(spans[1][2]);
if (used && total && total.value > 0) return { used, total };
}
return null;
}
module.exports = { parseVoeAccountStorage };
+2 -1
View File
@@ -2,6 +2,7 @@ const fs = require('fs');
const path = require('path');
const crypto = require('crypto');
const { request } = require('undici');
const { parseVoeAccountStorage } = require('./voe-account-storage');
const BASE_URL = 'https://voe.sx';
const USER_AGENT = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36';
@@ -152,7 +153,7 @@ class VoeUploader {
throw new Error('VOE Upload: CSRF-Token nicht gefunden. Bist du eingeloggt?');
}
return { csrfToken };
return { csrfToken, storage: parseVoeAccountStorage(html) };
}
/**