Beta Now Live!

Ship with confidence.

The AI inspector to ship faster.

Inspector General is the AI that helps any developer go from 1x developer to 10x developer.

Files changed (1) hide show
  1. src/server/api/routers/genius.ts +14 -8
src/server/api/routers/genius.ts CHANGED
@@ -3,9 +3,7 @@ import {
3
3
  createTRPCRouter,
4
4
  publicProcedure,
5
5
  } from "~/server/api/trpc";
6
- import { type GeniusSongReference, type GeniusHit } from "~/schema";
6
+ import { type GeniusSongReference, type GeniusHit } from "~/schema";
7
- import {parse} from "node-html-parser";
8
-
9
7
  const geniusBaseUrl = "https://api.genius.com";
10
8
  const ovhApiUrl = "https://api.lyrics.ovh";
11
9
 
@@ -90,11 +88,19 @@ export const geniusRouter = createTRPCRouter({
90
88
  let lyrics = "";
91
89
 
92
90
  if(lyrics === "" && data?.response?.song?.primary_artist?.name && data?.response?.song?.title) {
91
+ // console.log("artist: ", data?.response?.song?.primary_artist?.name);
92
+ // console.log("title: ", data?.response?.song?.title);
93
+ try{
93
- const url = `${ovhApiUrl}/v1/${data?.response?.song.primary_artist.name}/${data?.response?.song.title}`;
94
+ const url = `${ovhApiUrl}/v1/${data?.response?.song.primary_artist.name}/${data?.response?.song.title}`;
94
- const response = await fetch(url);
95
+ const response = await fetch(url);
95
- const res = await response.json() as { lyrics: string };
96
+ const res = await response.json() as { lyrics: string };
97
+ // console.log(res);
96
- lyrics = res.lyrics ?? "Lyrics not found";
98
+ lyrics = res.lyrics ?? "Lyrics not found";
97
- lyrics = (res.lyrics || "").replaceAll("\n\n", "\n").replaceAll("\\", "").replaceAll("\"","");
99
+ lyrics = (res.lyrics || "").replaceAll("\n\n", "\n").replaceAll("\\", "").replaceAll("\"","");
100
+ } catch (err) {
101
+ console.log(err);
102
+ lyrics = "Lyrics not found";
103
+ }
98
104
  } else {
99
105
  lyrics = "Lyrics not found";
100
106
  }
Automate your workflow

Pull Requests Auto-Reviewed

Get instant PR code reviews on Github to help develoeprs ship fast!

Pull Requests Auto-Reviewed
Zone in on feedback

Chat with Inspector General

Ask inspector general for more details feedback on your code, or narrow in to file specific feedback.

Chat with Inspector General
Help Developers

Line by line PR feedback

We don't just tell a long list of issues, we provide feedback line by line to help developers find the issues and fix them quickly.

Line by line PR feedback

Pricing

Use it for free for yourself, upgrade when your team needs more repos.

Free$0/moBest for 1-5 users
One repository
30 day data retention
Pro$10/moBest for 5-50 users
Multiple repository
Email support
365 day data retention
Priority support
EnterpriseContact usBest for 50+ users
Multiple repository
Email support
Data retention
Priority support