Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,6 +1,7 @@
|
|
| 1 |
import os
|
| 2 |
import requests
|
| 3 |
import pandas as pd
|
|
|
|
| 4 |
|
| 5 |
# ββββββ PARCHE Pydantic para FastAPI ββββββ
|
| 6 |
import pydantic
|
|
@@ -98,14 +99,20 @@ def fetch_playlist_table(url):
|
|
| 98 |
|
| 99 |
def main(url):
|
| 100 |
df = fetch_playlist_table(url)
|
| 101 |
-
|
|
|
|
|
|
|
|
|
|
| 102 |
|
| 103 |
iface = gr.Interface(
|
| 104 |
fn=main,
|
| 105 |
inputs=gr.Textbox(label="URL de playlist"),
|
| 106 |
-
outputs=
|
|
|
|
|
|
|
|
|
|
| 107 |
title="π΅ Tabla de Playlist Spotify",
|
| 108 |
-
description="Trae Artist, Title, ISRC, URL, URI y GΓ©neros de cada track"
|
| 109 |
)
|
| 110 |
|
| 111 |
if __name__ == '__main__':
|
|
|
|
| 1 |
import os
|
| 2 |
import requests
|
| 3 |
import pandas as pd
|
| 4 |
+
import tempfile
|
| 5 |
|
| 6 |
# ββββββ PARCHE Pydantic para FastAPI ββββββ
|
| 7 |
import pydantic
|
|
|
|
| 99 |
|
| 100 |
def main(url):
|
| 101 |
df = fetch_playlist_table(url)
|
| 102 |
+
# Guardar CSV temporalmente
|
| 103 |
+
tmp = tempfile.NamedTemporaryFile(delete=False, suffix=".csv")
|
| 104 |
+
df.to_csv(tmp.name, index=False)
|
| 105 |
+
return df, tmp.name
|
| 106 |
|
| 107 |
iface = gr.Interface(
|
| 108 |
fn=main,
|
| 109 |
inputs=gr.Textbox(label="URL de playlist"),
|
| 110 |
+
outputs=[
|
| 111 |
+
gr.Dataframe(headers=['Artist','Title','ISRC','URL','URI','Genres'], label="Tabla"),
|
| 112 |
+
gr.File(label="Descargar CSV")
|
| 113 |
+
],
|
| 114 |
title="π΅ Tabla de Playlist Spotify",
|
| 115 |
+
description="Trae Artist, Title, ISRC, URL, URI y GΓ©neros de cada track y permite descargar CSV"
|
| 116 |
)
|
| 117 |
|
| 118 |
if __name__ == '__main__':
|