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
32
utils/navidrome.ts
Normal file
32
utils/navidrome.ts
Normal file
|
@ -0,0 +1,32 @@
|
|||
import { z } from 'zod'
|
||||
import { ffetch as ffetchBase } from './fetch.ts'
|
||||
import { getEnv } from './misc.ts'
|
||||
|
||||
export const navidromeFfetch = ffetchBase.extend({
|
||||
baseUrl: getEnv('NAVIDROME_ENDPOINT'),
|
||||
headers: {
|
||||
'x-nd-authorization': `Bearer ${getEnv('NAVIDROME_TOKEN')}`,
|
||||
},
|
||||
})
|
||||
|
||||
export const NavidromeSong = z.object({
|
||||
id: z.string(),
|
||||
title: z.string(),
|
||||
album: z.string(),
|
||||
albumArtist: z.string(),
|
||||
artist: z.string(),
|
||||
path: z.string(),
|
||||
duration: z.number(),
|
||||
})
|
||||
export type NavidromeSong = z.infer<typeof NavidromeSong>
|
||||
|
||||
export function fetchSongs(offset: number, pageSize: number) {
|
||||
return navidromeFfetch('/api/song', {
|
||||
query: {
|
||||
_start: offset,
|
||||
_end: offset + pageSize,
|
||||
_order: 'ASC',
|
||||
_sort: 'title',
|
||||
},
|
||||
}).parsedJson(z.array(NavidromeSong))
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue