Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -3,6 +3,7 @@ import requests
|
|
| 3 |
import pandas as pd
|
| 4 |
from tempfile import NamedTemporaryFile
|
| 5 |
from openpyxl import Workbook
|
|
|
|
| 6 |
|
| 7 |
# Lista de credenciales de API de Spotify
|
| 8 |
client_ids = ['b4a2add66ffb4f1198b94b087b365c65', '9df51caba5d247dc921b21de35a47c44']
|
|
@@ -164,9 +165,15 @@ def interface(project_name, query, num_spotify_playlists=50):
|
|
| 164 |
# Ordenar por popularidad
|
| 165 |
df.sort_values(by=['popularity'], ascending=False, inplace=True)
|
| 166 |
|
| 167 |
-
|
| 168 |
-
|
| 169 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 170 |
|
| 171 |
# Configuraci贸n de Gradio
|
| 172 |
iface = gr.Interface(
|
|
@@ -181,5 +188,3 @@ iface = gr.Interface(
|
|
| 181 |
description="Enter a search query to fetch playlists and their songs from Spotify. Client credentials are pre-configured."
|
| 182 |
)
|
| 183 |
iface.launch()
|
| 184 |
-
|
| 185 |
-
|
|
|
|
| 3 |
import pandas as pd
|
| 4 |
from tempfile import NamedTemporaryFile
|
| 5 |
from openpyxl import Workbook
|
| 6 |
+
import shutil
|
| 7 |
|
| 8 |
# Lista de credenciales de API de Spotify
|
| 9 |
client_ids = ['b4a2add66ffb4f1198b94b087b365c65', '9df51caba5d247dc921b21de35a47c44']
|
|
|
|
| 165 |
# Ordenar por popularidad
|
| 166 |
df.sort_values(by=['popularity'], ascending=False, inplace=True)
|
| 167 |
|
| 168 |
+
# Guardar DataFrame en un archivo Excel
|
| 169 |
+
tmpfile = NamedTemporaryFile(delete=False, suffix='.xlsx')
|
| 170 |
+
df.to_excel(tmpfile.name, index=False)
|
| 171 |
+
|
| 172 |
+
# Renombrar el archivo con el nombre del proyecto
|
| 173 |
+
project_file_name = f"{project_name}.xlsx"
|
| 174 |
+
shutil.move(tmpfile.name, project_file_name)
|
| 175 |
+
|
| 176 |
+
return df, project_file_name # Devuelve el DataFrame y el enlace al archivo Excel
|
| 177 |
|
| 178 |
# Configuraci贸n de Gradio
|
| 179 |
iface = gr.Interface(
|
|
|
|
| 188 |
description="Enter a search query to fetch playlists and their songs from Spotify. Client credentials are pre-configured."
|
| 189 |
)
|
| 190 |
iface.launch()
|
|
|
|
|
|