diff --git a/backend/services/youtube.py b/backend/services/youtube.py index eba6cc0..5307390 100644 --- a/backend/services/youtube.py +++ b/backend/services/youtube.py @@ -276,16 +276,97 @@ class YouTubeService: # We'll use get_charts "trending" for "Trending" category # And maybe "Top Songs" for "Top Hits" + # 1. Trending (from Charts) + trending_playlist = { + "id": "trending", + "title": "Trending Now", + "description": "Top music videos right now", + "cover_url": trending_songs[0]['cover_url'] if trending_songs else "", + "tracks": trending_songs, + "type": "Playlist", + "creator": "YouTube Charts" + } + + # 2. Top Hits (Simulated via search) + # We'll fetch a few "standard" playlists or results to populate the home page + # This makes the app feel "alive" even without user history + + async def get_search_shelf(query, title): + try: + res = self.search(query) + if res and 'tracks' in res: + return { + "id": f"shelf_{query}", + "title": title, + "description": f"Best of {title}", + "cover_url": res['tracks'][0]['cover_url'] if res['tracks'] else "", + "tracks": res['tracks'], + "type": "Playlist", + "creator": "Spotify Clone" + } + except: + return None + + # Since this is synchronous, we'll do simple searches or use cached results + # For speed, we might want to hardcode IDs of popular playlists in the future + # But for now, let's just reuse the trending videos for a "Top Hits" section to fill space + # and maybe shuffle them or pick different slice + + import random + top_hits_tracks = list(trending_songs) + if len(top_hits_tracks) > 5: + random.shuffle(top_hits_tracks) + + top_hits_playlist = { + "id": "top_hits", + "title": "Top Hits Today", + "description": "The hottest tracks right now.", + "cover_url": top_hits_tracks[0]['cover_url'] if top_hits_tracks else "", + "tracks": top_hits_tracks, + "type": "Playlist", + "creator": "Editors" + } + + # 3. New Releases (Simulated) + new_releases_tracks = list(trending_songs) + if len(new_releases_tracks) > 2: + # Just rotate them to look different + new_releases_tracks = new_releases_tracks[2:] + new_releases_tracks[:2] + + new_releases_playlist = { + "id": "new_releases", + "title": "New Releases", + "description": "Brand new music found for you.", + "cover_url": new_releases_tracks[0]['cover_url'] if new_releases_tracks else "", + "tracks": new_releases_tracks, + "type": "Playlist", + "creator": "Spotify Clone" + } + response = { - "Trending": [{ - "id": "trending", - "title": "Trending Now", - "description": "Top music videos right now", - "cover_url": trending_songs[0]['cover_url'] if trending_songs else "", - "tracks": trending_songs, - "type": "Playlist", - "creator": "YouTube Charts" - }] + "Trending": [trending_playlist], + "Top Hits": [top_hits_playlist], + "New Releases": [new_releases_playlist], + "Focus & Chill": [ + { + "id": "lofi_beats", + "title": "Lofi Beats", + "description": "Chill beats to study/relax to", + "cover_url": "https://i.ytimg.com/vi/jfKfPfyJRdk/hqdefault.jpg", + "tracks": [], # Empty tracks will force a fetch when clicked if handled + "type": "Playlist", + "creator": "Lofi Girl" + }, + { + "id": "jazz_vibes", + "title": "Jazz Vibes", + "description": "Relaxing Jazz instrumental", + "cover_url": "https://i.ytimg.com/vi/DX7W7WUI6w8/hqdefault.jpg", + "tracks": [], + "type": "Playlist", + "creator": "Jazz Cafe" + } + ] } self.cache.set(cache_key, response, ttl_seconds=3600) diff --git a/docker-compose.yml b/docker-compose.yml index 3ba9c92..73dc99b 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -9,11 +9,3 @@ services: volumes: - ./data:/app/backend/data - - watchtower: - image: containrrr/watchtower - container_name: watchtower - volumes: - - /var/run/docker.sock:/var/run/docker.sock - command: --interval 3600 --cleanup --label-enable=false spotify-clone # Checks every hour for 'spotify-clone' container - restart: always diff --git a/frontend/app/library/page.tsx b/frontend/app/library/page.tsx index c2b04c5..0b3b8f1 100644 --- a/frontend/app/library/page.tsx +++ b/frontend/app/library/page.tsx @@ -76,7 +76,7 @@ export default function LibraryPage() { {playlists.map((playlist) => (
Playlist • You
+Playlist • You
Playlist • Made for you
+Playlist • Made for you
Artist
+Artist
Album • {album.creator || 'Spotify'}
+Album • {album.creator || 'Spotify'}
{playlist.description}
+{playlist.description}
{track.artist}
+{track.artist}
{album.description}
+{album.description}