Files
lucida/src/streamers/deezer/main.ts
2025-07-20 18:28:43 -04:00

20 lines
693 B
TypeScript

import { fetch } from 'undici'
import { BarcodeAlbumType, LookupType } from '../../types.js'
import { AcceptableAlbumTypes, RawError, RawUPCAlbum, UPC } from './constants.js'
import { parseAlbum, parseError } from './parse.js'
export async function getTrack(tag: string, type: BarcodeAlbumType) {
if (!AcceptableAlbumTypes.includes(type)) throw new Error('Cannot use this type with Deezer.')
switch (type) {
case 'upc': {
const data = (await (await fetch(UPC.replace('{upc}', tag))).json()) as any
if (data?.id) return parseAlbum(data as RawUPCAlbum)
else throw new Error(parseError(data as RawError))
}
}
}
export async function getAlbum(tag: string, type: LookupType) {}