Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,16 +1,32 @@
|
|
| 1 |
import os
|
| 2 |
import requests
|
| 3 |
import pandas as pd
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4 |
import gradio as gr
|
| 5 |
from tempfile import NamedTemporaryFile
|
| 6 |
|
| 7 |
-
#
|
| 8 |
-
# Config Spotify (Client Credentials)
|
| 9 |
-
# βββββββββββββ
|
| 10 |
CLIENT_ID = os.getenv("SPOTIFY_CLIENT_IDS", "").split(',')[0]
|
| 11 |
CLIENT_SECRET = os.getenv("SPOTIFY_CLIENT_SECRETS", "").split(',')[0]
|
| 12 |
|
| 13 |
# FunciΓ³n para obtener token
|
|
|
|
| 14 |
def get_token():
|
| 15 |
resp = requests.post(
|
| 16 |
"https://accounts.spotify.com/api/token",
|
|
@@ -21,6 +37,7 @@ def get_token():
|
|
| 21 |
return resp.json()["access_token"]
|
| 22 |
|
| 23 |
# Extrae el ID de playlist de la URL
|
|
|
|
| 24 |
def extract_pid(url):
|
| 25 |
return url.strip().rstrip('/').split('/')[-1].split('?')[0]
|
| 26 |
|
|
@@ -78,7 +95,6 @@ def fetch_playlist_table(url):
|
|
| 78 |
return df
|
| 79 |
|
| 80 |
# Interfaz Gradio
|
| 81 |
-
|
| 82 |
def main(url):
|
| 83 |
df = fetch_playlist_table(url)
|
| 84 |
# Guarda CSV temporal
|
|
|
|
| 1 |
import os
|
| 2 |
import requests
|
| 3 |
import pandas as pd
|
| 4 |
+
|
| 5 |
+
# ββββββ PARCHE Pydantic para FastAPI ββββββ
|
| 6 |
+
import pydantic
|
| 7 |
+
pydantic.Schema = pydantic.Field
|
| 8 |
+
|
| 9 |
+
# ββββββ PARCHE GRADIO_CLIENT BOOLEANS ββββββ
|
| 10 |
+
import gradio_client.utils as client_utils
|
| 11 |
+
_orig_get_type = client_utils.get_type
|
| 12 |
+
|
| 13 |
+
def patched_get_type(schema):
|
| 14 |
+
if not isinstance(schema, dict):
|
| 15 |
+
return "Any"
|
| 16 |
+
return _orig_get_type(schema)
|
| 17 |
+
|
| 18 |
+
client_utils.get_type = patched_get_type
|
| 19 |
+
# ββββββββββββββββββββββββββββββββ
|
| 20 |
+
|
| 21 |
import gradio as gr
|
| 22 |
from tempfile import NamedTemporaryFile
|
| 23 |
|
| 24 |
+
# ConfiguraciΓ³n Spotify (Client Credentials)
|
|
|
|
|
|
|
| 25 |
CLIENT_ID = os.getenv("SPOTIFY_CLIENT_IDS", "").split(',')[0]
|
| 26 |
CLIENT_SECRET = os.getenv("SPOTIFY_CLIENT_SECRETS", "").split(',')[0]
|
| 27 |
|
| 28 |
# FunciΓ³n para obtener token
|
| 29 |
+
|
| 30 |
def get_token():
|
| 31 |
resp = requests.post(
|
| 32 |
"https://accounts.spotify.com/api/token",
|
|
|
|
| 37 |
return resp.json()["access_token"]
|
| 38 |
|
| 39 |
# Extrae el ID de playlist de la URL
|
| 40 |
+
|
| 41 |
def extract_pid(url):
|
| 42 |
return url.strip().rstrip('/').split('/')[-1].split('?')[0]
|
| 43 |
|
|
|
|
| 95 |
return df
|
| 96 |
|
| 97 |
# Interfaz Gradio
|
|
|
|
| 98 |
def main(url):
|
| 99 |
df = fetch_playlist_table(url)
|
| 100 |
# Guarda CSV temporal
|