Spaces:
Sleeping
Sleeping
Nikita Makarov commited on
Commit ·
fab1b17
1
Parent(s): 1508c5e
Replace all YouTube searches with Modal proxy as primary method
Browse files
src/mcp_servers/music_server.py
CHANGED
|
@@ -706,8 +706,11 @@ class MusicMCPServer:
|
|
| 706 |
|
| 707 |
print(f"🔍 Searching for music: '{query}'")
|
| 708 |
|
| 709 |
-
# Try
|
| 710 |
-
tracks = self.
|
|
|
|
|
|
|
|
|
|
| 711 |
|
| 712 |
if tracks:
|
| 713 |
# Preserve custom genre in track metadata
|
|
@@ -733,7 +736,11 @@ class MusicMCPServer:
|
|
| 733 |
print("⚠️ Both searches failed, trying simplified query...")
|
| 734 |
if song_request.get("song"):
|
| 735 |
simple_query = song_request["song"]
|
| 736 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 737 |
if tracks:
|
| 738 |
if song_request.get("genre"):
|
| 739 |
for track in tracks:
|
|
|
|
| 706 |
|
| 707 |
print(f"🔍 Searching for music: '{query}'")
|
| 708 |
|
| 709 |
+
# Try Modal proxy first (works in restricted networks like HF Spaces)
|
| 710 |
+
tracks = self.search_youtube_via_modal_proxy(query, limit=1)
|
| 711 |
+
if not tracks:
|
| 712 |
+
# Fallback to direct YouTube search (won't work in HF Spaces but kept for local testing)
|
| 713 |
+
tracks = self.search_youtube_music(query, limit=1, fast=True)
|
| 714 |
|
| 715 |
if tracks:
|
| 716 |
# Preserve custom genre in track metadata
|
|
|
|
| 736 |
print("⚠️ Both searches failed, trying simplified query...")
|
| 737 |
if song_request.get("song"):
|
| 738 |
simple_query = song_request["song"]
|
| 739 |
+
# Try Modal proxy first
|
| 740 |
+
tracks = self.search_youtube_via_modal_proxy(simple_query, limit=1)
|
| 741 |
+
if not tracks:
|
| 742 |
+
# Fallback to direct YouTube search
|
| 743 |
+
tracks = self.search_youtube_music(simple_query, limit=1, fast=True)
|
| 744 |
if tracks:
|
| 745 |
if song_request.get("genre"):
|
| 746 |
for track in tracks:
|