**Task ID:** `{task_id}`
**Title:** {title}
**Time:** {receipt['generated']}
**Proof:** `{receipt['proof']['proof'][:32]}...`
> 💾 **Save these receipts!** They prove you created this song request.
---
"""
else:
yield "⚠️ No receipt generated - use a custom title for ownership proof\n\n"
yield f"**⏳ Status:** Generation started\n"
yield f"**📞 Callback:** https://1hit.no/callback.php\n\n"
yield "---\n\n"
yield f"## 🔍 Check Status Manually\n\n"
yield f"Use this Task ID: `{task_id}` in the Check tab\n\n"
# Simple one-time check after 30 seconds
yield "\n**⏰ Will check once in 30 seconds...**\n"
time.sleep(30)
# Single status check
status_result = get_task_info(task_id)
yield "\n## 📊 Status Check (30s)\n\n"
yield status_result
except Exception as e:
yield f"❌ Error submitting request: {str(e)}"
return
except Exception as e:
yield f"❌ **Unexpected Error:** {str(e)}"
# Function to handle URL parameters
def parse_url_params(request: gr.Request):
"""Parse taskid from URL parameters"""
task_id = None
if request:
try:
query_params = parse_qs(urlparse(request.request.url).query)
if 'taskid' in query_params:
task_id = query_params['taskid'][0]
# Remove any whitespace
task_id = task_id.strip()
except Exception as e:
print(f"Error parsing URL params: {e}")
return task_id
# Create the app
with gr.Blocks(theme=gr.themes.Soft()) as app:
gr.Markdown("# 🎵 Suno Song Generator with Receipts")
gr.Markdown("Create songs from lyrics and style using Suno AI - now with instant receipt downloads!")
# Define state variables
initial_load_done = gr.State(value=False)
with gr.TabItem("Audio Link"):
gr.HTML("""
Hey gangster kids, plis clean up the site for me, you are making a mess!
13 feb 2026 - Making a backup of dataset available, but made to many commits. :)
https://huggingface.co/datasets/MySafeCode/1hit.no-Music-Images/
""")
with gr.Tab("🎶 Generate Song", id="generate_tab") as tab_generate:
with gr.Row():
with gr.Column(scale=1):
# Lyrics Input
gr.Markdown("### Step 1: Enter Lyrics")
lyrics_text = gr.Textbox(
label="Lyrics",
placeholder="Paste your lyrics here...\n\nExample:\n(Verse 1)\nSun is shining, sky is blue\nBirds are singing, just for you...",
lines=10,
interactive=True
)
# Song Settings
gr.Markdown("### Step 2: Song Settings")
style = gr.Textbox(
label="Music Style",
placeholder="Example: Pop, Rock, Jazz, Classical, Electronic, Hip Hop, Country",
value="Folk soul flamenco glam rock goa trance fusion",
interactive=True
)
title = gr.Textbox(
label="Song Title (use custom title for receipt)",
placeholder="My Awesome Song",
value="Generated Song",
info="✅ Custom title = you get an ownership receipt with download buttons!",
interactive=True
)
with gr.Row():
instrumental = gr.Checkbox(
label="Instrumental (No Vocals)",
value=False,
interactive=True
)
model = gr.Dropdown(
label="Model",
choices=["V5", "V4_5PLUS", "V4_5ALL", "V4_5", "V4"],
value="V4_5ALL",
interactive=True
)
# Action Buttons
generate_btn = gr.Button("🚀 Generate Song", variant="primary", size="lg")
clear_btn = gr.Button("🗑️ Clear All", variant="secondary")
# Instructions
gr.Markdown("""
**📋 How to use:**
1. Paste lyrics (or leave empty for instrumental)
2. Set music style
3. Enter song title
4. Choose model
5. Click Generate!
**🔐 NEW: Ownership Receipts with Download Buttons**
- Use a **custom title** to get instant receipt download buttons
- Receipt contains cryptographic proof of your request
- Click buttons to download JSON or HTML receipt
- Save them to prove you created this song
""")
with gr.Column(scale=2):
# Output Area
output = gr.Markdown(
value="### Ready to generate!\n\nEnter lyrics and settings, then click 'Generate Song' to get your receipt download buttons."
)
with gr.Tab("🔍 Check Any Task", id="check_tab") as tab_check:
with gr.Row():
with gr.Column(scale=1):
gr.Markdown("### Check Task Status")
gr.Markdown("Enter any Suno Task ID to check its status")
check_task_id = gr.Textbox(
label="Task ID",
placeholder="Enter Task ID from generation or separation",
info="From Song Generator or Vocal Separator"
)
check_btn = gr.Button("🔍 Check Status", variant="primary")
check_clear_btn = gr.Button("🗑️ Clear", variant="secondary")
# URL parameter info
gr.Markdown("""
**Quick access via URL:**
Add `?taskid=YOUR_TASK_ID` to the URL
Example:
`https://1hit.no/gen/view.php?taskid=fa3529d5cbaa93427ee4451976ed5c4b`
""")
with gr.Column(scale=2):
check_output = gr.Markdown(
value="### Enter a Task ID above\n\nPaste any Suno Task ID to check its current status and results."
)
with gr.Tab("📚 Instructions", id="instructions_tab"):
gr.Markdown("""
## 📖 How to Use This App
### 🎶 Generate Song Tab
1. **Enter Lyrics** (or leave empty for instrumental)
2. **Set Music Style** (e.g., "Pop", "Rock", "Jazz")
3. **Enter Song Title** (use custom title for receipt)
4. **Choose Model** (V4_5ALL recommended)
5. **Click "Generate Song"**
### 🔐 New: Ownership Receipts with Download Buttons
- When you use a **custom title**, you get instant receipt download buttons
- **JSON Receipt** - Machine-readable proof
- **HTML Receipt** - Human-readable viewer
- Receipt contains cryptographic proof (HMAC-SHA256)
- Click the buttons to download and save your proof of ownership
### 🔍 Check Any Task Tab
1. **Paste any Suno Task ID**
2. **Click "Check Status"**
3. **View results and download links**
**Quick URL Access:**
- Visit with `?taskid=YOUR_TASK_ID` in the URL
- Automatically switches to Check tab
- Shows task status immediately
""")
with gr.Tab("📚 Less Instructions", id="less_instructions_tab"):
gr.Markdown("""
## 📖 Quick Guide
### 🎶 Generate Song
1. Enter lyrics
2. Set music style
3. Enter song title (custom = receipt with download buttons)
4. Click Generate
5. Click the receipt download buttons!
### 🔍 Check Task
Add `?taskid=YOUR_TASK_ID` to URL
### 📞 Callback Status
https://1hit.no/gen/view.php
""")
gr.Markdown("---")
gr.Markdown(
"""
Create custom songs with ownership receipts - click buttons to download!
""",
elem_id="footer"
)
# Event handlers for Generate Song tab
def clear_all():
return "", "Folk soul flamenco glam rock goa trance fusion", "Generated Song", False, "V4_5ALL", "### Ready to generate!\n\nEnter lyrics and settings, then click 'Generate Song' to get your receipt download buttons."
clear_btn.click(
clear_all,
outputs=[lyrics_text, style, title, instrumental, model, output]
)
generate_btn.click(
generate_song_from_text,
inputs=[lyrics_text, style, title, instrumental, model],
outputs=output
)
# Event handlers for Check Any Task tab
def clear_check():
return "", "### Enter a Task ID above\n\nPaste any Suno Task ID to check its current status and results."
check_clear_btn.click(
clear_check,
outputs=[check_task_id, check_output]
)
check_btn.click(
get_task_info,
inputs=[check_task_id],
outputs=check_output
)
# Function to handle URL parameter on load
def on_page_load(request: gr.Request):
"""Handle URL parameters when page loads"""
task_id = parse_url_params(request)
if task_id:
# We have a task ID from URL, return it and fetch results
task_result = get_task_info(task_id)
return (
task_id, # For check_task_id
task_result, # For check_output
gr.Tabs(selected="check_tab"), # Switch to check tab
True # Mark as loaded
)
else:
# No task ID in URL, stay on first tab
return (
"", # Empty check_task_id
"### Enter a Task ID above\n\nPaste any Suno Task ID to check its current status and results.", # Default message
gr.Tabs(selected="generate_tab"), # Stay on generate tab
True # Mark as loaded
)
# Load URL parameters when the app starts
app.load(
fn=on_page_load,
inputs=[],
outputs=[check_task_id, check_output, gr.Tabs(), initial_load_done],
queue=False
)
# Launch the app
if __name__ == "__main__":
print("🚀 Starting Suno Song Generator with Receipt Download Buttons")
print(f"🔑 SunoKey: {'✅ Set' if SUNO_KEY else '❌ Not set'}")
print("📦 Receipts: Download buttons appear immediately when you get a Task ID with custom title")
print("🌐 Open your browser to: http://localhost:7860")
app.launch(server_name="0.0.0.0", server_port=7860, share=False)