94 lines
2.7 KiB
HTML
94 lines
2.7 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>URL to JSON Formatter</title>
|
|
<style>
|
|
body {
|
|
font-family: Arial, sans-serif;
|
|
max-width: 600px;
|
|
margin: 40px auto;
|
|
padding: 20px;
|
|
background-color: #1b1b1b; /* Pure black background */
|
|
color: #c792ea; /* Light purple text color */
|
|
}
|
|
textarea, input, button {
|
|
width: 100%;
|
|
padding: 10px;
|
|
margin-top: 10px;
|
|
background-color: #2a2a2a; /* Darker black for inputs */
|
|
color: #c792ea; /* Light purple text in inputs */
|
|
border: 1px solid #5c5c5c; /* Gray border for inputs */
|
|
border-radius: 4px;
|
|
}
|
|
textarea::placeholder {
|
|
color: #8a8a8a; /* Gray placeholder text */
|
|
}
|
|
button {
|
|
background-color: #6a1b9a; /* Deep purple for button */
|
|
color: white;
|
|
font-weight: bold;
|
|
cursor: pointer;
|
|
border: none;
|
|
}
|
|
button:hover {
|
|
background-color: #8e24aa; /* Lighter purple on hover */
|
|
}
|
|
#output {
|
|
white-space: pre-wrap;
|
|
background-color: #2a2a2a; /* Darker black for output background */
|
|
padding: 10px;
|
|
border: 1px solid #5c5c5c; /* Gray border for output */
|
|
color: #c792ea; /* Light purple text in output */
|
|
border-radius: 4px;
|
|
}
|
|
h2 {
|
|
color: #ba68c8; /* Bright purple for heading */
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<textarea id="urlInput" rows="10" placeholder="Paste URLs here, one per line..."></textarea>
|
|
<button onclick="convertUrls()">Convert</button>
|
|
|
|
<h2>Formatted Output</h2>
|
|
<div id="output"></div>
|
|
|
|
<script>
|
|
function convertUrls() {
|
|
const input = document.getElementById("urlInput").value;
|
|
const outputDiv = document.getElementById("output");
|
|
|
|
// Split the input into lines
|
|
const lines = input.trim().split("\n");
|
|
|
|
// Map each line to a formatted JSON object
|
|
const formattedJson = lines.map(line => {
|
|
let url = line.trim();
|
|
|
|
// Prepend https:// if not already present
|
|
if (!url.startsWith("http://") && !url.startsWith("https://")) {
|
|
url = "https://" + url;
|
|
}
|
|
|
|
// Extract artist and title from the filename in the URL
|
|
const filename = decodeURIComponent(url.split("/").pop().replace(".flac", ""));
|
|
const [artist, title] = filename.split(" - ");
|
|
|
|
return {
|
|
metaData: {
|
|
artist: artist || "Unknown Artist",
|
|
title: title || "Unknown Title"
|
|
},
|
|
url: url
|
|
};
|
|
});
|
|
|
|
// Display formatted JSON as a string
|
|
outputDiv.textContent = JSON.stringify(formattedJson, null, 2);
|
|
}
|
|
</script>
|
|
|
|
</body>
|
|
</html>
|