Skip to content

Commit

Permalink
fix: remove lodash
Browse files Browse the repository at this point in the history
  • Loading branch information
JimmyLv committed Mar 7, 2023
1 parent 23a4fe7 commit 049aa45
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 65 deletions.
4 changes: 1 addition & 3 deletions lib/bilibili.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import { find } from "lodash";
import { VideoService } from "~/lib/types";
import {
fetchYoutubeSubtitle,
SUBTITLE_DOWNLOADER_URL,
} from "~/lib/youtube/fetchYoutubeSubtitle";
import { sample } from "~/utils/fp";
import { find, sample } from "~/utils/fp";

const fetchBilibiliSubtitles = async (bvId: string) => {
const requestUrl = `https://api.bilibili.com/x/web-interface/view?bvid=${bvId}`;
Expand Down Expand Up @@ -51,7 +50,6 @@ export async function fetchSubtitle(
const transcripts = subtitles
.split("\r\n\r\n")
?.map((text: string, index: number) => ({ text, index }));
console.log("========subtitleUrl response========", title, transcripts);
return { title, subtitles: transcripts };
}

Expand Down
46 changes: 0 additions & 46 deletions lib/youtube/fetchYoutubeSubtitleOfficially.ts

This file was deleted.

18 changes: 4 additions & 14 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
"@supabase/auth-ui-shared": "^0.1.2",
"@supabase/supabase-js": "^2.10.0",
"@teovilla/shadcn-ui-react": "^0.5.0",
"@types/lodash": "^4.14.191",
"@upstash/ratelimit": "^0.3.8",
"@upstash/redis": "^1.20.1",
"@vercel/analytics": "^0.1.8",
Expand All @@ -36,7 +35,6 @@
"framer-motion": "^9.0.1",
"get-video-id": "^3.6.5",
"lemonsqueezy.ts": "^0.1.6",
"lodash": "^4.17.21",
"lucide-react": "^0.122.0",
"next": "latest",
"next-themes": "^0.2.1",
Expand Down
5 changes: 5 additions & 0 deletions utils/fp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,8 @@ export const sample = (arr: any[] = []) => {
const len = arr === null ? 0 : arr.length;
return len ? arr[Math.floor(Math.random() * len)] : undefined;
};

export function find(subtitleList: any[], args: { [key: string]: any }) {
const key = Object.keys(args)[0];
return subtitleList.find((item) => item[key] === args[key]);
}

1 comment on commit 049aa45

@vercel
Copy link

@vercel vercel bot commented on 049aa45 Mar 7, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.