diff --git a/.serena/cache/typescript/document_symbols_cache_v23-06-25.pkl b/.serena/cache/typescript/document_symbols_cache_v23-06-25.pkl index 7abe452..3ea53dc 100644 Binary files a/.serena/cache/typescript/document_symbols_cache_v23-06-25.pkl and b/.serena/cache/typescript/document_symbols_cache_v23-06-25.pkl differ diff --git a/.serena/memories/audio_filename_improvements.md b/.serena/memories/audio_filename_improvements.md new file mode 100644 index 0000000..1440457 --- /dev/null +++ b/.serena/memories/audio_filename_improvements.md @@ -0,0 +1,22 @@ +# Audio File Naming and Caption Improvements + +## Changes Made + +### 1. Frontend (public/script.ts) +- Added `performer` field to `/api/convert` request +- Now sends artist name along with title and other metadata + +### 2. Backend (src/server.ts) +- Updated `/api/convert` endpoint to accept `performer` parameter +- Modified filename generation to include artist name: + - Format: `{artist} - {title}.mp3` (when artist available) + - Fallback: `{title}.mp3` (when no artist) + - Limited artist name to 20 chars, title to 30 chars for safe filenames + +### 3. Bot (src/bot.ts) +- Removed "🎵 ..." text from audio message captions +- Changed `caption: \`🎵 ${title}\`` to `caption: undefined` +- Audio files now show clean filename without emoji prefix + +## Result +Audio files now have proper names like "Artist Name - Song Title.mp3" and no caption text, making them cleaner in Telegram chats. \ No newline at end of file diff --git a/public/script.ts b/public/script.ts index bed14b0..f6a56f6 100644 --- a/public/script.ts +++ b/public/script.ts @@ -283,6 +283,7 @@ class QuixoticApp { videoId, title, url, + performer, userId: this.tg?.initDataUnsafe?.user?.id || 'demo' }) }); diff --git a/src/bot.ts b/src/bot.ts index 46a7b45..89be03e 100644 --- a/src/bot.ts +++ b/src/bot.ts @@ -263,7 +263,7 @@ export class QuixoticBot { await this.bot.sendAudio(chatId, audioUrl, { title: title, performer: performer || 'SoundCloud', - caption: `🎵 ${title}`, + caption: undefined, thumbnail: thumbnail, parse_mode: undefined }); @@ -274,7 +274,7 @@ export class QuixoticBot { // Fallback: try as document try { await this.bot.sendDocument(chatId, audioUrl, { - caption: `🎵 ${title}`, + caption: undefined, parse_mode: undefined }); console.log(`✅ Document sent: ${title}`); diff --git a/src/server.ts b/src/server.ts index 416f0a5..04c54ff 100644 --- a/src/server.ts +++ b/src/server.ts @@ -90,7 +90,7 @@ app.post('/api/search', async (req: Request, res: Response) => { // Convert video to MP3 app.post('/api/convert', async (req: Request, res: Response) => { try { - const { videoId, title, userId, url }: { videoId?: string; title?: string; userId?: string; url?: string } = req.body; + const { videoId, title, userId, url, performer }: { videoId?: string; title?: string; userId?: string; url?: string; performer?: string } = req.body; console.log('Convert request received:', { videoId, title, userId }); if (!videoId) { @@ -99,7 +99,8 @@ app.post('/api/convert', async (req: Request, res: Response) => { // Generate safe filename const safeTitle = (title || '').replace(/[^\w\s-]/g, '').replace(/\s+/g, '_').substring(0, 50); - const filename = `${videoId}_${safeTitle}.mp3`; + const safePerformer = (performer || '').replace(/[^\w\s-]/g, '').replace(/\s+/g, '_').substring(0, 20); + const filename = safePerformer ? `${safePerformer} - ${safeTitle}.mp3` : `${safeTitle}.mp3`; const outputPath = path.join(downloadsDir, filename); // Check if file already exists