File size: 4,394 Bytes
efa43bd
 
 
2eef2c0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
efa43bd
2eef2c0
 
 
 
 
 
 
efa43bd
2eef2c0
 
 
 
 
 
 
efa43bd
2eef2c0
efa43bd
2eef2c0
 
 
 
 
 
 
 
efa43bd
2eef2c0
 
 
 
 
efa43bd
2eef2c0
 
 
 
 
 
 
 
efa43bd
2eef2c0
 
 
 
 
 
 
 
efa43bd
2eef2c0
 
 
 
 
 
efa43bd
 
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
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>Spotify Downloader</title>
  <style>
    :root {
      --spotify-green: #1DB954;
      --bg: #f9f9f9;
      --card: #fff;
      --text: #333;
      --muted: #666;
    }
    * { box-sizing: border-box; margin: 0; padding: 0; }
    body {
      font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
      background: var(--bg);
      color: var(--text);
      display: flex;
      align-items: center;
      justify-content: center;
      min-height: 100vh;
      padding: 1rem;
    }
    .container {
      background: var(--card);
      border-radius: 12px;
      box-shadow: 0 4px 12px rgba(0,0,0,0.05);
      max-width: 360px;
      width: 100%;
      padding: 2rem;
      text-align: center;
    }
    .logo {
      width: 64px;
      margin-bottom: 1rem;
    }
    h1 {
      font-size: 1.25rem;
      margin-bottom: 1.5rem;
      color: var(--spotify-green);
    }
    form input {
      width: 100%;
      padding: 0.75rem;
      border: 1px solid #ddd;
      border-radius: 8px;
      font-size: 1rem;
      margin-bottom: 1rem;
    }
    form button {
      width: 100%;
      padding: 0.75rem;
      background: var(--spotify-green);
      color: #fff;
      border: none;
      border-radius: 8px;
      font-size: 1rem;
      cursor: pointer;
      transition: background 0.2s;
    }
    form button:hover {
      background: #17a44c;
    }
    .result {
      margin-top: 1.5rem;
      text-align: left;
    }
    .media-item {
      display: block;
      margin: 0.5rem 0;
      padding: 0.75rem;
      background: var(--bg);
      border-radius: 6px;
      text-decoration: none;
      color: var(--spotify-green);
      font-weight: 500;
      font-size: 0.95rem;
      transition: background 0.2s;
    }
    .media-item:hover {
      background: #e6f7ee;
    }
    .info {
      display: flex;
      align-items: center;
      margin-bottom: 1rem;
    }
    .info img {
      width: 64px;
      height: 64px;
      border-radius: 8px;
      margin-right: 1rem;
    }
    .info div {
      flex: 1;
    }
    .info .title {
      font-size: 1rem;
      font-weight: 600;
      margin-bottom: 0.25rem;
    }
    .info .author {
      font-size: 0.85rem;
      color: var(--muted);
    }
  </style>
</head>
<body>
  <div class="container">
    <img src="https://cdn.jsdelivr.net/gh/edent/SuperTinyIcons/images/svg/spotify.svg" alt="Spotify" class="logo">
    <h1>Spotify Downloader</h1>
    <form id="download-form">
      <input type="url" id="track-url" placeholder="Enter Spotify track URL..." required>
      <button type="submit">Fetch Links</button>
    </form>
    <div id="output" class="result" hidden>
      <div class="info">
        <img id="thumb" src="" alt="Thumbnail">
        <div>
          <div id="track-title" class="title"></div>
          <div id="track-author" class="author"></div>
        </div>
      </div>
      <div id="links"></div>
    </div>
  </div>
  <script>
    const form = document.getElementById('download-form');
    const output = document.getElementById('output');
    const thumb = document.getElementById('thumb');
    const trackTitle = document.getElementById('track-title');
    const trackAuthor = document.getElementById('track-author');
    const linksDiv = document.getElementById('links');

    form.addEventListener('submit', async e => {
      e.preventDefault();
      const url = document.getElementById('track-url').value.trim();
      output.hidden = true;
      linksDiv.innerHTML = '';

      try {
        const res = await fetch(`/proxy-url?url=${encodeURIComponent(url)}`);
        if (!res.ok) throw new Error('Failed to fetch');
        const data = await res.json();
        const info = data.data;
        thumb.src = info.thumbnail;
        trackTitle.textContent = info.title;
        trackAuthor.textContent = info.author;

        info.medias.forEach(item => {
          const a = document.createElement('a');
          a.href = item.url;
          a.textContent = `Download ${item.quality}`;
          a.className = 'media-item';
          a.setAttribute('download', '');
          linksDiv.appendChild(a);
        });

        output.hidden = false;
      } catch (err) {
        alert(err.message);
      }
    });
  </script>
</body>
</html>