🎮ArcadeLab

Wrong Holiday Music Finder 🎃

by BoldPenguin14
154 lines4.2 KB
▶ Play

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<title>Wrong Holiday Music Finder 🎃</title>
<style>
body {
 background:linear-gradient(140deg,#170c29,#552044,#b64b21);
 color:white;font-family:Arial;text-align:center;
 padding:20px;min-height:100vh;
}
main {
 max-width:600px;margin:25px auto;padding:25px;
 background:#251632;border:2px solid #ff9c50;
 border-radius:24px;
}
h1{color:#ffb36b;font-size:35px}
input,select,button {
 width:100%;padding:15px;margin:9px 0;
 border:0;border-radius:12px;font-size:16px;
 box-sizing:border-box;
}
button{background:#ff963e;font-weight:bold;cursor:pointer}
#result {
 display:none;background:#392346;padding:20px;
 margin-top:20px;border-radius:15px;
}
#result img{width:140px;border-radius:15px}
a{color:#ffc17e;display:inline-block;margin:8px}
</style>
</head>
<body>
<main>
<h1>🎃 SONG CHAOS 🎧</h1>
<h2>The Music & Podcast Finder</h2>
<p>Ask for ANYTHING. I'll find you something!</p>

<input id="ask" placeholder="Find me a song for the wrong holiday...">

<select id="kind">
<option value="song">🎵 Song</option>
<option value="podcast">🎙️ Podcast</option>
<option value="both">🎲 Surprise me!</option>
</select>

<button onclick="findIt()">✨ FIND IT NOW!</button>
<p id="status"></p>

<div id="result">
<h2 id="headline"></h2>
<img id="art" alt="Cover artwork">
<h2 id="name"></h2>
<p id="creator"></p>
<p id="reason"></p>
<a id="apple" target="_blank">🍎 Apple Music / Podcasts</a>
<a id="amazon" target="_blank">📦 Amazon Music</a>
</div>
</main>

<script>
const $ = id => document.getElementById(id);

function escapeText(s) {
 return String(s || "").replace(/[&<>"']/g,c=>({
 "&":"&amp;","<":"&lt;",">":"&gt;",
 '"':"&quot;","'":"&#39;"
 }[c]));
}

function searchTerm(prompt,kind) {
 const month = new Date().getMonth();
 const holidayWrong =
   /wrong holiday|wrong season|opposite holiday/i.test(prompt);

 if(holidayWrong) {
   if(month===9 || month===10)
     return {term:"Mariah Carey All I Want for Christmas Is You",
       reason:"🎃 WRONG HOLIDAY ALERT! Christmas music during spooky season!"};
   return {term:"Michael Jackson Thriller",
       reason:"🎄 WRONG HOLIDAY ALERT! Halloween music when it's Christmas season!"};
 }
 return {term:prompt,reason:"✨ Picked to match your request!"};
}

async function findIt() {
 const prompt=$("ask").value.trim() || "cool";
 let kind=$("kind").value;
 if(kind==="both") kind=Math.random()<.5?"song":"podcast";

 $("status").textContent="🔮 Finding your perfect match...";
 $("result").style.display="none";

 const request=searchTerm(prompt,kind);
 const params=new URLSearchParams({
   term:request.term,
   media:kind==="podcast"?"podcast":"music",
   entity:kind==="podcast"?"podcast":"song",
   limit:"20",
   country:"us"
 });

 try {
   const response=await fetch(
     "https://itunes.apple.com/search?"+params
   );
   if(!response.ok) throw Error("Search unavailable");

   const data=await response.json();
   if(!data.results.length) {
     $("status").textContent="No exact match! Try describing it differently.";
     return;
   }

   const results=data.results;
   let chosen;

   // Random results keep the game fun.
   chosen=results[Math.floor(Math.random()*results.length)];

   const name=kind==="podcast"
      ?chosen.collectionName:chosen.trackName;
   const creator=chosen.artistName || "Unknown creator";

   $("headline").textContent=kind==="podcast"
      ?"🎙️ YOUR PODCAST IS HERE!"
      :"🎵 YOUR SONG IS HERE!";

   $("name").textContent=name;
   $("creator").textContent="By "+creator;
   $("reason").textContent=request.reason;
   $("art").src=chosen.artworkUrl100 || "";
   $("art").style.display=chosen.artworkUrl100?"inline-block":"none";

   const query=encodeURIComponent(name+" "+creator);
   $("apple").href=chosen.trackViewUrl ||
      chosen.collectionViewUrl ||
      "https://music.apple.com/us/search?term="+query;

   $("amazon").href="https://music.amazon.com/search/"+query;

   $("status").textContent="";
   $("result").style.display="block";

 } catch(e) {
   $("status").textContent=
     "Couldn't load the catalog. Check your connection and try again.";
 }
}
</script>
</body>
</html>

Game Source: Wrong Holiday Music Finder 🎃

Creator: BoldPenguin14

Libraries: none

Complexity: moderate (154 lines, 4.2 KB)

The full source code is displayed above on this page.

Remix Instructions

To remix this game, copy the source code above and modify it. Add a ARCADELAB header at the top with "remix_of: wrong-holiday-music-finder-boldpenguin14" to link back to the original. Then publish at arcadelab.ai/publish.