Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -19,6 +19,7 @@ client_utils.get_type = patched_get_type
|
|
| 19 |
# ββββββββββββββββββββββββββββββββ
|
| 20 |
|
| 21 |
import gradio as gr
|
|
|
|
| 22 |
|
| 23 |
# ConfiguraciΓ³n Spotify (Client Credentials)
|
| 24 |
CLIENT_ID = os.getenv("SPOTIFY_CLIENT_IDS", "").split(',')[0]
|
|
@@ -91,17 +92,25 @@ def fetch_playlist_table(url):
|
|
| 91 |
df = pd.DataFrame(records)
|
| 92 |
return df
|
| 93 |
|
| 94 |
-
# FunciΓ³n principal: retorna DataFrame
|
| 95 |
def main(url):
|
| 96 |
-
|
| 97 |
-
|
| 98 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 99 |
iface = gr.Interface(
|
| 100 |
fn=main,
|
| 101 |
inputs=gr.Textbox(label="URL de playlist", placeholder="https://open.spotify.com/playlist/..."),
|
| 102 |
-
outputs=
|
|
|
|
|
|
|
|
|
|
| 103 |
title="π΅ Tabla de Playlist Spotify",
|
| 104 |
-
description="Trae Artist, Title, ISRC, URL, URI y GΓ©neros de cada track"
|
| 105 |
)
|
| 106 |
|
| 107 |
if __name__ == '__main__':
|
|
|
|
| 19 |
# ββββββββββββββββββββββββββββββββ
|
| 20 |
|
| 21 |
import gradio as gr
|
| 22 |
+
from io import BytesIO
|
| 23 |
|
| 24 |
# ConfiguraciΓ³n Spotify (Client Credentials)
|
| 25 |
CLIENT_ID = os.getenv("SPOTIFY_CLIENT_IDS", "").split(',')[0]
|
|
|
|
| 92 |
df = pd.DataFrame(records)
|
| 93 |
return df
|
| 94 |
|
| 95 |
+
# FunciΓ³n principal: retorna DataFrame y CSV en memoria
|
| 96 |
def main(url):
|
| 97 |
+
df = fetch_playlist_table(url)
|
| 98 |
+
# Convertir DataFrame a CSV en memoria
|
| 99 |
+
csv_buffer = BytesIO()
|
| 100 |
+
df.to_csv(csv_buffer, index=False)
|
| 101 |
+
csv_bytes = csv_buffer.getvalue()
|
| 102 |
+
return df, ('playlist.csv', csv_bytes)
|
| 103 |
+
|
| 104 |
+
# Interfaz Gradio con gr.Download
|
| 105 |
iface = gr.Interface(
|
| 106 |
fn=main,
|
| 107 |
inputs=gr.Textbox(label="URL de playlist", placeholder="https://open.spotify.com/playlist/..."),
|
| 108 |
+
outputs=[
|
| 109 |
+
gr.Dataframe(headers=['Artist','Title','ISRC','URL','URI','Genres'], label="Tabla de Playlist Spotify"),
|
| 110 |
+
gr.Download(label="Descargar CSV")
|
| 111 |
+
],
|
| 112 |
title="π΅ Tabla de Playlist Spotify",
|
| 113 |
+
description="Trae Artist, Title, ISRC, URL, URI y GΓ©neros de cada track y permite descargar CSV sin usar disco"
|
| 114 |
)
|
| 115 |
|
| 116 |
if __name__ == '__main__':
|