Skip to content

Open-source music player for YouTube Music's catalog, with genres, full albums and playlists. Windows, macOS, Linux, Android, iPhone and Docker. No account needed.

TypeScript
5.8 KB
Raw Blame
<!doctype html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="Content-Security-Policy" content="default-src 'self'; style-src 'unsafe-inline'; script-src 'unsafe-inline'" />
    <title>Musike</title>
    <style>
      :root {
        --bg: #0b0c0f;
        --surface: #181a20;
        --line: rgb(255 255 255 / 0.08);
        --fg: #eceef2;
        --fg-2: #9ba1ad;
        --accent: #c3ec52;
        --danger: #ff7a6b;
      }
      * {
        box-sizing: border-box;
      }
      html,
      body {
        margin: 0;
        height: 100%;
        background: var(--bg);
        color: var(--fg);
        font: 14px/1.4 "Segoe UI Variable", "Segoe UI", system-ui, sans-serif;
        -webkit-app-region: drag;
        user-select: none;
      }
      main {
        height: 100%;
        display: flex;
        flex-direction: column;
        justify-content: center;
        gap: 18px;
        padding: 32px;
        border: 1px solid var(--line);
        border-radius: 12px;
      }
      .brand {
        display: flex;
        align-items: center;
        gap: 10px;
        font-size: 20px;
        font-weight: 600;
        letter-spacing: -0.02em;
      }
      .brand svg {
        width: 34px;
        height: 34px;
      }
      @keyframes eq {
        0%, 100% { transform: scaleY(0.35); }
        50% { transform: scaleY(1); }
      }
      .brand rect {
        transform-box: fill-box;
        transform-origin: top;
        animation: eq 1s cubic-bezier(0.16, 1, 0.3, 1) infinite;
      }
      .brand rect:nth-child(2) { animation-delay: -0.35s; }
      .brand rect:nth-child(3) { animation-delay: -0.6s; }
      #status {
        color: var(--fg-2);
        min-height: 20px;
      }
      .rows {
        display: grid;
        gap: 10px;
      }
      .row span {
        display: flex;
        justify-content: space-between;
        font-size: 12px;
        color: var(--fg-2);
        margin-bottom: 5px;
        font-variant-numeric: tabular-nums;
      }
      .bar {
        height: 4px;
        border-radius: 99px;
        background: var(--surface);
        overflow: hidden;
      }
      .bar i {
        display: block;
        height: 100%;
        width: 0;
        background: var(--accent);
        border-radius: 99px;
        transition: width 0.25s cubic-bezier(0.16, 1, 0.3, 1);
      }
      .error {
        color: var(--danger);
      }
      button {
        -webkit-app-region: no-drag;
        align-self: flex-start;
        height: 40px;
        padding: 0 20px;
        border: 0;
        border-radius: 99px;
        background: var(--accent);
        color: var(--bg);
        font: inherit;
        font-weight: 600;
        cursor: pointer;
      }
      @media (prefers-reduced-motion: reduce) {
        .brand rect { animation: none; }
      }
    </style>
  </head>
  <body>
    <main>
      <div class="brand">
        <svg viewBox="10 10 28 28" aria-hidden="true">
          <g fill="#C3EC52">
            <rect x="10" y="10" width="8" height="28" rx="4" />
            <rect x="20" y="10" width="8" height="16" rx="4" />
            <rect x="30" y="10" width="8" height="28" rx="4" />
          </g>
        </svg>
        musike
      </div>
      <div id="status"></div>
      <div class="rows" id="rows"></div>
    </main>
    <script>
      // The app's language, passed by the desktop shell (?lang=); English until the user picks another.
      const TEXTS = {
        en: {
          starting: "Starting",
          downloading: "Downloading components on first launch",
          ready: "ready",
          extracting: "extracting",
          of: (got, total) => `${got} of ${total} MB`,
          failed: "Couldn't start: ",
          retry: "Try again",
          names: { "yt-dlp": "yt-dlp (YouTube search)", deno: "Deno (YouTube challenges)", ffmpeg: "FFmpeg (HD video)" },
        },
        "pt-BR": {
          starting: "Iniciando",
          downloading: "Baixando componentes na primeira execução",
          ready: "pronto",
          extracting: "extraindo",
          of: (got, total) => `${got} de ${total} MB`,
          failed: "Não foi possível iniciar: ",
          retry: "Tentar de novo",
          names: { "yt-dlp": "yt-dlp (busca no YouTube)", deno: "Deno (desafios do YouTube)", ffmpeg: "FFmpeg (vídeo HD)" },
        },
      };
      const lang = new URLSearchParams(location.search).get("lang");
      const t = TEXTS[lang] ?? TEXTS.en;
      document.documentElement.lang = TEXTS[lang] ? lang : "en";
      document.getElementById("status").textContent = t.starting;
      const mb = (n) => (n / 1048576).toFixed(1);

      window.update = (state) => {
        const essentials = Object.entries(state).filter(([k]) => k !== "ffmpeg");
        if (!essentials.length) return;
        document.getElementById("status").textContent = t.downloading;
        document.getElementById("rows").innerHTML = essentials
          .map(([key, s]) => {
            const pct = s.total ? Math.round((s.received / s.total) * 100) : 0;
            const label = s.status === "done" ? t.ready : s.status === "extracting" ? t.extracting : s.total ? t.of(mb(s.received), mb(s.total)) : `${mb(s.received)} MB`;
            const width = s.status === "done" || s.status === "extracting" ? 100 : pct;
            return `<div class="row"><span><b>${t.names[key] ?? key}</b><em>${label}</em></span><div class="bar"><i style="width:${width}%"></i></div></div>`;
          })
          .join("");
      };

      window.fail = (message) => {
        const status = document.getElementById("status");
        status.className = "error";
        status.textContent = t.failed + message;
        const retry = document.createElement("button");
        retry.textContent = t.retry;
        retry.onclick = () => window.musikeDesktop.retry();
        document.querySelector("main").appendChild(retry);
      };
    </script>
  </body>
</html>