Mthrfkr commited on
Commit
8c52824
Β·
verified Β·
1 Parent(s): c4ec079

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -3
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
- return df
 
 
 
102
 
103
  iface = gr.Interface(
104
  fn=main,
105
  inputs=gr.Textbox(label="URL de playlist"),
106
- outputs=gr.Dataframe(headers=['Artist','Title','ISRC','URL','URI','Genres']),
 
 
 
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__':