Skip to content

Commit 5c86de8

Browse files
committed
feat: file token fallbacks
1 parent 0bc87f1 commit 5c86de8

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

src/file.ts

+12-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
/* eslint-disable @typescript-eslint/no-unsafe-return */
33

44
import { hookNative } from './anti-detection'
5-
import { console } from './utils'
5+
import { console, useTimeout } from './utils'
66

77
type FileType = 'img' | 'mp3' | 'midi'
88

@@ -97,7 +97,17 @@ const getApiAuth = async (type: FileType, index: number): Promise<string> => {
9797
}
9898
}
9999

100-
return magic
100+
try {
101+
return await useTimeout(magic, 5 * 1000 /* 5s */)
102+
} catch {
103+
console.error(type, 'token timeout')
104+
switch (type) {
105+
// try hard-coded tokens
106+
case 'img': return '8c022bdef45341074ce876ae57a48f64b86cdcf5'
107+
case 'midi': return '38fb9efaae51b0c83b5bb5791a698b48292129e7'
108+
case 'mp3': return '63794e5461e4cfa046edfbdddfccc1ac16daffd2'
109+
}
110+
}
101111
}
102112

103113
export const getFileUrl = async (id: number, type: FileType, index = 0): Promise<string> => {

0 commit comments

Comments
 (0)