Spaces:
Running
Running
File size: 7,672 Bytes
8143cb6 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 |
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta httpEquiv="Content-Type" content="text/html; charset=utf-8" />
<title>Python YouTube Ringtones</title>
<meta name="title" content="Python YouTube Ringtones" />
<meta name="description" content="Generate custom ringtones from YouTube videos with one click! Python YouTube Ringtones lets you convert YouTube audio into high-quality MP3 and iPhone ringtones in seconds. No software required β fast, free, and online!" />
<meta property="og:type" content="website" />
<meta property="og:url" content="https://ringtones.jessejesse.xyz" />
<meta property="og:title" content="Python YouTube Ringtones" />
<meta property="og:description" content="Generate custom ringtones from YouTube videos with one click! Python YouTube Ringtones lets you convert YouTube audio into high-quality MP3 and iPhone ringtones in seconds. No software required β fast, free, and online!" />
<meta property="og:image" content="https://ringtones.jessejesse.xyz/og.png" />
<meta property="twitter:card" content="summary_large_image" />
<meta property="twitter:url" content="https://ringtones.jessejesse.xyz" />
<meta property="twitter:title" content="Python YouTube Ringtones" />
<meta property="twitter:description" content="Generate custom ringtones from YouTube videos with one click! Python YouTube Ringtones lets you convert YouTube audio into high-quality MP3 and iPhone ringtones in seconds. No software required β fast, free, and online!" />
<meta property="twitter:image" content="https://ringtones.jessejesse.xyz/og.png" />
<meta name="author" content="JesseJesse.xyz" />
<style>
body {
background: linear-gradient(135deg, #1a1a2e, #111827, #0f0f14);
color: white;
visibility: hidden;
}
</style>
<script src="https://cdn.tailwindcss.com"></script>
<script>
document.addEventListener("DOMContentLoaded", () => {
document.body.style.visibility = "visible";
updateRingtoneCount(); // Fetch count on page load
});
</script>
</head>
<body class="bg-gradient-to-br from-gray-900 via-gray-800 to-black text-white flex flex-col justify-center items-center h-screen">
<div class="w-full max-w-md bg-transparent p-6 rounded-lg shadow-lg text-center">
<img src="icon.png" alt="App Icon" class="w-20 h-20 mx-auto mb-4" />
<h1 class="text-xl font-bold mb-4">Python YouTube Ringtones</h1>
<p class="mt-4 text-center text-yellow-400">
βͺβ¬βͺβ¬ tones made: <span id="ringtone-count">0</span>
</p>
<br />
<div class="flex gap-2">
<input
id="youtube-url"
type="text"
placeholder="Enter YouTube URL"
class="flex-1 p-2 border border-gray-700 rounded bg-gray-700 text-white"
/>
<button onclick="pasteClipboard()" class="bg-gray-600 hover:bg-gray-500 px-3 py-2 rounded">
✎
</button>
</div>
<input
id="mp3-upload"
type="file"
accept="audio/*"
class="w-full p-2 mt-4 border border-gray-700 rounded bg-gray-700 text-white"
/>
<button
onclick="processRingtone()"
class="w-full bg-indigo-700 hover:bg-green-800 text-white py-2 px-4 rounded mt-4"
>
Generate Ringtones
</button>
<p id="status" class="text-center mt-4 text-yellow-400"></p>
<a
id="android-ringtone"
href="#"
download
class="hidden block mt-4 text-center text-green-800"
>β¬ Android Ringtone</a
>
<a
id="iphone-ringtone"
href="#"
download
class="hidden block mt-4 text-center text-green-400"
>β¬ iPhone Ringtone</a
>
</div>
<footer class="mt-6 text-green-600 text-sm text-center cursor-pointer" onclick="sharePage()">
JesseJesse.xyz
</footer>
<br />
<span class="inline-block ml-2 text-sm text-center cursor-pointer">☝ share</span>
<script>
const REDIS_URL = "https://amused-walleye-31373.upstash.io";
const REDIS_TOKEN = "AXqNASQgMWZmMTdjYTEtNTJjYi00MDczLWJmZDctNjFjZGUyOTA0ZjEyNjcyMTI0NDM2MDBjNDVmZmE5NjJlMTllYTkyMDI2MDU=";
async function updateRingtoneCount() {
try {
const response = await fetch(`${REDIS_URL}/get/ringtone_count`, {
headers: { Authorization: `Bearer ${REDIS_TOKEN}` },
});
const data = await response.json();
document.getElementById("ringtone-count").innerText = data.result || 0;
} catch (error) {
console.error("Error fetching ringtone count:", error);
}
}
async function incrementRingtoneCount() {
try {
await fetch(`${REDIS_URL}/incr/ringtone_count`, {
headers: { Authorization: `Bearer ${REDIS_TOKEN}` },
});
updateRingtoneCount(); //count
} catch (error) {
console.error("Error updating ringtone count:", error);
}
}
async function processRingtone() {
const urlInput = document.getElementById("youtube-url").value;
const fileInput = document.getElementById("mp3-upload").files[0];
const androidLink = document.getElementById("android-ringtone");
const iphoneLink = document.getElementById("iphone-ringtone");
const status = document.getElementById("status");
if (!urlInput && !fileInput) {
status.innerText = "β Please enter a YouTube URL or upload an MP3 file!";
return;
}
try {
status.innerText = "β³ one moment please...";
const client = await import("https://cdn.jsdelivr.net/npm/@gradio/client/+esm").then((m) => m.Client);
const connectedClient = await client.connect("sudo-soldier/PYTR");
const inputData = {
url: urlInput || "Hello!!",
uploaded_file: fileInput || null,
};
const result = await connectedClient.predict("/process_youtube_url", inputData);
const androidFile = result.data[0]?.url || result.data[0]?.path;
const iphoneFile = result.data[1]?.url || result.data[1]?.path;
if (androidFile) {
androidLink.href = androidFile;
androidLink.download = "android_ringtone.mp3";
androidLink.style.display = "block";
}
if (iphoneFile) {
iphoneLink.href = iphoneFile;
iphoneLink.download = "iphone_ringtone.m4r";
iphoneLink.style.display = "block";
}
status.innerText = "Ringtones Ready!";
incrementRingtoneCount(); //count
} catch (error) {
console.error(error);
status.innerText = "Error processing request!";
}
}
async function pasteClipboard() {
try {
const text = await navigator.clipboard.readText();
document.getElementById("youtube-url").value = text;
} catch (error) {
alert("Clipboard access denied! Please paste manually.");
}
}
function sharePage() {
if (navigator.share) {
navigator
.share({
title: "ringtones.JesseJesse.xyz",
url: window.location.href,
})
.catch((error) => console.log("Sharing failed:", error));
} else {
alert("Share API not supported in this browser.");
}
}
</script>
</body>
</html>
|