Compare commits

...

7 Commits

Author SHA1 Message Date
4af305fa56 Progress saving 2025-11-17 13:05:56 +01:00
31eeff8890 Error handling search 2025-10-22 13:52:11 +02:00
4e0748302e removed extra unnecessary .mp3 extensions 2025-10-22 13:48:13 +02:00
8490b2d16c code cleanup 2025-10-22 11:53:12 +02:00
48bbec8830 fixed queue 2025-10-22 11:49:25 +02:00
27a4043095 Converted over to TS 2025-10-22 11:48:36 +02:00
8c7ec8e968 Updated to v3 api
Senseless JSDoc
2025-10-22 11:32:12 +02:00
10 changed files with 754 additions and 166 deletions

1
.env
View File

@@ -0,0 +1 @@
AUTHTOKEN=eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJfaWQiOiJmWVlwNF8ybmRaTmxEM1UweWU1eGciLCJleHAiOjE3NjExMjAxNTIuODYzLCJpYXQiOjE3NjExMTkyNTJ9.UDf9OZqqC8uXnkKXnqdXJDrVGbSPo_Q9IT9x2tf8mcJEu9qm3twTcfqNetbLlsw9b4bERyoh1waXIzCJj8hCIWK-oRMenbzdjbSqMl29_36tNV204fnuGXhEMo8-NXS6k9DCQ74-1xd1IOGcACP4rHyDcKvEY46D_ccfJL-TR_TGFIxJrt05SGrBWNr4I2AFQ4I-uq23jInphIkOggw356dNIRvfinhoGYkju8IUiUIGUFTMgXom9rBm-RR2k9MhHm9d0FqMuGGrB5dlFzvGXc7LUIabC4-MIc17g6U2aqPGCuyTSHkmCsWJQE9y4wZZ2m6px7wkyIOtYjbhDnzFhw

1
.gitignore vendored
View File

@@ -1,3 +1,4 @@
songs/
json-data/
node_modules/
dist

View File

