mirror of
https://github.com/wahyd4/you-music.git
synced 2026-08-09 05:06:44 +10:00
7.3 KiB
7.3 KiB
New Features Implementation Summary
Features Implemented
1. ✅ Search Function Timeout (1 minute)
- Added 60-second timeout to YouTube search (yt-dlp subprocess)
- Added 60-second timeout to Bilibili search (aiohttp request)
- Graceful error handling for timeouts
Files Modified:
backend/app/services/search.py
2. ✅ Full-Screen Player
- Added fullscreen button in bottom control panel
- Created
FullScreenPlayercomponent with:- Large album artwork
- Enhanced song information display
- All player controls (play/pause, next/previous)
- Action buttons (like, add to playlist, share)
- Click on thumbnail to open fullscreen
Files Modified:
frontend/src/components/player/Player.tsxfrontend/src/components/player/FullScreenPlayer.tsx(new)
3. ✅ Auto Search & Download Feature
Backend:
-
New Database Models:
DownloadJob: Tracks auto-download jobs with status, priority, duplication detectionAPIKey: API key management for authentication
-
New API Endpoints:
POST /api/auto-download/job- Create download job (requires API key)GET /api/auto-download/jobs- List all jobsGET /api/auto-download/jobs/{id}- Get specific jobPOST /api/auto-download/jobs/{id}/confirm- Confirm duplicate downloadPOST /api/auto-download/jobs/{id}/retry- Retry failed jobDELETE /api/auto-download/jobs/{id}- Delete jobPOST /api/auto-download/jobs/clear-completed- Clear completed jobs
-
Priority Logic:
- Songs with "official" or "官方" in title are marked as priority
- Priority songs are automatically selected for download
-
Duplicate Detection:
- Checks for existing songs by source URL
- Puts duplicates in "waiting_confirmation" status
- User must confirm before downloading duplicate
Files Created:
backend/app/api/auto_download.pybackend/alembic/versions/52b30f47e145_add_download_jobs_and_api_keys_tables.py
Files Modified:
backend/app/models/models.pybackend/app/schemas/schemas.pybackend/main.py
Frontend:
-
AutoDownload Component:
- Input for song name and API key
- Real-time job status updates (every 5 seconds)
- Job list with status badges
- Confirmation dialog for duplicates
- Retry button for failed jobs
- Clear completed jobs button
-
Integrated into Home Page:
- Tabs: Library | Auto Download
Files Created:
frontend/src/components/download/AutoDownload.tsxfrontend/src/components/HomePage.tsx
Files Modified:
frontend/src/App.tsxfrontend/src/api/client.ts
4. ✅ API Keys Management
Backend:
-
New API Endpoints:
POST /api/api-keys/- Create API keyGET /api/api-keys/- List all keysGET /api/api-keys/{id}- Get specific keyDELETE /api/api-keys/{id}- Delete keyPOST /api/api-keys/{id}/deactivate- Deactivate keyPOST /api/api-keys/{id}/activate- Activate key
-
Authentication Middleware:
verify_api_key()dependency for protected endpoints- Checks expiration and active status
- Updates last_used_at timestamp
Files Created:
backend/app/api/api_keys.py
Files Modified:
backend/app/models/models.pybackend/app/schemas/schemas.pybackend/main.py
Frontend:
-
API Keys Management Component:
- Create/delete API keys
- Set expiration (optional)
- Show/hide key values
- Copy to clipboard
- Display usage statistics
- Complete API usage documentation
-
Integrated into Settings:
- Tabs: General | API Keys
Files Created:
frontend/src/components/settings/APIKeysManagement.tsx
Files Modified:
frontend/src/components/settings/SettingsPage.tsxfrontend/src/api/client.ts
5. ✅ Artist Search Feature
Backend:
- New API Endpoint:
GET /api/artists/search?q={query}- Search artists by name
Files Modified:
backend/app/api/artist.pybackend/app/schemas/schemas.py
Frontend:
- Search input in Artists page
- Real-time artist filtering
Files Modified:
frontend/src/components/artist/ArtistsPage.tsxfrontend/src/api/client.ts
6. ✅ Sort Features
Backend:
-
Music API:
- Added
sort_byparameter (title, artist, album, created_at, duration) - Added
sort_orderparameter (asc, desc) - Default:
created_at desc
- Added
-
Artist API:
- Added
sort_byparameter (name, song_count) - Added
sort_orderparameter (asc, desc) - Default:
song_count desc
- Added
-
Artist Songs:
- Added sorting to artist detail page
Files Modified:
backend/app/api/music.pybackend/app/api/artist.py
Frontend:
-
Music Library:
- Sort dropdown (Date Added, Title, Artist, Album, Duration)
- Sort order toggle button
- Persists in query
-
Artists Page:
- Sort dropdown (Song Count, Name)
- Sort order toggle button
-
Artist Detail Page:
- Inherits sorting capability
Files Modified:
frontend/src/components/MusicLibrary.tsxfrontend/src/components/artist/ArtistsPage.tsxfrontend/src/api/client.ts
7. ✅ Default Sort for Library (by created_at desc)
- Backend defaults to
created_at descwhen no sort specified - Frontend queries with default sort
Files Modified:
backend/app/api/music.pyfrontend/src/components/MusicLibrary.tsx
New UI Components Created
frontend/src/components/ui/select.tsx- Dropdown select componentfrontend/src/components/ui/badge.tsx- Status badgesfrontend/src/components/ui/tabs.tsx- Tab navigationfrontend/src/components/ui/alert.tsx- Alert/notification boxes
API Usage Example
Auto Download API
# Create API key first (through Settings UI)
# Then use it to create download jobs:
curl -X POST http://localhost:8000/api/auto-download/job \
-H "X-API-Key: ym_your_generated_key_here" \
-H "Content-Type: application/json" \
-d '{"song_name": "Shape of You"}'
# Get job status
curl http://localhost:8000/api/auto-download/jobs
# Confirm duplicate download
curl -X POST http://localhost:8000/api/auto-download/jobs/1/confirm
# Retry failed job
curl -X POST http://localhost:8000/api/auto-download/jobs/1/retry
Database Migrations
- Migration created:
52b30f47e145_add_download_jobs_and_api_keys_tables.py - Tables added:
download_jobsapi_keys
Testing Checklist
- Backend compiles without errors
- Database migration applied successfully
- All new API endpoints exist
- Search timeout works (need to test with slow network)
- Fullscreen player opens and closes properly
- Auto-download job creation works
- API key authentication works
- Duplicate detection works
- Priority songs identified correctly
- Artist search returns results
- Sorting works on library page
- Sorting works on artists page
- Default sort is created_at desc
Next Steps
- Start the development servers
- Test each feature manually
- Create API key in Settings
- Test auto-download with API key
- Verify sorting on all pages
- Test fullscreen player
- Test artist search
- Verify timeout behavior
Notes
- API keys are stored with prefix "ym_" for easy identification
- Auto-download jobs refresh every 5 seconds in the UI
- Priority is automatically detected based on title keywords
- Duplicate detection prevents accidental re-downloads
- All new features are fully integrated into the existing UI