Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions example.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#!/usr/bin/env python3
"""
Example: Using the improved UdioWrapper (v0.0.4).
Fixes the 500 error from Issue #7.
"""

import logging
import sys

from udio_wrapper import UdioWrapper

logging.basicConfig(
level=logging.INFO,
format="%(asctime)s [%(levelname)s] %(message)s",
datefmt="%H:%M:%S",
)

AUTH_TOKEN = "YOUR_SB-API-AUTH-TOKEN" # Get from Udio cookies

# Fix #1: use_cloudscraper=True bypasses Cloudflare if Udio added it
# Fix #2: retries on 500/502/503/504 with exponential backoff
# Fix #3: fixed malformed Cookie header (was "; sb-api-auth-token" → "sb-api-auth-token")
# Fix #4: proper error logging that shows Udio's response body
wrapper = UdioWrapper(
auth_token=AUTH_TOKEN,
timeout=90,
max_retries=3,
use_cloudscraper=False, # set True if you install cloudscraper
)

# Quick health check — verify the session works
print("Generating song...")
result = wrapper.create_song(
prompt="A relaxing jazz melody with piano",
seed=-1,
)
if result:
print(f"Success! Generated {len(result)} song(s):")
for song in result:
print(f" - {song['title']} -> {song['song_path']}")
else:
print("Failed. Enable DEBUG logging to see Udio's error response:")
print(" logging.getLogger().setLevel(logging.DEBUG)")
sys.exit(1)
3 changes: 2 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
requests==2.31.0
requests>=2.31.0
urllib3>=1.26.0
14 changes: 9 additions & 5 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
from setuptools import setup, find_packages

with open("requirements.txt", "r") as f:
requirements = f.read().splitlines()
requirements = [l.strip() for l in f if l.strip() and not l.startswith("#")]

setup(
name='udio_wrapper',
version='0.0.1',
description='Generates songs using the Udio API using textual prompts.',
author='Flowese',
name="udio_wrapper",
version="0.0.4",
description="Generates songs using the Udio API using textual prompts.",
author="Flowese",
packages=find_packages(),
install_requires=requirements,
extras_require={
"cloudscraper": ["cloudscraper>=1.2.0"],
},
python_requires=">=3.8",
)
Loading