mirror of
https://git.stupid.fish/teidesu/scripts.git
synced 2025-07-28 02:32:11 +10:00
chore: update public repo
This commit is contained in:
parent
e0109980c0
commit
e7c9507247
25 changed files with 5364 additions and 0 deletions
39
scripts/infra/slskd-total-upload.ts
Normal file
39
scripts/infra/slskd-total-upload.ts
Normal file
|
@ -0,0 +1,39 @@
|
|||
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))
|
Loading…
Add table
Add a link
Reference in a new issue