All files / Rindu/utils getMusicFanArt.ts

14.28% Statements 1/7
0% Branches 0/1
0% Functions 0/1
16.66% Lines 1/6

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38                                                    2x                      
interface FanArtData {
  name: string;
  mbid_id: string;
  artistbackground: {
    id: string;
    url: string;
    likes: string;
  }[];
  artistthumb: {
    id: string;
    url: string;
    likes: string;
  }[];
  albums: Record<string, unknown>[];
  musiclogo: {
    id: string;
    url: string;
    likes: string;
  }[];
  musicbanner: {
    id: string;
    url: string;
    likes: string;
  }[];
}
 
export async function getMusicFanArt(mbid: string): Promise<FanArtData | null> {
  const api = process.env.FAN_ART_TV_API_KEY as string;
  const fanArtRes = await fetch(
    `http://webservice.fanart.tv/v3/music/${mbid}?api_key=${api}`
  );
 
  Iif (!fanArtRes.ok) return null;
 
  const fanArtData = (await fanArtRes.json()) as FanArtData;
  return fanArtData;
}