@@ -1,7 +1,7 @@
import https from 'https';
import fs from 'fs';
import * as https from 'https';
import * as fs from 'fs';
async function downloadSong(downloadLink, folder, filename, songCount) {
async function downloadSong(downloadLink: string, folder: string, filename: string, songCount: number): Promise<void> {
console.log(`Downloading song #${songCount} ...`)
return new Promise((resolve, reject) => {
https.get(downloadLink, (response) => {
@@ -10,7 +10,7 @@ async function downloadSong(downloadLink, folder, filename, songCount) {
console.log(`${songCount} songs downloaded successfully`);
resolve();
})
.on('error', (error) => {
.on('error', (error: Error) => {
console.error('Error downloading song:', error);
reject(error);
});
@@ -18,8 +18,8 @@ async function downloadSong(downloadLink, folder, filename, songCount) {
});
}
process.on('message', async (message) => {
process.on('message', async (message: any) => {
const { downloadLink, folder, filename, songCount } = message;
await downloadSong(downloadLink, folder, filename, songCount);
process.send(`Song #${songCount} downloaded successfully`);
process.send && process.send(`Song #${songCount} downloaded successfully`);
});

View File

@@ -1,2 +0,0 @@
GET https://api.brain.fm/v2/mental-states/6042a1bad80ae028b821e958/genres/
Authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJfaWQiOiJGYmd3dndBT1JCTjlibVJmRUxLcHciLCJleHAiOjE2ODE5ODg5MTUuMzU2LCJpYXQiOjE2ODE5ODgwMTV9.hCs0U5Iv5bgaU9oYi9kmSl0A_gt3V9svL0NiCEvtZFr4DXiNQwkt30fUtwOofMmHUnoEKiRt8ER-K8n5vsXKc23gvvcKaYEzY1kipwlAkK_JiYslE1FXDGXBBN1VrunACWLY5sWyRt1og6WP20BaoD0gIvBr0iazN323mlpU_Ls4yOrid2J_veXAwmCkW_26Q2NbhJeEV2rlwnV95CtxmogYHkoDrDz65UncU5AUvl4ae96il9IN7MSI0DvFl3NutVnD3B2wPaNHNAIoMC1_nLwWl5Q5GMbgC2AW3B1U0pozg78ePFVWq-mKYY8IbgjESNKWg1gRF5oknsFq8shxjw

16
jsconfig.json Normal file
View File

@@ -0,0 +1,16 @@
{
"compilerOptions": {
"module": "ESNext",
"moduleResolution": "Bundler",
"target": "ES2024",
"jsx": "react-jsx",
"allowImportingTsExtensions": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"strict": true
},
"exclude": [
"node_modules",
"**/node_modules/*"
]
}

157
main.js
View File

@@ -1,157 +0,0 @@
import fs from 'fs';
import https from 'https';
import chalk from 'chalk';
import load from 'dotenv';
load()
let songCount = 1;
const AUTHTOKEN = process.env.AUTHTOKEN;
const TOKEN = process.env.TOKEN;
const USERID = process.env.USERID;
if(!AUTHTOKEN || !TOKEN || !USERID) {
console.error('Please enter all the required information');
process.exit(1);
}
let genres = [
"Beach",
"Chimes & Bowls",
"Forest",
"Nightsounds",
"Rain",
"Rainforest",
"River",
"Thunder",
"Underwater",
"Wind",
"Acoustic",
"Atmospheric",
"Cinematic",
"Classical",
"Drone",
"Electronic",
"Grooves",
"Lofi",
"Piano",
"Post Rock",
];
let mentalStateIDs = {
focus: "6042a1bad80ae028b821e954",
sleep: "6042a1bad80ae028b821e95c",
relax: "6042a1bad80ae028b821e958"
}
class DownloadQueue {
constructor(maxConcurrency) {
this.queue = [];
this.activeDownloads = 0;
this.maxConcurrency = maxConcurrency;
}
enqueue(url, folder, filename) {
this.queue.push({url, folder, filename});
this.processQueue();
}
async processQueue() {
if (this.activeDownloads < this.maxConcurrency && this.queue.length > 0) {
const {url, folder, filename} = this.queue.shift();
this.activeDownloads++;
await downloadSong(url, folder, filename);
console.log(`${songCount} songs downloaded successfully \n${this.queue.length} remaining`)
this.activeDownloads--;
this.processQueue();
}
}
}
const downloadQueue = new DownloadQueue(3)
for(const genre of genres) {
console.log(chalk.red(`Starting genre ${genre}`))
for(const mentalState of Object.keys(mentalStateIDs)) {
console.log(chalk.yellow(`Starting mental state ${mentalState}`))
//
// Phase 1 : Fetch all song data
//
let data = await fetch(`https://api.brain.fm/v2/genres/${genre}/tracks?mentalStateId=${mentalStateIDs[mentalState]}&version=3`, {
headers: {
authorization: `Bearer ${AUTHTOKEN}`
}
});
data = await data.json();
data = formatAudioData(data.result);
if (checkIfJsonExists(`./json-data/${mentalState}/${genre}.json`)) continue;
ensureDirectory(`./json-data/${mentalState}`);
let file = fs.createWriteStream(`./json-data/${mentalState}/${genre}.json`);
file.write(JSON.stringify(data));
file.close();
//
// Phase 2 : Download songs to device
//
console.log(chalk.green(`Started downloading ${genre} ${mentalState}`))
for (const song of data) {
let activity = song.serving.track.tags.find(tag => tag.type === "activity").value;
let NEL = song.neuralEffectLevel;
let level = (NEL > 0.66 ? "high" : NEL > 0.33 ? "medium" : "low");
let hasMultipleNELs = song.hasMultipleNELs;
let folder = `./songs/${genre}/${mentalState}/${activity}/${hasMultipleNELs ? "mixed" : level}`
let filename = `${song.name.replace(' ', '_')}`;
let downloadLink = `https://audio.brain.fm/${song.url}?userId=${USERID}&token=${TOKEN}`;
downloadQueue.enqueue(downloadLink, folder, filename);
}
}
};
async function downloadSong(downloadLink, folder, filename) {
return new Promise((resolve, reject) => {
ensureDirectory(folder)
https.get(downloadLink, (response) => {
response.pipe(fs.createWriteStream(`${folder}/${filename}.mp3`))
.on('finish', () => {
songCount++
resolve();
})
.on('error', (error) => {
console.error('Error downloading song:', error);
reject(error);
});
});
});
}
function formatAudioData(arr) {
return arr.map(item => {
delete item.serving.track.similarTracks;
return item;
});
}
function ensureDirectory(directory) {
if (!fs.existsSync(directory)) {
fs.mkdirSync(directory, { recursive: true });
}
}
function checkIfJsonExists(mentalState, genre) {
const filePath = `./json-data/${mentalState}/${genre}.json`;
return fs.existsSync(filePath);
}

457
main.ts Normal file
View File

@@ -0,0 +1,457 @@
import * as fs from 'fs';
import * as https from 'https';
import chalk from 'chalk';
import * as dotenv from 'dotenv';
dotenv.config();
let songCount = 1;
const PROGRESS_FILE = './progress.json';
type ProgressState = {
songCount: number;
currentMentalStateIndex: number;
currentGenreIndex: number;
processedSongs: Set<string>;
completedGenres: string[];
};
function loadProgress(): ProgressState | null {
if (fs.existsSync(PROGRESS_FILE)) {
try {
const data = JSON.parse(fs.readFileSync(PROGRESS_FILE, 'utf-8'));
console.log(chalk.blue('Found previous progress, resuming...'));
console.log(chalk.blue(`Previously downloaded: ${data.songCount} songs`));
return {
...data,
processedSongs: new Set(data.processedSongs || [])
};
} catch (error) {
console.error(chalk.red('Error loading progress file, starting fresh'), error);
return null;
}
}
return null;
}
function saveProgress(state: ProgressState) {
const dataToSave = {
...state,
processedSongs: Array.from(state.processedSongs)
};
fs.writeFileSync(PROGRESS_FILE, JSON.stringify(dataToSave, null, 2));
}
function clearProgress() {
if (fs.existsSync(PROGRESS_FILE)) {
fs.unlinkSync(PROGRESS_FILE);
console.log(chalk.green('Progress file cleared - all downloads complete!'));
}
}
const AUTHTOKEN = process.env.AUTHTOKEN;
if (!AUTHTOKEN) {
console.error('Please enter all the required information');
process.exit(1);
}
type MentalState = "focus" | "relax" | "sleep" | "meditate";
type MentalStateArray = MentalState[];
let mentalStates: MentalStateArray = ["focus", "relax", "sleep", "meditate"];
type GenreStructure = {
base: string[];
nature: string[];
};
type GenresMap = Record<MentalState, GenreStructure>;
let genres: GenresMap = {
"focus": {
base: [
"Acoustic",
"Atmospheric",
"Cinematic",
"Classical",
"Drone",
"Electronic",
"Grooves",
"Lofi",
"Piano",
"Post Rock"
],
nature: [
"Beach",
"Chimes & Bowls",
"Forest",
"Nightsounds",
"Rain",
"Rainforest",
"River",
"Thunder",
"Underwater",
"Wind"
]
},
"relax": {
base: [
"Atmospheric",
"Electronic"
],
nature: [
"Beach",
"Chimes & Bowls",
"Forest",
"Nightsounds",
"Rain",
"Rainforest",
"River",
"Thunder",
"Underwater",
"Wind"
]
},
"sleep": {
base: [
"Atmospheric"
],
nature: [
"Beach",
"Forest",
"Nightsounds",
"Rain",
"Rainforest",
"River",
"Thunder",
"Underwater",
"Wind"
]
},
"meditate": {
base: [
"Atmospheric",
"Electronic"
],
nature: [
"Beach",
"Chimes & Bowls",
"Forest",
"Nightsounds",
"Rain",
"Rainforest",
"River",
"Thunder",
"Underwater",
"Wind"
]
}
};
// Commenting out moods since it's not used in the code
/*
type MoodsMap = Record<MentalState, string[]>;
let moods: MoodsMap = {
"focus": [
"Brooding",
"Calm",
"Chill",
"Dark",
"Downtempo",
"Dreamlike",
"Driving",
"Energizing",
"Epic",
"Floating",
"Heavy",
"Hopeful",
"Inspiring",
"Meditative",
"Mysterious",
"Ominous",
"Optimistic",
"Playful",
"Ponderous",
"Serene",
"Strong",
"Upbeat",
"Uplifting"
],
"relax": [
"Brooding",
"Calm",
"Chill",
"Dark",
"Downtempo",
"Dreamlike",
"Driving",
"Energizing",
"Epic",
"Floating",
"Hopeful",
"Inspiring",
"Meditative",
"Mysterious",
"Optimistic",
"Playful",
"Ponderous",
"Serene",
"Strong",
"Upbeat",
"Uplifting"
],
"sleep": [
"Brooding",
"Calm",
"Chill",
"Dark",
"Dreamlike",
"Epic",
"Floating",
"Heavy",
"Meditative",
"Mysterious",
"Optimistic",
"Ponderous",
"Serene",
"Strong"
],
"meditate": [
"Brooding",
"Calm",
"Chill",
"Dark",
"Downtempo",
"Dreamlike",
"Driving",
"Energizing",
"Epic",
"Floating",
"Heavy",
"Hopeful",
"Inspiring",
"Meditative",
"Mysterious",
"Optimistic",
"Playful",
"Ponderous",
"Serene",
"Strong",
"Upbeat",
"Uplifting"
]
}
*/
type QueueEntry = {
url: string;
folder: string;
filename: string;
songId: string;
};
class DownloadQueue {
private queue: QueueEntry[] = [];
private activeDownloads = 0;
private maxConcurrency: number;
private progressState: ProgressState;
constructor(maxConcurrency: number, progressState: ProgressState) {
this.maxConcurrency = maxConcurrency;
this.progressState = progressState;
}
public enqueue(url: string, folder: string, filename: string, songId: string) {
// Skip if already processed
if (this.progressState.processedSongs.has(songId)) {
return;
}
this.queue.push({ url, folder, filename, songId });
this.processQueue();
}
public async waitForCompletion(): Promise<void> {
return new Promise((resolve) => {
const checkInterval = setInterval(() => {
if (this.activeDownloads === 0 && this.queue.length === 0) {
clearInterval(checkInterval);
resolve();
}
}, 100);
});
}
private async processQueue(): Promise<void> {
while (this.activeDownloads < this.maxConcurrency && this.queue.length > 0) {
const { url, folder, filename, songId } = this.queue.shift()!;
this.activeDownloads++;
this.processDownload(url, folder, filename, songId).then(() => {
this.activeDownloads--;
this.processQueue();
}).catch((error) => {
console.error('Error downloading song:', error);
this.activeDownloads--;
this.processQueue();
});
}
}
private async processDownload(url: string, folder: string, filename: string, songId: string): Promise<void> {
await downloadSong(url, folder, filename);
this.progressState.songCount++;
this.progressState.processedSongs.add(songId);
songCount = this.progressState.songCount;
// Save progress every 10 songs
if (this.progressState.songCount % 10 === 0) {
saveProgress(this.progressState);
}
console.log(`${songCount} songs downloaded successfully \n${this.queue.length} remaining`);
}
}
// Load or initialize progress
const savedProgress = loadProgress();
const progressState: ProgressState = savedProgress || {
songCount: 0,
currentMentalStateIndex: 0,
currentGenreIndex: 0,
processedSongs: new Set(),
completedGenres: []
};
songCount = progressState.songCount;
const downloadQueue = new DownloadQueue(3, progressState);
// Set up graceful shutdown
process.on('SIGINT', () => {
console.log(chalk.yellow('\n\nReceived SIGINT, saving progress...'));
saveProgress(progressState);
process.exit(0);
});
process.on('SIGTERM', () => {
console.log(chalk.yellow('\n\nReceived SIGTERM, saving progress...'));
saveProgress(progressState);
process.exit(0);
});
for (let mentalStateIndex = progressState.currentMentalStateIndex; mentalStateIndex < mentalStates.length; mentalStateIndex++) {
const mentalState = mentalStates[mentalStateIndex];
console.log(chalk.red(`Starting mental state ${mentalState}`))
const allGenres = [...genres[mentalState].base, ...genres[mentalState].nature];
const startGenreIndex = mentalStateIndex === progressState.currentMentalStateIndex ? progressState.currentGenreIndex : 0;
for (let genreIndex = startGenreIndex; genreIndex < allGenres.length; genreIndex++) {
const genre = allGenres[genreIndex];
const genreKey = `${mentalState}:${genre}`;
// Skip if already completed
if (progressState.completedGenres.includes(genreKey)) {
console.log(chalk.gray(`Skipping already completed: ${genre} (${mentalState})`));
continue;
}
console.log(chalk.yellow(`Starting genre ${genre}`))
// Update current position
progressState.currentMentalStateIndex = mentalStateIndex;
progressState.currentGenreIndex = genreIndex;
//
// Phase 1 : Fetch all song data
//
const response = await fetch(`https://api.brain.fm/v3/servings/search?genre=${genre}&dynamicMentalStateId=${mentalState}`, {
headers: {
authorization: `Bearer ${AUTHTOKEN}`
}
});
if (!response.ok) {
chalk.red("ERROR SEARCHING SONGS")
chalk.red(response.text());
continue;
}
const responseData = await response.json();
const data = formatAudioData(responseData.result);
if (checkIfJsonExists(`./json-data/${mentalState}/${genre}.json`)) continue;
ensureDirectory(`./json-data/${mentalState}`);
let file = fs.createWriteStream(`./json-data/${mentalState}/${genre}.json`);
file.write(JSON.stringify(data));
file.close();
//
// Phase 2 : Download songs to device
//
console.log(chalk.green(`Started queuing ${genre} ${mentalState}`))
for (const song of data) {
let activity = song.track.tags.filter((x: any) => x.type == 'activity').map((x: any) => x.value).join('/');
let NEL = song.trackVariation.neuralEffectLevel;
let level = (NEL > 0.66 ? "high" : NEL > 0.33 ? "medium" : "low");
let folder = `./songs/${genre}/${mentalState}/${activity}/${level}`
let filename = song.trackVariation.baseUrl;
let downloadLink = song.trackVariation.tokenedUrl;
let songId = `${mentalState}:${genre}:${filename}`;
downloadQueue.enqueue(downloadLink, folder, filename, songId);
}
// Wait for all songs in this genre to complete before marking as done
await downloadQueue.waitForCompletion();
// Mark genre as completed
progressState.completedGenres.push(genreKey);
saveProgress(progressState);
console.log(chalk.green(`✓ Completed ${genre} (${mentalState})`));
}
}
// All done, clear progress file
clearProgress();
console.log(chalk.green.bold(`\n🎉 All downloads complete! Total songs: ${songCount}`));
function downloadSong(downloadLink: string, folder: string, filename: string): Promise<void> {
return new Promise((resolve, reject) => {
ensureDirectory(folder)
https.get(downloadLink, (response) => {
response.pipe(fs.createWriteStream(`${folder}/${filename}`))
.on('finish', () => {
resolve();
})
.on('error', (error: Error) => {
console.error('Error downloading song:', error);
reject(error);
});
});
});
}
function formatAudioData(arr: any[]) {
return arr.map(item => {
delete item.track.similarTracks;
return item;
});
}
function ensureDirectory(directory: string) {
if (!fs.existsSync(directory)) {
fs.mkdirSync(directory, { recursive: true });
}
}
function checkIfJsonExists(filePath: string) {
return fs.existsSync(filePath);
}

231
package-lock.json generated
View File

@@ -11,8 +11,133 @@
"dependencies": {
"chalk": "^5.2.0",
"dotenv": "^16.0.3"
},
"devDependencies": {
"@types/chalk": "^0.4.31",
"@types/node": "^24.9.1",
"ts-node": "^10.9.2",
"typescript": "^5.9.3"
}
},
"node_modules/@cspotcode/source-map-support": {
"version": "0.8.1",
"resolved": "https://registry.npmjs.org/@cspotcode/source-map-support/-/source-map-support-0.8.1.tgz",
"integrity": "sha512-IchNf6dN4tHoMFIn/7OE8LWZ19Y6q/67Bmf6vnGREv8RSbBVb9LPJxEcnwrcwX6ixSvaiGoomAUvu4YSxXrVgw==",
"dev": true,
"license": "MIT",
"dependencies": {
"@jridgewell/trace-mapping": "0.3.9"
},
"engines": {
"node": ">=12"
}
},
"node_modules/@jridgewell/resolve-uri": {
"version": "3.1.2",
"resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.1.2.tgz",
"integrity": "sha512-bRISgCIjP20/tbWSPWMEi54QVPRZExkuD9lJL+UIxUKtwVJA8wW1Trb1jMs1RFXo1CBTNZ/5hpC9QvmKWdopKw==",
"dev": true,
"license": "MIT",
"engines": {
"node": ">=6.0.0"
}
},
"node_modules/@jridgewell/sourcemap-codec": {
"version": "1.5.5",
"resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.5.5.tgz",
"integrity": "sha512-cYQ9310grqxueWbl+WuIUIaiUaDcj7WOq5fVhEljNVgRfOUhY9fy2zTvfoqWsnebh8Sl70VScFbICvJnLKB0Og==",
"dev": true,
"license": "MIT"
},
"node_modules/@jridgewell/trace-mapping": {
"version": "0.3.9",
"resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.9.tgz",
"integrity": "sha512-3Belt6tdc8bPgAtbcmdtNJlirVoTmEb5e2gC94PnkwEW9jI6CAHUeoG85tjWP5WquqfavoMtMwiG4P926ZKKuQ==",
"dev": true,
"license": "MIT",
"dependencies": {
"@jridgewell/resolve-uri": "^3.0.3",
"@jridgewell/sourcemap-codec": "^1.4.10"
}
},
"node_modules/@tsconfig/node10": {
"version": "1.0.11",
"resolved": "https://registry.npmjs.org/@tsconfig/node10/-/node10-1.0.11.tgz",
"integrity": "sha512-DcRjDCujK/kCk/cUe8Xz8ZSpm8mS3mNNpta+jGCA6USEDfktlNvm1+IuZ9eTcDbNk41BHwpHHeW+N1lKCz4zOw==",
"dev": true,
"license": "MIT"
},
"node_modules/@tsconfig/node12": {
"version": "1.0.11",
"resolved": "https://registry.npmjs.org/@tsconfig/node12/-/node12-1.0.11.tgz",
"integrity": "sha512-cqefuRsh12pWyGsIoBKJA9luFu3mRxCA+ORZvA4ktLSzIuCUtWVxGIuXigEwO5/ywWFMZ2QEGKWvkZG1zDMTag==",
"dev": true,
"license": "MIT"
},
"node_modules/@tsconfig/node14": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/@tsconfig/node14/-/node14-1.0.3.tgz",
"integrity": "sha512-ysT8mhdixWK6Hw3i1V2AeRqZ5WfXg1G43mqoYlM2nc6388Fq5jcXyr5mRsqViLx/GJYdoL0bfXD8nmF+Zn/Iow==",
"dev": true,
"license": "MIT"
},
"node_modules/@tsconfig/node16": {
"version": "1.0.4",
"resolved": "https://registry.npmjs.org/@tsconfig/node16/-/node16-1.0.4.tgz",
"integrity": "sha512-vxhUy4J8lyeyinH7Azl1pdd43GJhZH/tP2weN8TntQblOY+A0XbT8DJk1/oCPuOOyg/Ja757rG0CgHcWC8OfMA==",
"dev": true,
"license": "MIT"
},
"node_modules/@types/chalk": {
"version": "0.4.31",
"resolved": "https://registry.npmjs.org/@types/chalk/-/chalk-0.4.31.tgz",
"integrity": "sha512-nF0fisEPYMIyfrFgabFimsz9Lnuu9MwkNrrlATm2E4E46afKDyeelT+8bXfw1VSc7sLBxMxRgT7PxTC2JcqN4Q==",
"dev": true,
"license": "MIT"
},
"node_modules/@types/node": {
"version": "24.9.1",
"resolved": "https://registry.npmjs.org/@types/node/-/node-24.9.1.tgz",
"integrity": "sha512-QoiaXANRkSXK6p0Duvt56W208du4P9Uye9hWLWgGMDTEoKPhuenzNcC4vGUmrNkiOKTlIrBoyNQYNpSwfEZXSg==",
"dev": true,
"license": "MIT",
"dependencies": {
"undici-types": "~7.16.0"
}
},
"node_modules/acorn": {
"version": "8.15.0",
"resolved": "https://registry.npmjs.org/acorn/-/acorn-8.15.0.tgz",
"integrity": "sha512-NZyJarBfL7nWwIq+FDL6Zp/yHEhePMNnnJ0y3qfieCrmNvYct8uvtiV41UvlSe6apAfk0fY1FbWx+NwfmpvtTg==",
"dev": true,
"license": "MIT",
"bin": {
"acorn": "bin/acorn"
},
"engines": {
"node": ">=0.4.0"
}
},
"node_modules/acorn-walk": {
"version": "8.3.4",
"resolved": "https://registry.npmjs.org/acorn-walk/-/acorn-walk-8.3.4.tgz",
"integrity": "sha512-ueEepnujpqee2o5aIYnvHU6C0A42MNdsIDeqy5BydrkuC5R1ZuUFnm27EeFJGoEHJQgn3uleRvmTXaJgfXbt4g==",
"dev": true,
"license": "MIT",
"dependencies": {
"acorn": "^8.11.0"
},
"engines": {
"node": ">=0.4.0"
}
},
"node_modules/arg": {
"version": "4.1.3",
"resolved": "https://registry.npmjs.org/arg/-/arg-4.1.3.tgz",
"integrity": "sha512-58S9QDqG0Xx27YwPSt9fJxivjYl432YCwfDMfZ+71RAqUrZef7LrKQZ3LHLOwCS4FLNBplP533Zx895SeOCHvA==",
"dev": true,
"license": "MIT"
},
"node_modules/chalk": {
"version": "5.2.0",
"resolved": "https://registry.npmjs.org/chalk/-/chalk-5.2.0.tgz",
@@ -24,6 +149,23 @@
"url": "https://github.com/chalk/chalk?sponsor=1"
}
},
"node_modules/create-require": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/create-require/-/create-require-1.1.1.tgz",
"integrity": "sha512-dcKFX3jn0MpIaXjisoRvexIJVEKzaq7z2rZKxf+MSr9TkdmHmsU4m2lcLojrj/FHl8mk5VxMmYA+ftRkP/3oKQ==",
"dev": true,
"license": "MIT"
},
"node_modules/diff": {
"version": "4.0.2",
"resolved": "https://registry.npmjs.org/diff/-/diff-4.0.2.tgz",
"integrity": "sha512-58lmxKSA4BNyLz+HHMUzlOEpg09FV+ev6ZMe3vJihgdxzgcwZ8VoEEPmALCZG9LmqfVoNMMKpttIYTVG6uDY7A==",
"dev": true,
"license": "BSD-3-Clause",
"engines": {
"node": ">=0.3.1"
}
},
"node_modules/dotenv": {
"version": "16.0.3",
"resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.0.3.tgz",
@@ -31,6 +173,95 @@
"engines": {
"node": ">=12"
}
},
"node_modules/make-error": {
"version": "1.3.6",
"resolved": "https://registry.npmjs.org/make-error/-/make-error-1.3.6.tgz",
"integrity": "sha512-s8UhlNe7vPKomQhC1qFelMokr/Sc3AgNbso3n74mVPA5LTZwkB9NlXf4XPamLxJE8h0gh73rM94xvwRT2CVInw==",
"dev": true,
"license": "ISC"
},
"node_modules/ts-node": {
"version": "10.9.2",
"resolved": "https://registry.npmjs.org/ts-node/-/ts-node-10.9.2.tgz",
"integrity": "sha512-f0FFpIdcHgn8zcPSbf1dRevwt047YMnaiJM3u2w2RewrB+fob/zePZcrOyQoLMMO7aBIddLcQIEK5dYjkLnGrQ==",
"dev": true,
"license": "MIT",
"dependencies": {
"@cspotcode/source-map-support": "^0.8.0",
"@tsconfig/node10": "^1.0.7",
"@tsconfig/node12": "^1.0.7",
"@tsconfig/node14": "^1.0.0",
"@tsconfig/node16": "^1.0.2",
"acorn": "^8.4.1",
"acorn-walk": "^8.1.1",
"arg": "^4.1.0",
"create-require": "^1.1.0",
"diff": "^4.0.1",
"make-error": "^1.1.1",
"v8-compile-cache-lib": "^3.0.1",
"yn": "3.1.1"
},
"bin": {
"ts-node": "dist/bin.js",
"ts-node-cwd": "dist/bin-cwd.js",
"ts-node-esm": "dist/bin-esm.js",
"ts-node-script": "dist/bin-script.js",
"ts-node-transpile-only": "dist/bin-transpile.js",
"ts-script": "dist/bin-script-deprecated.js"
},
"peerDependencies": {
"@swc/core": ">=1.2.50",
"@swc/wasm": ">=1.2.50",
"@types/node": "*",
"typescript": ">=2.7"
},
"peerDependenciesMeta": {
"@swc/core": {
"optional": true
},
"@swc/wasm": {
"optional": true
}
}
},
"node_modules/typescript": {
"version": "5.9.3",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-5.9.3.tgz",
"integrity": "sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw==",
"dev": true,
"license": "Apache-2.0",
"bin": {
"tsc": "bin/tsc",
"tsserver": "bin/tsserver"
},
"engines": {
"node": ">=14.17"
}
},
"node_modules/undici-types": {
"version": "7.16.0",
"resolved": "https://registry.npmjs.org/undici-types/-/undici-types-7.16.0.tgz",
"integrity": "sha512-Zz+aZWSj8LE6zoxD+xrjh4VfkIG8Ya6LvYkZqtUQGJPZjYl53ypCaUwWqo7eI0x66KBGeRo+mlBEkMSeSZ38Nw==",
"dev": true,
"license": "MIT"
},
"node_modules/v8-compile-cache-lib": {
"version": "3.0.1",
"resolved": "https://registry.npmjs.org/v8-compile-cache-lib/-/v8-compile-cache-lib-3.0.1.tgz",
"integrity": "sha512-wa7YjyUGfNZngI/vtK0UHAN+lgDCxBPCylVXGp0zu59Fz5aiGtNXaq3DhIov063MorB+VfufLh3JlF2KdTK3xg==",
"dev": true,
"license": "MIT"
},
"node_modules/yn": {
"version": "3.1.1",
"resolved": "https://registry.npmjs.org/yn/-/yn-3.1.1.tgz",
"integrity": "sha512-Ux4ygGWsu2c7isFWe8Yu1YluJmqVhxqK2cLXNQA5AcC3QfbGNpM7fu0Y8b/z16pXLnFxZYvWhd3fhBY9DLmC6Q==",
"dev": true,
"license": "MIT",
"engines": {
"node": ">=6"
}
}
}
}

View File

@@ -2,9 +2,12 @@
"name": "brainfm-extract",
"version": "1.0.0",
"description": "",
"main": "main.js",
"main": "dist/main.js",
"type": "module",
"scripts": {
"build": "tsc",
"start": "npm run build && node dist/main.js",
"dev": "ts-node main.ts",
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
@@ -13,5 +16,11 @@
"dependencies": {
"chalk": "^5.2.0",
"dotenv": "^16.0.3"
},
"devDependencies": {
"@types/chalk": "^0.4.31",
"@types/node": "^24.9.1",
"ts-node": "^10.9.2",
"typescript": "^5.9.3"
}
}

32
tsconfig.json Normal file
View File

@@ -0,0 +1,32 @@
{
"compilerOptions": {
"target": "ES2024",
"module": "ESNext",
"moduleResolution": "Bundler",
"outDir": "./dist",
"rootDir": "./",
"strict": true,
"esModuleInterop": true,
"skipLibCheck": true,
"forceConsistentCasingInFileNames": true,
"declaration": true,
"declarationMap": true,
"sourceMap": true,
"removeComments": false,
"noImplicitAny": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"noImplicitReturns": true,
"noImplicitOverride": true,
"noUnusedLocals": true,
"noUnusedParameters": true
},
"include": [
"./**/*.ts"
],
"exclude": [
"node_modules",
"dist",
"**/node_modules/*"
]
}