Skip to content

Commit f0fa385

Browse files
committed
refractor: replace crypto uuuid with md5
1 parent 3ae31ab commit f0fa385

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

src/commands/fbdl.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@ const fileExists = async (filePath: string) => {
2424
}
2525
};
2626

27+
function md5FromUrl(url: string) {
28+
return crypto.createHash("md5").update(url).digest("hex");
29+
}
30+
2731
export default async function (msg: Message) {
2832
const query = msg.body.replace(/^fbdl\b\s*/i, "").trim();
2933
if (query.length === 0) {
@@ -51,7 +55,7 @@ export default async function (msg: Message) {
5155

5256
const tempDir = "./.temp";
5357
fs.mkdirSync(tempDir, { recursive: true });
54-
const tempPath = `${tempDir}/${crypto.randomUUID()}.mp4`;
58+
const tempPath = `${tempDir}/${md5FromUrl(result.url)}.mp4`;
5559

5660
if (await fileExists(tempPath)) {
5761
const media = MessageMedia.fromFilePath(tempPath);

0 commit comments

Comments
 (0)