sfiledl 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/index.cjs +820 -0
- package/build/index.cjs.map +1 -0
- package/build/index.d.ts +145 -0
- package/build/index.mjs +812 -0
- package/build/index.mjs.map +1 -0
- package/license +21 -0
- package/package.json +91 -0
- package/readme +172 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":["../src/index.ts"],"sourcesContent":["#!/usr/bin/env node\nimport {\n\tchromium,\n\ttype Browser,\n\ttype BrowserContext,\n\ttype Page,\n\ttype Download,\n\ttype Response,\n\ttype LaunchOptions,\n\ttype BrowserContextOptions,\n} from 'playwright'\nimport { promises as fs } from 'fs'\nimport { join, basename } from 'path'\nimport { tmpdir } from 'os'\nimport { exit } from 'process'\ntype Result<T, E extends Error = Error> =\n\t| { readonly success: true; readonly value: T }\n\t| { readonly success: false; readonly error: E }\nconst isOk = <T, E extends Error>(\n\tresult: Result<T, E>,\n): result is Result<T, E> & {\n\treadonly success: true\n\treadonly value: T\n} => result.success\nconst isErr = <T, E extends Error>(\n\tresult: Result<T, E>,\n): result is Result<T, E> & {\n\treadonly success: false\n\treadonly error: E\n} => !result.success\nconst safeStringify = (value: unknown, space?: number): string => {\n\ttry {\n\t\treturn JSON.stringify(value, null, space)\n\t} catch {\n\t\treturn '[Circular or unserializable]'\n\t}\n}\nconst sanitizeFilename = (name: string, replacement = '_'): string => {\n\tconst sanitized = name\n\t\t.replace(/[<>:\"/\\\\|?*\\x00-\\x1F]/g, replacement)\n\t\t.replace(new RegExp(`${replacement}+`, 'g'), replacement)\n\t\t.trim()\n\t\t.slice(0, 255)\n\treturn sanitized || 'file.bin'\n}\nconst sleep = (ms: number): Promise<void> => new Promise((resolve) => setTimeout(resolve, ms))\nabstract class AppError extends Error {\n\treadonly timestamp: string\n\treadonly context: Record<string, unknown> | undefined\n\tconstructor(\n\t\tmessage: string,\n\t\tpublic readonly code: string,\n\t\tpublic readonly retryable: boolean = true,\n\t\tcontext?: Record<string, unknown>,\n\t) {\n\t\tsuper(message)\n\t\tthis.name = this.constructor.name\n\t\tthis.timestamp = new Date().toISOString()\n\t\tthis.context = context !== undefined ? Object.freeze({ ...context }) : undefined\n\t\tError.captureStackTrace?.(this, this.constructor)\n\t}\n\ttoJSON(): Record<string, unknown> {\n\t\treturn {\n\t\t\tname: this.name,\n\t\t\tmessage: this.message,\n\t\t\tcode: this.code,\n\t\t\tretryable: this.retryable,\n\t\t\ttimestamp: this.timestamp,\n\t\t\tcontext: this.context,\n\t\t\tstack: process.env['NODE_ENV'] === 'development' ? this.stack : undefined,\n\t\t}\n\t}\n}\nclass ValidationError extends AppError {\n\tconstructor(message: string, context?: Record<string, unknown>) {\n\t\tsuper(message, 'VALIDATION_ERROR', false, context)\n\t}\n}\nclass NetworkError extends AppError {\n\tconstructor(message: string, context?: Record<string, unknown>) {\n\t\tsuper(message, 'NETWORK_ERROR', true, context)\n\t}\n}\nclass FileError extends AppError {\n\tconstructor(message: string, context?: Record<string, unknown>) {\n\t\tsuper(message, 'FILE_ERROR', false, context)\n\t}\n}\nclass BrowserError extends AppError {\n\tconstructor(message: string, context?: Record<string, unknown>) {\n\t\tsuper(message, 'BROWSER_ERROR', true, context)\n\t}\n}\ntype LogLevel = 'DEBUG' | 'INFO' | 'WARN' | 'ERROR'\ninterface LogEntry {\n\treadonly timestamp: string\n\treadonly level: LogLevel\n\treadonly message: string\n\treadonly context?: Readonly<Record<string, unknown>>\n}\nclass Logger {\n\tprivate static readonly LEVELS: Readonly<Record<LogLevel, number>> = Object.freeze({\n\t\tDEBUG: 0,\n\t\tINFO: 1,\n\t\tWARN: 2,\n\t\tERROR: 3,\n\t})\n\tprivate minLevel: LogLevel\n\tprivate entries: LogEntry[] = []\n\tprivate maxEntries = 1000\n\tprivate logFile?: string\n\tconstructor(minLevel: LogLevel = 'INFO') {\n\t\tthis.minLevel = minLevel\n\t}\n\tsetLogLevel(level: LogLevel): void {\n\t\tthis.minLevel = level\n\t}\n\tuseLogFile(path: string): void {\n\t\tthis.logFile = path\n\t}\n\tprivate shouldLog(level: LogLevel): boolean {\n\t\treturn Logger.LEVELS[level] >= Logger.LEVELS[this.minLevel]\n\t}\n\tprivate format(entry: LogEntry): string {\n\t\tconst ctx = entry.context !== undefined ? ` ${safeStringify(entry.context)}` : ''\n\t\treturn `[${entry.timestamp}] ${entry.level}: ${entry.message}${ctx}`\n\t}\n\tprivate record(entry: LogEntry): void {\n\t\tthis.entries.push(entry)\n\t\tif (this.entries.length > this.maxEntries) {\n\t\t\tthis.entries.shift()\n\t\t}\n\t}\n\tprivate output(entry: LogEntry): void {\n\t\tconst formatted = this.format(entry)\n\t\tconst outputFn = entry.level === 'ERROR' ? console.error : console.log\n\t\toutputFn(formatted)\n\t\tif (this.logFile !== undefined) {\n\t\t\tvoid fs.appendFile(this.logFile, `${formatted}\\n`).catch(() => {})\n\t\t}\n\t}\n\tlog(level: LogLevel, message: string, context?: Record<string, unknown>): void {\n\t\tif (!this.shouldLog(level)) return\n\t\tconst entry: LogEntry = {\n\t\t\ttimestamp: new Date().toISOString(),\n\t\t\tlevel,\n\t\t\tmessage,\n\t\t\t...(context !== undefined\n\t\t\t\t? { context: Object.freeze({ ...context }) as Readonly<Record<string, unknown>> }\n\t\t\t\t: {}),\n\t\t}\n\t\tthis.record(entry)\n\t\tthis.output(entry)\n\t}\n\tdebug(message: string, context?: Record<string, unknown>): void {\n\t\tthis.log('DEBUG', message, context)\n\t}\n\tinfo(message: string, context?: Record<string, unknown>): void {\n\t\tthis.log('INFO', message, context)\n\t}\n\twarn(message: string, context?: Record<string, unknown>): void {\n\t\tthis.log('WARN', message, context)\n\t}\n\terror(message: string, context?: Record<string, unknown>): void {\n\t\tthis.log('ERROR', message, context)\n\t}\n\tgetEntries(level?: LogLevel): readonly LogEntry[] {\n\t\tif (level === undefined) return [...this.entries]\n\t\treturn this.entries.filter((e) => e.level === level)\n\t}\n}\ninterface CliFlags {\n\treadonly help: boolean\n\treadonly debug: boolean\n\treadonly headless: boolean\n\treadonly proxy?: string\n\treadonly logFile?: string\n\treadonly json: boolean\n\treadonly batch?: string\n\treadonly concurrency: number\n\treadonly retry: number\n\treadonly timeout: number\n}\ninterface CliArgs {\n\treadonly url?: string\n\treadonly saveDir?: string\n\treadonly flags: CliFlags\n\treadonly errors: readonly string[]\n}\nclass CliFlagsBuilder implements CliFlags {\n\thelp = false\n\tdebug = false\n\theadless = true\n\tproxy?: string\n\tlogFile?: string\n\tjson = false\n\tbatch?: string\n\tconcurrency = 1\n\tretry = 3\n\ttimeout = 60000\n\tbuild(): CliFlags {\n\t\tconst flags: CliFlags = {\n\t\t\thelp: this.help,\n\t\t\tdebug: this.debug,\n\t\t\theadless: this.headless,\n\t\t\tjson: this.json,\n\t\t\tconcurrency: this.concurrency,\n\t\t\tretry: this.retry,\n\t\t\ttimeout: this.timeout,\n\t\t\t...(this.proxy !== undefined && { proxy: this.proxy }),\n\t\t\t...(this.logFile !== undefined && { logFile: this.logFile }),\n\t\t\t...(this.batch !== undefined && { batch: this.batch }),\n\t\t}\n\t\treturn Object.freeze(flags)\n\t}\n}\nclass CliParser {\n\tstatic parse(argv: readonly string[]): CliArgs {\n\t\tconst args = argv.slice(2)\n\t\tconst flags = new CliFlagsBuilder()\n\t\tconst positional: string[] = []\n\t\tconst errors: string[] = []\n\t\tfor (let i = 0; i < args.length; i++) {\n\t\t\tconst arg = args[i]\n\t\t\tif (arg === undefined || arg === null) continue\n\t\t\tif (arg === '--') {\n\t\t\t\tpositional.push(\n\t\t\t\t\t...args.slice(i + 1).filter((a): a is string => a !== undefined && a !== null),\n\t\t\t\t)\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tif (arg.startsWith('--')) {\n\t\t\t\tconst [key, ...valueParts] = arg.slice(2).split('=')\n\t\t\t\tif (key === undefined || key === '') continue\n\t\t\t\tlet value: string\n\t\t\t\tif (valueParts.length > 0) {\n\t\t\t\t\tvalue = valueParts.join('=')\n\t\t\t\t} else if (i + 1 < args.length) {\n\t\t\t\t\tconst nextArg = args[i + 1]\n\t\t\t\t\tif (\n\t\t\t\t\t\tnextArg !== undefined &&\n\t\t\t\t\t\ttypeof nextArg === 'string' &&\n\t\t\t\t\t\t!nextArg.startsWith('-')\n\t\t\t\t\t) {\n\t\t\t\t\t\tvalue = nextArg\n\t\t\t\t\t\ti++\n\t\t\t\t\t} else {\n\t\t\t\t\t\tvalue = 'true'\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tvalue = 'true'\n\t\t\t\t}\n\t\t\t\tCliParser.setFlag(flags, key, value ?? 'true', errors)\n\t\t\t} else if (typeof arg === 'string' && arg.startsWith('-') && arg.length === 2) {\n\t\t\t\tconst key = arg[1]\n\t\t\t\tif (key === undefined || key === '') continue\n\t\t\t\tconst next = args[i + 1]\n\t\t\t\tconst value =\n\t\t\t\t\tnext !== undefined &&\n\t\t\t\t\ttypeof next === 'string' &&\n\t\t\t\t\tnext !== '-' &&\n\t\t\t\t\t!next.startsWith('-')\n\t\t\t\t\t\t? args[++i]\n\t\t\t\t\t\t: 'true'\n\t\t\t\tCliParser.setFlag(flags, key, value ?? 'true', errors)\n\t\t\t} else if (typeof arg === 'string' && arg.startsWith('-') && arg.length > 2) {\n\t\t\t\tfor (let j = 1; j < arg.length; j++) {\n\t\t\t\t\tconst char = arg[j]\n\t\t\t\t\tif (char !== undefined && char !== '') {\n\t\t\t\t\t\tCliParser.setFlag(flags, char, 'true', errors)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else if (typeof arg === 'string') {\n\t\t\t\tpositional.push(arg)\n\t\t\t}\n\t\t}\n\t\tconst url = positional[0]\n\t\tconst saveDir = positional[1]\n\t\tif (flags.concurrency < 1 || flags.concurrency > 20) {\n\t\t\terrors.push('--concurrency must be 1-20')\n\t\t}\n\t\tif (flags.retry < 1 || flags.retry > 10) {\n\t\t\terrors.push('--retry must be 1-10')\n\t\t}\n\t\tif (flags.timeout < 1000) {\n\t\t\terrors.push('--timeout must be >= 1000ms')\n\t\t}\n\t\treturn {\n\t\t\turl,\n\t\t\tsaveDir,\n\t\t\tflags: flags.build(),\n\t\t\terrors: Object.freeze(errors),\n\t\t} as unknown as CliArgs\n\t}\n\tprivate static setFlag(\n\t\tflags: CliFlagsBuilder,\n\t\tkey: string,\n\t\tvalue: string,\n\t\terrors: string[],\n\t): void {\n\t\tconst normalized = key.replace(/-([a-z])/g, (_, c) => c.toUpperCase())\n\t\tswitch (normalized) {\n\t\t\tcase 'help':\n\t\t\tcase 'h':\n\t\t\t\tflags.help = value === 'true'\n\t\t\t\tbreak\n\t\t\tcase 'debug':\n\t\t\t\tflags.debug = value === 'true'\n\t\t\t\tbreak\n\t\t\tcase 'headless':\n\t\t\t\tflags.headless = value !== 'false'\n\t\t\t\tbreak\n\t\t\tcase 'proxy':\n\t\t\t\tflags.proxy = value\n\t\t\t\tbreak\n\t\t\tcase 'logfile':\n\t\t\tcase 'log-file':\n\t\t\t\tflags.logFile = value\n\t\t\t\tbreak\n\t\t\tcase 'json':\n\t\t\t\tflags.json = value === 'true'\n\t\t\t\tbreak\n\t\t\tcase 'batch':\n\t\t\t\tflags.batch = value\n\t\t\t\tbreak\n\t\t\tcase 'concurrency': {\n\t\t\t\tconst num = Number(value)\n\t\t\t\tif (Number.isFinite(num)) flags.concurrency = num\n\t\t\t\telse errors.push(`Invalid concurrency: ${value}`)\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tcase 'retry': {\n\t\t\t\tconst num = Number(value)\n\t\t\t\tif (Number.isFinite(num)) flags.retry = num\n\t\t\t\telse errors.push(`Invalid retry: ${value}`)\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tcase 'timeout': {\n\t\t\t\tconst num = Number(value)\n\t\t\t\tif (Number.isFinite(num)) flags.timeout = num\n\t\t\t\telse errors.push(`Invalid timeout: ${value}`)\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tdefault:\n\t\t\t\terrors.push(`Unknown flag: --${key}`)\n\t\t\t\tbreak\n\t\t}\n\t}\n}\ninterface BrowserConfig {\n\treadonly headless: boolean\n\treadonly userAgent: string\n\treadonly viewport?: {\n\t\treadonly width: number\n\t\treadonly height: number\n\t}\n\treadonly proxy?: {\n\t\treadonly server: string\n\t\treadonly username?: string\n\t\treadonly password?: string\n\t}\n\treadonly acceptDownloads: true\n}\ninterface DownloadResult {\n\treadonly filename: string\n\treadonly savePath: string\n\treadonly size: number\n\treadonly method: 'direct' | 'fallback'\n}\nclass BrowserManager implements AsyncDisposable {\n\tprivate browser: Browser | null = null\n\tprivate context: BrowserContext | null = null\n\tprivate page: Page | null = null\n\tprivate readonly logger: Logger\n\tprivate readonly config: BrowserConfig\n\tconstructor(logger: Logger, config: Partial<BrowserConfig>) {\n\t\tthis.logger = logger\n\t\tconst maybeViewport = config.viewport\n\t\tconst maybeProxy = config.proxy\n\t\tconst browserConfig: BrowserConfig = {\n\t\t\theadless: config.headless ?? true,\n\t\t\tuserAgent:\n\t\t\t\tconfig.userAgent ??\n\t\t\t\t'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36',\n\t\t\tacceptDownloads: true,\n\t\t\t...(maybeViewport !== undefined && { viewport: maybeViewport }),\n\t\t\t...(maybeProxy !== undefined && { proxy: maybeProxy }),\n\t\t}\n\t\tthis.config = Object.freeze(browserConfig)\n\t}\n\tasync launch(): Promise<Result<void, BrowserError>> {\n\t\ttry {\n\t\t\tthis.logger.debug('Launching browser', { headless: this.config.headless })\n\t\t\tconst launchOptions: LaunchOptions = {\n\t\t\t\theadless: this.config.headless,\n\t\t\t\targs: [\n\t\t\t\t\t'--no-sandbox',\n\t\t\t\t\t'--disable-setuid-sandbox',\n\t\t\t\t\t'--disable-dev-shm-usage',\n\t\t\t\t\t'--disable-gpu',\n\t\t\t\t\t'--disable-blink-features=AutomationControlled',\n\t\t\t\t],\n\t\t\t}\n\t\t\tif (this.config.proxy !== undefined) {\n\t\t\t\tconst proxyOpts: LaunchOptions['proxy'] = {\n\t\t\t\t\tserver: this.config.proxy.server,\n\t\t\t\t}\n\t\t\t\tif (this.config.proxy.username !== undefined) {\n\t\t\t\t\t;(proxyOpts as any).username = this.config.proxy.username\n\t\t\t\t}\n\t\t\t\tif (this.config.proxy.password !== undefined) {\n\t\t\t\t\t;(proxyOpts as any).password = this.config.proxy.password\n\t\t\t\t}\n\t\t\t\tlaunchOptions.proxy = proxyOpts\n\t\t\t}\n\t\t\tthis.browser = await chromium.launch(launchOptions)\n\t\t\tconst contextOptions: BrowserContextOptions = {\n\t\t\t\tuserAgent: this.config.userAgent,\n\t\t\t\tacceptDownloads: this.config.acceptDownloads,\n\t\t\t\tlocale: 'en-US',\n\t\t\t\ttimezoneId: 'UTC',\n\t\t\t}\n\t\t\tif (this.config.viewport !== undefined) {\n\t\t\t\tcontextOptions.viewport = this.config.viewport\n\t\t\t}\n\t\t\tthis.context = await this.browser.newContext(contextOptions)\n\t\t\tawait this.context.addCookies([\n\t\t\t\t{\n\t\t\t\t\tname: 'safe_link_counter',\n\t\t\t\t\tvalue: '1',\n\t\t\t\t\tdomain: '.sfile.co',\n\t\t\t\t\tpath: '/',\n\t\t\t\t\texpires: Math.floor(Date.now() / 1000) + 3600,\n\t\t\t\t},\n\t\t\t])\n\t\t\tthis.page = await this.context.newPage()\n\t\t\tthis.setupListeners()\n\t\t\tthis.logger.info('Browser launched successfully')\n\t\t\treturn { success: true, value: undefined }\n\t\t} catch (err) {\n\t\t\tconst error = err instanceof Error ? err : new Error(String(err))\n\t\t\tthis.logger.error('Browser launch failed', { error: error.message })\n\t\t\tawait this.cleanup()\n\t\t\treturn {\n\t\t\t\tsuccess: false,\n\t\t\t\terror: new BrowserError(`Launch failed: ${error.message}`, {\n\t\t\t\t\toriginal: error.name,\n\t\t\t\t}),\n\t\t\t}\n\t\t}\n\t}\n\tprivate setupListeners(): void {\n\t\tif (this.page === null) return\n\t\tthis.page.on('console', (msg) => {\n\t\t\tconst type = msg.type()\n\t\t\tif (type === 'error' || type === 'warning') {\n\t\t\t\tconst level: LogLevel = type === 'error' ? 'ERROR' : 'WARN'\n\t\t\t\tthis.logger.log(level, `[CONSOLE] ${msg.text()}`, { location: msg.location().url })\n\t\t\t}\n\t\t})\n\t\tthis.page.on('pageerror', (err) => {\n\t\t\tthis.logger.error('[PAGE ERROR]', { message: err.message })\n\t\t})\n\t}\n\tasync navigate(\n\t\turl: string,\n\t\toptions?: {\n\t\t\treadonly waitUntil?: 'load' | 'domcontentloaded' | 'networkidle' | 'commit'\n\t\t\treadonly timeout?: number\n\t\t},\n\t): Promise<Result<void, NetworkError>> {\n\t\tif (this.page === null) {\n\t\t\treturn { success: false, error: new NetworkError('Page not initialized') }\n\t\t}\n\t\ttry {\n\t\t\tawait this.page.goto(url, {\n\t\t\t\twaitUntil: options?.waitUntil ?? 'networkidle',\n\t\t\t\ttimeout: options?.timeout ?? 60000,\n\t\t\t})\n\t\t\treturn { success: true, value: undefined }\n\t\t} catch (err) {\n\t\t\tconst error = err instanceof Error ? err : new Error(String(err))\n\t\t\treturn {\n\t\t\t\tsuccess: false,\n\t\t\t\terror: new NetworkError(`Navigation failed: ${error.message}`),\n\t\t\t}\n\t\t}\n\t}\n\tasync waitForDownloadButton(timeout = 30000): Promise<Result<void, Error>> {\n\t\tif (this.page === null) {\n\t\t\treturn { success: false, error: new Error('Page not initialized') }\n\t\t}\n\t\ttry {\n\t\t\tconst button = this.page.locator('#download')\n\t\t\tawait button.waitFor({ state: 'visible', timeout })\n\t\t\tawait this.page.waitForFunction(\n\t\t\t\t() => {\n\t\t\t\t\tconst btn = document.querySelector('#download') as HTMLAnchorElement | null\n\t\t\t\t\tif (btn === null) return false\n\t\t\t\t\tconst href = btn.getAttribute('href')\n\t\t\t\t\tconst style = window.getComputedStyle(btn)\n\t\t\t\t\treturn href !== null && href !== '#' && style.pointerEvents !== 'none'\n\t\t\t\t},\n\t\t\t\t{ timeout },\n\t\t\t)\n\t\t\treturn { success: true, value: undefined }\n\t\t} catch (err) {\n\t\t\tconst error = err instanceof Error ? err : new Error(String(err))\n\t\t\treturn { success: false, error }\n\t\t}\n\t}\n\tasync extractDownloadUrl(): Promise<Result<string, Error>> {\n\t\tif (this.page === null) {\n\t\t\treturn { success: false, error: new Error('Page not initialized') }\n\t\t}\n\t\ttry {\n\t\t\tconst href = await this.page.$eval('#download', (el: Element) => {\n\t\t\t\tconst anchor = el as HTMLAnchorElement\n\t\t\t\treturn anchor.href\n\t\t\t})\n\t\t\tif (href === null || href === '' || href === '#') {\n\t\t\t\treturn { success: false, error: new Error('Invalid download href') }\n\t\t\t}\n\t\t\treturn { success: true, value: href }\n\t\t} catch (err) {\n\t\t\tconst error = err instanceof Error ? err : new Error(String(err))\n\t\t\treturn { success: false, error }\n\t\t}\n\t}\n\tasync waitForDownload(timeout = 60000): Promise<Result<Download, Error>> {\n\t\tif (this.page === null) {\n\t\t\treturn { success: false, error: new Error('Page not initialized') }\n\t\t}\n\t\ttry {\n\t\t\tconst download = await this.page.waitForEvent('download', { timeout })\n\t\t\treturn { success: true, value: download }\n\t\t} catch (err) {\n\t\t\tconst error = err instanceof Error ? err : new Error(String(err))\n\t\t\treturn { success: false, error }\n\t\t}\n\t}\n\tasync collectResponses(waitMs = 3000): Promise<readonly Response[]> {\n\t\tif (this.page === null) return []\n\t\tconst responses: Response[] = []\n\t\tconst handler = (res: Response) => {\n\t\t\tresponses.push(res)\n\t\t}\n\t\tthis.page.on('response', handler)\n\t\tawait sleep(waitMs)\n\t\tthis.page.off('response', handler)\n\t\treturn Object.freeze(responses)\n\t}\n\tfindFileResponse(responses: readonly Response[]): Response | undefined {\n\t\treturn responses\n\t\t\t.slice()\n\t\t\t.reverse()\n\t\t\t.find((r) => {\n\t\t\t\tconst headers = r.headers()\n\t\t\t\tconst disposition = headers['content-disposition']\n\t\t\t\treturn (\n\t\t\t\t\t(disposition !== undefined && disposition.includes('attachment')) ||\n\t\t\t\t\tr.url().includes('/downloadfile/')\n\t\t\t\t)\n\t\t\t})\n\t}\n\tasync saveDebugArtifacts(errorMessage: string): Promise<Result<string, Error>> {\n\t\tif (this.page === null) {\n\t\t\treturn { success: false, error: new Error('Page not available') }\n\t\t}\n\t\ttry {\n\t\t\tconst debugDir = join(tmpdir(), `sfile_debug_${Date.now()}`)\n\t\t\tawait fs.mkdir(debugDir, { recursive: true })\n\t\t\tawait Promise.all([\n\t\t\t\tthis.page.screenshot({ path: join(debugDir, 'error.png'), fullPage: true }),\n\t\t\t\tfs.writeFile(join(debugDir, 'error.html'), await this.page.content()),\n\t\t\t\tfs.writeFile(join(debugDir, 'error.txt'), errorMessage),\n\t\t\t])\n\t\t\treturn { success: true, value: debugDir }\n\t\t} catch (err) {\n\t\t\tconst error = err instanceof Error ? err : new Error(String(err))\n\t\t\treturn {\n\t\t\t\tsuccess: false,\n\t\t\t\terror: new FileError(`Failed to save artifacts: ${error.message}`),\n\t\t\t}\n\t\t}\n\t}\n\tprivate async cleanup(): Promise<void> {\n\t\tif (this.page !== null) {\n\t\t\tawait this.page.close().catch(() => {})\n\t\t\tthis.page = null\n\t\t}\n\t\tif (this.context !== null) {\n\t\t\tawait this.context.close().catch(() => {})\n\t\t\tthis.context = null\n\t\t}\n\t\tif (this.browser !== null) {\n\t\t\tawait this.browser.close().catch(() => {})\n\t\t\tthis.browser = null\n\t\t}\n\t}\n\tasync [Symbol.asyncDispose](): Promise<void> {\n\t\tthis.logger.debug('Closing browser resources...')\n\t\tawait this.cleanup()\n\t\tthis.logger.info('Browser resources closed')\n\t}\n\t[Symbol.dispose](): void {\n\t\tvoid this[Symbol.asyncDispose]()\n\t}\n}\ninterface DownloaderConfig {\n\treadonly saveDir: string\n\treadonly timeout: number\n\treadonly retryAttempts: number\n}\nclass Downloader {\n\tprivate readonly logger: Logger\n\tprivate readonly config: DownloaderConfig\n\tconstructor(logger: Logger, config: DownloaderConfig) {\n\t\tthis.logger = logger\n\t\tthis.config = Object.freeze(config)\n\t}\n\tasync download(url: string): Promise<Result<DownloadResult, AppError>> {\n\t\tif (!url.includes('sfile.co')) {\n\t\t\treturn { success: false, error: new ValidationError('Invalid sfile.co URL', { url }) }\n\t\t}\n\t\ttry {\n\t\t\tawait fs.mkdir(this.config.saveDir, { recursive: true })\n\t\t} catch (err) {\n\t\t\tconst error = err instanceof Error ? err : new Error(String(err))\n\t\t\treturn {\n\t\t\t\tsuccess: false,\n\t\t\t\terror: new FileError(`Failed to create save dir: ${error.message}`),\n\t\t\t}\n\t\t}\n\t\tlet lastError: AppError | undefined\n\t\tfor (let attempt = 1; attempt <= this.config.retryAttempts; attempt++) {\n\t\t\tthis.logger.info(`Download attempt ${attempt}/${this.config.retryAttempts}`, { url })\n\t\t\tconst result = await this.executeDownload(url)\n\t\t\tif (isOk(result)) {\n\t\t\t\treturn result\n\t\t\t}\n\t\t\tlastError = result.error\n\t\t\tif (!lastError.retryable || attempt === this.config.retryAttempts) {\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tconst delay = Math.min(1000 * Math.pow(2, attempt - 1), 10000)\n\t\t\tthis.logger.info(`Retrying in ${delay}ms...`)\n\t\t\tawait sleep(delay)\n\t\t}\n\t\tif (lastError === undefined) {\n\t\t\treturn { success: false, error: new Error('Unknown error') as AppError }\n\t\t}\n\t\treturn { success: false, error: lastError }\n\t}\n\tprivate async executeDownload(url: string): Promise<Result<DownloadResult, AppError>> {\n\t\tconst browserMgr = new BrowserManager(this.logger, {\n\t\t\theadless: true,\n\t\t\tuserAgent:\n\t\t\t\t'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36',\n\t\t})\n\t\ttry {\n\t\t\tconst launchResult = await browserMgr.launch()\n\t\t\tif (isErr(launchResult)) {\n\t\t\t\treturn { success: false, error: launchResult.error }\n\t\t\t}\n\t\t\tconst navResult = await browserMgr.navigate(url)\n\t\t\tif (isErr(navResult)) {\n\t\t\t\treturn { success: false, error: navResult.error }\n\t\t\t}\n\t\t\tconst buttonResult = await browserMgr.waitForDownloadButton()\n\t\t\tif (isErr(buttonResult)) {\n\t\t\t\treturn {\n\t\t\t\t\tsuccess: false,\n\t\t\t\t\terror: new NetworkError(`Button wait failed: ${buttonResult.error.message}`),\n\t\t\t\t}\n\t\t\t}\n\t\t\tconst urlResult = await browserMgr.extractDownloadUrl()\n\t\t\tif (isErr(urlResult)) {\n\t\t\t\treturn {\n\t\t\t\t\tsuccess: false,\n\t\t\t\t\terror: new NetworkError(`URL extract failed: ${urlResult.error.message}`),\n\t\t\t\t}\n\t\t\t}\n\t\t\tconst intermediateUrl = urlResult.value\n\t\t\tconst autoUrl = intermediateUrl.includes('?')\n\t\t\t\t? `${intermediateUrl}&auto=1`\n\t\t\t\t: `${intermediateUrl}?auto=1`\n\t\t\tthis.logger.debug('Auto URL', { url: autoUrl })\n\t\t\tconst downloadPromise = browserMgr.waitForDownload(this.config.timeout)\n\t\t\tconst autoNavResult = await browserMgr.navigate(autoUrl, {\n\t\t\t\twaitUntil: 'commit',\n\t\t\t\ttimeout: this.config.timeout,\n\t\t\t})\n\t\t\tif (isErr(autoNavResult)) {\n\t\t\t\treturn { success: false, error: autoNavResult.error }\n\t\t\t}\n\t\t\tconst downloadResult = await downloadPromise\n\t\t\tif (isOk(downloadResult)) {\n\t\t\t\treturn await this.handleDirectDownload(downloadResult.value, this.config.saveDir)\n\t\t\t} else {\n\t\t\t\tthis.logger.warn('Download event failed, trying fallback')\n\t\t\t\tconst responses = await browserMgr.collectResponses(3000)\n\t\t\t\tconst fileResponse = browserMgr.findFileResponse(responses)\n\t\t\t\tif (fileResponse === undefined) {\n\t\t\t\t\treturn {\n\t\t\t\t\t\tsuccess: false,\n\t\t\t\t\t\terror: new NetworkError('No file response found in fallback'),\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\treturn await this.handleFallbackDownload(fileResponse, this.config.saveDir)\n\t\t\t}\n\t\t} finally {\n\t\t\tawait browserMgr[Symbol.asyncDispose]()\n\t\t}\n\t}\n\tprivate async handleDirectDownload(\n\t\tdownload: Download,\n\t\tsaveDir: string,\n\t): Promise<Result<DownloadResult, AppError>> {\n\t\ttry {\n\t\t\tconst suggested = download.suggestedFilename()\n\t\t\tconst filename = sanitizeFilename(suggested !== undefined ? suggested : 'file.bin')\n\t\t\tconst savePath = join(saveDir, filename)\n\t\t\tthis.logger.info('Saving via direct download', { filename })\n\t\t\tawait download.saveAs(savePath)\n\t\t\tconst stats = await fs.stat(savePath)\n\t\t\treturn {\n\t\t\t\tsuccess: true,\n\t\t\t\tvalue: {\n\t\t\t\t\tfilename,\n\t\t\t\t\tsavePath,\n\t\t\t\t\tsize: stats.size,\n\t\t\t\t\tmethod: 'direct',\n\t\t\t\t},\n\t\t\t}\n\t\t} catch (err) {\n\t\t\tconst error = err instanceof Error ? err : new Error(String(err))\n\t\t\treturn {\n\t\t\t\tsuccess: false,\n\t\t\t\terror: new FileError(`Direct download failed: ${error.message}`),\n\t\t\t}\n\t\t}\n\t}\n\tprivate async handleFallbackDownload(\n\t\tresponse: Response,\n\t\tsaveDir: string,\n\t): Promise<Result<DownloadResult, AppError>> {\n\t\ttry {\n\t\t\tconst buffer = await response.body()\n\t\t\tconst urlPath = response.url().split('?')[0] ?? 'unknown'\n\t\t\tconst base = basename(urlPath)\n\t\t\tconst filename = sanitizeFilename(base !== '' ? base : 'file.bin')\n\t\t\tconst savePath = join(saveDir, filename)\n\t\t\tawait fs.writeFile(savePath, buffer)\n\t\t\tthis.logger.info('Saved via fallback', { filename, size: buffer.length })\n\t\t\treturn {\n\t\t\t\tsuccess: true,\n\t\t\t\tvalue: {\n\t\t\t\t\tfilename,\n\t\t\t\t\tsavePath,\n\t\t\t\t\tsize: buffer.length,\n\t\t\t\t\tmethod: 'fallback',\n\t\t\t\t},\n\t\t\t}\n\t\t} catch (err) {\n\t\t\tconst error = err instanceof Error ? err : new Error(String(err))\n\t\t\treturn {\n\t\t\t\tsuccess: false,\n\t\t\t\terror: new FileError(`Fallback download failed: ${error.message}`),\n\t\t\t}\n\t\t}\n\t}\n}\nclass App {\n\tprivate readonly logger: Logger\n\tconstructor() {\n\t\tthis.logger = new Logger('INFO')\n\t}\n\tasync run(): Promise<number> {\n\t\tconst args = CliParser.parse(process.argv)\n\t\tif (args.errors.length > 0) {\n\t\t\tfor (const err of args.errors) {\n\t\t\t\tthis.logger.error(`CLI error: ${err}`)\n\t\t\t}\n\t\t\tthis.showHelp()\n\t\t\treturn 2\n\t\t}\n\t\tif (args.flags.help || args.url === undefined) {\n\t\t\tthis.showHelp()\n\t\t\treturn 0\n\t\t}\n\t\tthis.logger.info('Starting Sfile Downloader', {\n\t\t\turl: args.url,\n\t\t\tsaveDir: args.saveDir ?? process.cwd(),\n\t\t\theadless: args.flags.headless,\n\t\t})\n\t\tconst downloader = new Downloader(this.logger, {\n\t\t\tsaveDir: args.saveDir ?? process.cwd(),\n\t\t\ttimeout: args.flags.timeout,\n\t\t\tretryAttempts: args.flags.retry,\n\t\t})\n\t\tconst result = await downloader.download(args.url)\n\t\tif (isOk(result)) {\n\t\t\tthis.logger.info('ā
Download complete', {\n\t\t\t\tfile: result.value.filename,\n\t\t\t\tsize: `${Math.round(result.value.size / 1024)} KB`,\n\t\t\t\tmethod: result.value.method,\n\t\t\t})\n\t\t\tconsole.log(`Saved: ${result.value.savePath}`)\n\t\t\treturn 0\n\t\t} else {\n\t\t\tthis.logger.error('ā Download failed', {\n\t\t\t\terror: result.error.message,\n\t\t\t\tcode: result.error.code,\n\t\t\t\tretryable: result.error.retryable,\n\t\t\t})\n\t\t\treturn 1\n\t\t}\n\t}\n\tshowHelp(): void {\n\t\tconsole.log(`\nš Sfile Downloader - Strict TypeScript CLI\nUsage:\n bun run src/index.ts <url> [saveDir] [options]\nArguments:\n url sfile.co URL to download (required)\n saveDir Directory to save files (default: current directory)\nOptions:\n --help, -h Show this help message\n --debug Enable debug logging\n --headless=BOOL Run browser headless (default: true)\n --proxy=URL Proxy server URL\n --log-file=PATH Write logs to file\n --json Output logs as JSON\n --batch=FILE Download URLs from file (one per line)\n --concurrency=N Parallel downloads (1-20, default: 1)\n --retry=N Max retry attempts (1-10, default: 3)\n --timeout=MS Operation timeout in ms (default: 60000)\nExamples:\n bun run src/index.ts https://sfile.co/xyz ./downloads\n bun run src/index.ts --batch=urls.txt --concurrency=3\n bun run src/index.ts https://sfile.co/abc --debug --headless=false\nExit Codes:\n 0 Success\n 1 Download/operation error\n 2 CLI/validation error\n`)\n\t}\n}\nconst main = async (): Promise<void> => {\n\tconst app = new App()\n\tconst shutdown = async (signal: NodeJS.Signals): Promise<void> => {\n\t\tconsole.error(`\\nReceived ${signal}, shutting down...`)\n\t\texit(130)\n\t}\n\tprocess.once('SIGINT', () => {\n\t\tvoid shutdown('SIGINT')\n\t})\n\tprocess.once('SIGTERM', () => {\n\t\tvoid shutdown('SIGTERM')\n\t})\n\ttry {\n\t\tconst exitCode = await app.run()\n\t\texit(exitCode)\n\t} catch (err) {\n\t\tconst error = err instanceof Error ? err : new Error(String(err))\n\t\tconsole.error(`[FATAL] Unhandled error: ${error.message}`)\n\t\tif (process.env['NODE_ENV'] === 'development' && error.stack !== undefined) {\n\t\t\tconsole.error(error.stack)\n\t\t}\n\t\texit(1)\n\t}\n}\nif (require.main === module) {\n\tvoid main()\n}\nexport { App, Downloader, BrowserManager, Logger, CliParser }\nexport type {\n\tResult,\n\tAppError,\n\tValidationError,\n\tNetworkError,\n\tFileError,\n\tBrowserError,\n\tCliFlags,\n\tCliArgs,\n\tDownloadResult,\n\tBrowserConfig,\n\tDownloaderConfig,\n\tLogLevel,\n\tLogEntry,\n}\n"],"names":["fs"],"mappings":";;;;;;;AAkBA,MAAM,IAAI,GAAG,CACZ,MAAoB,KAIhB,MAAM,CAAC,OAAO;AACnB,MAAM,KAAK,GAAG,CACb,MAAoB,KAIhB,CAAC,MAAM,CAAC,OAAO;AACpB,MAAM,aAAa,GAAG,CAAC,KAAc,EAAE,KAAc,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M,GAAG,CAAC,GAAG,EAAE;QAChC,IAAI,CAAC,QAAQ,CAAC;IACf;IAAE,OAAO,GAAG,EAAE;QACb,MAAM,KAAK,GAAG,GAAG,YAAY,KAAK,GAAG,GAAG,GAAG,IAAI,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;QACjE,OAAO,CAAC,KAAK,CAAC,CAAA,yBAAA,EAA4B,KAAK,CAAC,OAAO,CAAA,CAAE,CAAC;AAC1D,QAAA,IAAI,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,KAAK,aAAa,IAAI,KAAK,CAAC,KAAK,KAAK,SAAS,EAAE;AAC3E,YAAA,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC;QAC3B;QACA,IAAI,CAAC,CAAC,CAAC;IACR;AACD,CAAC;AACD,IAAI,OAAO,CAAC,IAAI,KAAK,MAAM,EAAE;IAC5B,KAAK,IAAI,EAAE;AACZ;;;;"}
|
package/license
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 neuxdotdev
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/package.json
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "sfiledl",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "š Sfile Downloader - Strict TypeScript CLI tool for downloading files from sfile.co",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./build/index.cjs",
|
|
7
|
+
"module": "./build/index.js",
|
|
8
|
+
"types": "./build/index.d.ts",
|
|
9
|
+
"license": "MIT",
|
|
10
|
+
"files": [
|
|
11
|
+
"build"
|
|
12
|
+
],
|
|
13
|
+
"sideEffects": false,
|
|
14
|
+
"engines": {
|
|
15
|
+
"node": ">=18.0.0",
|
|
16
|
+
"bun": ">=1.0.0"
|
|
17
|
+
},
|
|
18
|
+
"publishConfig": {
|
|
19
|
+
"access": "public"
|
|
20
|
+
},
|
|
21
|
+
"exports": {
|
|
22
|
+
".": {
|
|
23
|
+
"types": "./build/index.d.ts",
|
|
24
|
+
"import": "./build/index.js",
|
|
25
|
+
"require": "./build/index.cjs"
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
"bin": {
|
|
29
|
+
"sfiledl": "./build/index.js"
|
|
30
|
+
},
|
|
31
|
+
"scripts": {
|
|
32
|
+
"clean": "rm -rf build node_modules/.cache",
|
|
33
|
+
"typecheck": "tsc --noEmit",
|
|
34
|
+
"build:ts": "tsc",
|
|
35
|
+
"build:bundle": "rollup -c",
|
|
36
|
+
"build": "bun run clean && bun run typecheck && bun run build:ts && bun run build:bundle",
|
|
37
|
+
"dev:ts": "tsc --emitDeclarationOnly --outDir build --watch",
|
|
38
|
+
"build:prod": "NODE_ENV=production bun run build",
|
|
39
|
+
"dev": "rollup -c -w --bundleConfigAsCjs",
|
|
40
|
+
"format:build": "bun ./scripts/format-build.js",
|
|
41
|
+
"lint": "tsc --noEmit",
|
|
42
|
+
"format": "prettier . --write",
|
|
43
|
+
"format:check": "prettier . --check",
|
|
44
|
+
"clean-code": "rmcm -l js -i -c 0 -r ./src --verbose && bun run format",
|
|
45
|
+
"rebuild": "bun run clean && bun run clean-code && bun run build && bun run format:build",
|
|
46
|
+
"test": "bun test",
|
|
47
|
+
"prepublishOnly": "bun run build",
|
|
48
|
+
"prepare": "husky install || true",
|
|
49
|
+
"install:playwright": "bunx playwright install chromium"
|
|
50
|
+
},
|
|
51
|
+
"keywords": [
|
|
52
|
+
"sfile",
|
|
53
|
+
"download",
|
|
54
|
+
"playwright",
|
|
55
|
+
"typescript",
|
|
56
|
+
"cli",
|
|
57
|
+
"bun",
|
|
58
|
+
"sfile-downloader"
|
|
59
|
+
],
|
|
60
|
+
"author": "neuxdotdev <neux@github.com>",
|
|
61
|
+
"repository": {
|
|
62
|
+
"type": "git",
|
|
63
|
+
"url": "https://github.com/neuxdotdev/sfiledl.git"
|
|
64
|
+
},
|
|
65
|
+
"bugs": {
|
|
66
|
+
"url": "https://github.com/neuxdotdev/sfiledl/issues"
|
|
67
|
+
},
|
|
68
|
+
"homepage": "https://github.com/neuxdotdev/sfiledl#readme",
|
|
69
|
+
"dependencies": {
|
|
70
|
+
"playwright": "^1.58.2"
|
|
71
|
+
},
|
|
72
|
+
"devDependencies": {
|
|
73
|
+
"@types/node": "^25.5.0",
|
|
74
|
+
"@rollup/plugin-commonjs": "^29.0.2",
|
|
75
|
+
"@rollup/plugin-json": "^6.1.0",
|
|
76
|
+
"@rollup/plugin-node-resolve": "^16.0.3",
|
|
77
|
+
"@rollup/plugin-replace": "^6.0.3",
|
|
78
|
+
"@rollup/plugin-terser": "^1.0.0",
|
|
79
|
+
"@rollup/plugin-typescript": "^12.3.0",
|
|
80
|
+
"dts-bundle-generator": "^9.5.1",
|
|
81
|
+
"esbuild": "^0.27.4",
|
|
82
|
+
"husky": "^9.1.7",
|
|
83
|
+
"prettier": "^3.8.1",
|
|
84
|
+
"rollup": "^4.60.1",
|
|
85
|
+
"rollup-plugin-dts": "^6.4.1",
|
|
86
|
+
"rollup-plugin-peer-deps-external": "^2.2.4",
|
|
87
|
+
"rollup-plugin-visualizer": "^7.0.1",
|
|
88
|
+
"tslib": "^2.8.1",
|
|
89
|
+
"typescript": "^6.0.2"
|
|
90
|
+
}
|
|
91
|
+
}
|
package/readme
ADDED
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
# sfiledl
|
|
2
|
+
|
|
3
|
+
sfiledl is a tool designed to speed up the process of downloading files from the site https://sfile.co/.
|
|
4
|
+
|
|
5
|
+
So, the site https://sfile.co/ is a site that works like Mediafire, a place for sharing files quickly.
|
|
6
|
+
|
|
7
|
+
So, if we use a browser, it will take time. So, with sfiledl, we can automate the process of clicking on the UI. We just need to use the URL and everything is automated.
|
|
8
|
+
|
|
9
|
+
## INSTALLATION
|
|
10
|
+
|
|
11
|
+
Installing sfiledl is quite easy. Make sure you have bun (recommended), npm. If you have it, open your terminal and run it.
|
|
12
|
+
|
|
13
|
+
$ bun install --global sfiledl
|
|
14
|
+
|
|
15
|
+
Congratulations, you've now installed sfiledl
|
|
16
|
+
|
|
17
|
+
## ALTERNATIVE INSTALLATION
|
|
18
|
+
|
|
19
|
+
You can also clone this repository and install manually:
|
|
20
|
+
|
|
21
|
+
$ git clone https://github.com/neuxdotdev/sfiledl.git
|
|
22
|
+
$ cd sfiledl
|
|
23
|
+
$ bun install
|
|
24
|
+
$ bunx playwright install chromium
|
|
25
|
+
|
|
26
|
+
Then run directly:
|
|
27
|
+
|
|
28
|
+
$ bun run src/index.ts
|
|
29
|
+
|
|
30
|
+
## USAGE
|
|
31
|
+
|
|
32
|
+
Download single file:
|
|
33
|
+
|
|
34
|
+
$ bun run src/index.ts <url> [saveDir]
|
|
35
|
+
|
|
36
|
+
Example:
|
|
37
|
+
|
|
38
|
+
$ bun run src/index.ts https://sfile.co/xyz ./downloads
|
|
39
|
+
|
|
40
|
+
Using globally installed binary:
|
|
41
|
+
|
|
42
|
+
$ sfiledl https://sfile.co/xyz
|
|
43
|
+
|
|
44
|
+
## OPTIONS
|
|
45
|
+
|
|
46
|
+
--help, -h Show this help message
|
|
47
|
+
--debug Enable debug logging
|
|
48
|
+
--headless=BOOL Run browser headless (default: true)
|
|
49
|
+
--proxy=URL Proxy server URL
|
|
50
|
+
--log-file=PATH Write logs to file
|
|
51
|
+
--json Output logs as JSON
|
|
52
|
+
--batch=FILE Download URLs from file (one per line)
|
|
53
|
+
--concurrency=N Parallel downloads (1-20, default: 1)
|
|
54
|
+
--retry=N Max retry attempts (1-10, default: 3)
|
|
55
|
+
--timeout=MS Operation timeout in ms (default: 60000)
|
|
56
|
+
|
|
57
|
+
## BATCH DOWNLOAD
|
|
58
|
+
|
|
59
|
+
Create a text file with one URL per line:
|
|
60
|
+
|
|
61
|
+
## urls.txt
|
|
62
|
+
|
|
63
|
+
https://sfile.co/url1
|
|
64
|
+
https://sfile.co/url2
|
|
65
|
+
https://sfile.co/url3
|
|
66
|
+
|
|
67
|
+
Then run:
|
|
68
|
+
|
|
69
|
+
$ bun run src/index.ts --batch=urls.txt --concurrency=3
|
|
70
|
+
|
|
71
|
+
## EXIT CODES
|
|
72
|
+
|
|
73
|
+
0 Success
|
|
74
|
+
1 Download or operation error
|
|
75
|
+
2 CLI or validation error
|
|
76
|
+
|
|
77
|
+
## EXAMPLES
|
|
78
|
+
|
|
79
|
+
Basic download:
|
|
80
|
+
|
|
81
|
+
$ bun run src/index.ts https://sfile.co/abc /tmp/downloads
|
|
82
|
+
|
|
83
|
+
With more retries:
|
|
84
|
+
|
|
85
|
+
$ bun run src/index.ts https://sfile.co/xyz --retry=5
|
|
86
|
+
|
|
87
|
+
Disable headless mode (shows browser window):
|
|
88
|
+
|
|
89
|
+
$ bun run src/index.ts https://sfile.co/def --headless=false
|
|
90
|
+
|
|
91
|
+
Use proxy:
|
|
92
|
+
|
|
93
|
+
$ bun run src/index.ts https://sfile.co/ghi --proxy=http://localhost:8080
|
|
94
|
+
|
|
95
|
+
Longer timeout for slow networks:
|
|
96
|
+
|
|
97
|
+
$ bun run src/index.ts https://sfile.co/jkl --timeout=120000
|
|
98
|
+
|
|
99
|
+
Debug logging:
|
|
100
|
+
|
|
101
|
+
$ bun run src/index.ts https://sfile.co/mno --debug --verbose
|
|
102
|
+
|
|
103
|
+
## TROUBLESHOOTING
|
|
104
|
+
|
|
105
|
+
ERROR: Browser launch failed
|
|
106
|
+
SOLUTION: Install Playwright browsers by running bunx playwright install chromium
|
|
107
|
+
|
|
108
|
+
ERROR: Download timeout
|
|
109
|
+
SOLUTION: Increase timeout using --timeout flag with higher value
|
|
110
|
+
|
|
111
|
+
ERROR: Network blocked
|
|
112
|
+
SOLUTION: Use proxy option or check firewall settings
|
|
113
|
+
|
|
114
|
+
ERROR: File permission denied
|
|
115
|
+
SOLUTION: Create download directory first or change save path permissions
|
|
116
|
+
|
|
117
|
+
## REQUIREMENTS
|
|
118
|
+
|
|
119
|
+
Node.js >= 18.0.0
|
|
120
|
+
Bun >= 1.3
|
|
121
|
+
Playwright Chromium browser (install separately)
|
|
122
|
+
|
|
123
|
+
## CONTRIBUTING
|
|
124
|
+
|
|
125
|
+
Contributions are welcome! Please feel free to submit Pull Requests.
|
|
126
|
+
|
|
127
|
+
1. Fork the repository
|
|
128
|
+
2. Create your feature branch
|
|
129
|
+
3. Commit your changes
|
|
130
|
+
4. Push to the branch
|
|
131
|
+
5. Open a Pull Request
|
|
132
|
+
|
|
133
|
+
## BUILD FROM SOURCE
|
|
134
|
+
|
|
135
|
+
Build production bundle:
|
|
136
|
+
|
|
137
|
+
$ bun run build
|
|
138
|
+
|
|
139
|
+
Clean and rebuild:
|
|
140
|
+
|
|
141
|
+
$ bun run rebuild
|
|
142
|
+
|
|
143
|
+
Type check only:
|
|
144
|
+
|
|
145
|
+
$ bun run typecheck
|
|
146
|
+
|
|
147
|
+
Run tests:
|
|
148
|
+
|
|
149
|
+
$ bun run test
|
|
150
|
+
|
|
151
|
+
## PERFORMANCES
|
|
152
|
+
|
|
153
|
+
Single file: ~2-5 seconds depending on network speed
|
|
154
|
+
Batch download: Up to 20 concurrent downloads with concurrency option
|
|
155
|
+
Memory usage: Optimized for long-running operations
|
|
156
|
+
|
|
157
|
+
## LICENSE
|
|
158
|
+
|
|
159
|
+
MIT License - see LICENSE file for details
|
|
160
|
+
|
|
161
|
+
## AUTHOR
|
|
162
|
+
|
|
163
|
+
neuxdotdev - neuxdev1@gmail.com
|
|
164
|
+
|
|
165
|
+
## CREDITS
|
|
166
|
+
|
|
167
|
+
Built with Playwright automation framework
|
|
168
|
+
Designed for Bun runtime performance optimization
|
|
169
|
+
|
|
170
|
+
Repository: https://github.com/neuxdotdev/sfiledl
|
|
171
|
+
|
|
172
|
+
Issues: https://github.com/neuxdotdev/sfiledl/issues
|