Chrunos commited on
Commit
0b7f6c9
·
verified ·
1 Parent(s): 33eac3d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +20 -1
app.py CHANGED
@@ -225,6 +225,23 @@ def get_cookie():
225
  print(f"Error getting cookie: {e}")
226
  return None
227
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
228
 
229
  def get_data(track_id):
230
  link = f"https://open.spotify.com/track/{track_id}"
@@ -241,7 +258,9 @@ def get_data(track_id):
241
 
242
 
243
  def get_url(track_data, cookie):
244
- url = 'https://spotisongdownloader.to/api/composer/spotify/wertyuht3456.php'
 
 
245
 
246
  payload = {
247
  'song_name': track_data['song_name'],
 
225
  print(f"Error getting cookie: {e}")
226
  return None
227
 
228
+ def get_api():
229
+ headers = {
230
+ 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/133.0.0.0 Safari/537.36'
231
+ }
232
+
233
+ try:
234
+ response = requests.get('https://spotisongdownloader.to/track.php', headers=headers)
235
+ response.raise_for_status()
236
+
237
+ match = re.search(r'url:\s*"(/api/composer/spotify/[^"]+)"', response.text)
238
+ if match:
239
+ api_endpoint = match.group(1)
240
+ return f"https://spotisongdownloader.to{api_endpoint}"
241
+
242
+ except requests.exceptions.RequestException:
243
+ return None
244
+
245
 
246
  def get_data(track_id):
247
  link = f"https://open.spotify.com/track/{track_id}"
 
258
 
259
 
260
  def get_url(track_data, cookie):
261
+ url = get_api()
262
+ if not url:
263
+ return None
264
 
265
  payload = {
266
  'song_name': track_data['song_name'],