Spaces:
Sleeping
Sleeping
Nikita Makarov commited on
Commit ·
6abfc0f
1
Parent(s): 675eb61
Add search_youtube_via_modal_proxy method back
Browse files
src/mcp_servers/music_server.py
CHANGED
|
@@ -132,7 +132,33 @@ class MusicMCPServer:
|
|
| 132 |
print(f"⚠️ Video {video_id}: check failed - {e}")
|
| 133 |
self._embed_cache[video_id] = False
|
| 134 |
return False
|
| 135 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 136 |
def search_youtube_via_api(self, query: str, limit: int = 5) -> List[Dict[str, Any]]:
|
| 137 |
"""Search YouTube using official Data API v3 (works in restricted networks)"""
|
| 138 |
# This method uses HTTPS API instead of yt-dlp, which should work in HF Spaces
|
|
|
|
| 132 |
print(f"⚠️ Video {video_id}: check failed - {e}")
|
| 133 |
self._embed_cache[video_id] = False
|
| 134 |
return False
|
| 135 |
+
|
| 136 |
+
def search_youtube_via_modal_proxy(self, query: str, limit: int = 5) -> List[Dict[str, Any]]:
|
| 137 |
+
"""Search YouTube using Modal proxy (bypasses all network restrictions)"""
|
| 138 |
+
tracks = []
|
| 139 |
+
|
| 140 |
+
try:
|
| 141 |
+
# Use Modal proxy endpoint
|
| 142 |
+
modal_url = "https://nikitaxmakarov--youtube-search.modal.run"
|
| 143 |
+
params = {
|
| 144 |
+
'query': f"{query} music",
|
| 145 |
+
'limit': limit
|
| 146 |
+
}
|
| 147 |
+
|
| 148 |
+
response = requests.get(modal_url, params=params, timeout=30)
|
| 149 |
+
response.raise_for_status()
|
| 150 |
+
data = response.json()
|
| 151 |
+
|
| 152 |
+
if data.get('success') and 'tracks' in data:
|
| 153 |
+
tracks = data['tracks']
|
| 154 |
+
for track in tracks:
|
| 155 |
+
print(f" ✓ Found via Modal proxy: {track['title']} by {track['artist']}")
|
| 156 |
+
|
| 157 |
+
except Exception as e:
|
| 158 |
+
print(f"⚠️ Modal proxy search failed: {e}")
|
| 159 |
+
|
| 160 |
+
return tracks
|
| 161 |
+
|
| 162 |
def search_youtube_via_api(self, query: str, limit: int = 5) -> List[Dict[str, Any]]:
|
| 163 |
"""Search YouTube using official Data API v3 (works in restricted networks)"""
|
| 164 |
# This method uses HTTPS API instead of yt-dlp, which should work in HF Spaces
|