mirror of
https://git.stupid.fish/teidesu/scripts.git
synced 2025-07-27 18:22:10 +10:00
39 lines
891 B
TypeScript
39 lines
891 B
TypeScript
import { filesize } from 'filesize'
|
|
import { z } from 'zod'
|
|
|
|
import { ffetch } from '../../utils/fetch.ts'
|
|
import { getEnv } from '../../utils/misc.ts'
|
|
|
|
const res = await ffetch('/api/v0/transfers/uploads', {
|
|
baseUrl: getEnv('SLSKD_ENDPOINT'),
|
|
headers: {
|
|
cookie: getEnv('SLSKD_COOKIE'),
|
|
},
|
|
}).parsedJson(z.array(
|
|
z.object({
|
|
username: z.string(),
|
|
directories: z.array(z.object({
|
|
directory: z.string(),
|
|
fileCount: z.number(),
|
|
files: z.array(z.object({
|
|
id: z.string(),
|
|
filename: z.string(),
|
|
state: z.string(),
|
|
bytesTransferred: z.number(),
|
|
})),
|
|
})),
|
|
}),
|
|
))
|
|
|
|
let total = 0
|
|
|
|
for (const user of res) {
|
|
for (const dir of user.directories) {
|
|
for (const file of dir.files) {
|
|
if (file.state !== 'Completed, Succeeded') continue
|
|
total += file.bytesTransferred
|
|
}
|
|
}
|
|
}
|
|
|
|
console.log(filesize(total))
|