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