mirror of
https://github.com/mmahdium/TorrentMax.git
synced 2025-12-20 04:33:53 +01:00
- Add Arctic Lights background with radial gradient to index.vue - Make multiple app files executable (changed modes from 644 to 755) - Update dependencies in package-lock.json (browserslist, postcss-selector-parser, etc.) for latest versions and potential bug fixes
19 lines
548 B
TypeScript
Executable File
19 lines
548 B
TypeScript
Executable File
import parseTorrent from "parse-torrent";
|
|
import type { MagnetUrl } from "../../shared/types/magnet";
|
|
|
|
export async function parseTorrentFileToMagnetUrl(
|
|
file: Buffer
|
|
): Promise<MagnetUrl> {
|
|
const parsed = await parseTorrent(file);
|
|
|
|
const magnet: MagnetUrl = {
|
|
xt: `urn:btih:${parsed.infoHash}`,
|
|
dn: Array.isArray(parsed.name) ? parsed.name.join(" ") : parsed.name,
|
|
tr: parsed.announce || [],
|
|
xs: parsed.urlList || [],
|
|
// as, kt, mt are rarely present in .torrent files, but you can add if needed
|
|
};
|
|
|
|
return magnet;
|
|
}
|