Ivan000 commited on
Commit
ecadf7d
·
verified ·
1 Parent(s): 1e075c2

У тебя не получается ничего исправить поэтому пойдём радикальным путём: просто удали кнопки для сортировки, оставив только поиск и базовую сортировку по порядку, в каком сайт станции и выводит. - Initial Deployment

Browse files
Files changed (2) hide show
  1. README.md +7 -5
  2. index.html +271 -19
README.md CHANGED
@@ -1,10 +1,12 @@
1
  ---
2
- title: Matrix Radio Finder
3
- emoji: 📉
4
- colorFrom: purple
5
- colorTo: purple
6
  sdk: static
7
  pinned: false
 
 
8
  ---
9
 
10
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
1
  ---
2
+ title: matrix-radio-finder
3
+ emoji: 🐳
4
+ colorFrom: pink
5
+ colorTo: red
6
  sdk: static
7
  pinned: false
8
+ tags:
9
+ - deepsite
10
  ---
11
 
12
+ Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
index.html CHANGED
@@ -1,19 +1,271 @@
1
- <!doctype html>
2
- <html>
3
- <head>
4
- <meta charset="utf-8" />
5
- <meta name="viewport" content="width=device-width" />
6
- <title>My static Space</title>
7
- <link rel="stylesheet" href="style.css" />
8
- </head>
9
- <body>
10
- <div class="card">
11
- <h1>Welcome to your static Space!</h1>
12
- <p>You can modify this app directly by editing <i>index.html</i> in the Files and versions tab.</p>
13
- <p>
14
- Also don't forget to check the
15
- <a href="https://huggingface.co/docs/hub/spaces" target="_blank">Spaces documentation</a>.
16
- </p>
17
- </div>
18
- </body>
19
- </html>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ <title>Matrix Radio Finder</title>
7
+ <script src="https://cdn.tailwindcss.com"></script>
8
+ <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
9
+ <script>
10
+ tailwind.config = {
11
+ theme: {
12
+ extend: {
13
+ colors: {
14
+ matrix: {
15
+ dark: '#001a00',
16
+ medium: '#003300',
17
+ light: '#00cc00',
18
+ bright: '#00ff00',
19
+ }
20
+ },
21
+ fontFamily: {
22
+ 'mono': ['Courier New', 'monospace'],
23
+ }
24
+ }
25
+ }
26
+ }
27
+ </script>
28
+ <style>
29
+ @keyframes flicker {
30
+ 0% { opacity: 0.8; }
31
+ 50% { opacity: 1; }
32
+ 100% { opacity: 0.8; }
33
+ }
34
+ .flicker {
35
+ animation: flicker 3s infinite;
36
+ }
37
+ .matrix-bg {
38
+ background-color: #001a00;
39
+ background-image:
40
+ linear-gradient(rgba(0, 80, 0, 0.3) 1px, transparent 1px),
41
+ linear-gradient(90deg, rgba(0, 80, 0, 0.3) 1px, transparent 1px);
42
+ background-size: 20px 20px;
43
+ }
44
+ .glow-text {
45
+ text-shadow: 0 0 5px #00ff00;
46
+ }
47
+ .glow-box {
48
+ box-shadow: 0 0 10px #00ff00;
49
+ }
50
+ .radio-item:hover {
51
+ background-color: rgba(0, 80, 0, 0.5);
52
+ transform: translateX(5px);
53
+ }
54
+ .radio-item {
55
+ transition: all 0.3s ease;
56
+ }
57
+ .audio-player {
58
+ background: linear-gradient(to right, #001a00, #003300, #001a00);
59
+ }
60
+ ::-webkit-scrollbar {
61
+ width: 8px;
62
+ }
63
+ ::-webkit-scrollbar-track {
64
+ background: #001a00;
65
+ }
66
+ ::-webkit-scrollbar-thumb {
67
+ background: #00cc00;
68
+ border-radius: 4px;
69
+ }
70
+ ::-webkit-scrollbar-thumb:hover {
71
+ background: #00ff00;
72
+ }
73
+ </style>
74
+ </head>
75
+ <body class="matrix-bg font-mono text-matrix-light min-h-screen">
76
+ <div class="container mx-auto px-4 py-8">
77
+ <!-- Header -->
78
+ <header class="mb-10 text-center">
79
+ <h1 class="text-4xl md:text-6xl font-bold glow-text flicker mb-4">MATRIX RADIO FINDER</h1>
80
+ <p class="text-matrix-bright text-lg">Access the global radio network</p>
81
+ <div class="w-full max-w-2xl mx-auto mt-6 relative">
82
+ <input
83
+ type="text"
84
+ id="searchInput"
85
+ placeholder="Search radio stations..."
86
+ class="w-full bg-matrix-dark border-2 border-matrix-light text-matrix-light px-4 py-3 rounded-none focus:outline-none focus:border-matrix-bright focus:glow-box"
87
+ >
88
+ <button
89
+ id="searchBtn"
90
+ class="absolute right-0 top-0 h-full bg-matrix-light text-matrix-dark px-4 border-2 border-matrix-light hover:bg-matrix-bright hover:text-matrix-dark transition-all"
91
+ >
92
+ <i class="fas fa-search"></i>
93
+ </button>
94
+ </div>
95
+ </header>
96
+
97
+ <!-- Main Content -->
98
+ <main>
99
+ <!-- Now Playing -->
100
+ <div id="nowPlaying" class="audio-player p-4 mb-8 hidden glow-box">
101
+ <div class="flex flex-col md:flex-row items-center">
102
+ <div class="flex-shrink-0 mb-4 md:mb-0 md:mr-6">
103
+ <img id="stationImage" src="https://via.placeholder.com/150x150/001a00/00cc00?text=NO+IMAGE" alt="Station logo" class="w-24 h-24 object-cover border-2 border-matrix-light">
104
+ </div>
105
+ <div class="flex-grow text-center md:text-left">
106
+ <h3 id="stationName" class="text-xl font-bold text-matrix-bright"></h3>
107
+ <p id="stationCountry" class="text-matrix-light"></p>
108
+ <p id="stationTags" class="text-matrix-light text-sm mt-1"></p>
109
+ </div>
110
+ <audio id="audioPlayer" controls class="w-full md:w-auto mt-4 md:mt-0">
111
+ Your browser does not support the audio element.
112
+ </audio>
113
+ </div>
114
+ </div>
115
+
116
+ <!-- Results -->
117
+ <div id="loading" class="text-center py-10 hidden">
118
+ <div class="inline-block animate-spin rounded-full h-12 w-12 border-t-2 border-b-2 border-matrix-bright"></div>
119
+ <p class="mt-4">Accessing radio network...</p>
120
+ </div>
121
+
122
+ <div id="results" class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4">
123
+ <!-- Results will be inserted here by JavaScript -->
124
+ </div>
125
+
126
+ <div id="noResults" class="text-center py-10 hidden">
127
+ <p class="text-xl">No stations found. Try a different search.</p>
128
+ </div>
129
+
130
+ </main>
131
+
132
+ <!-- Footer -->
133
+ <footer class="mt-16 text-center text-matrix-light text-sm pb-8">
134
+ <p class="mb-2">Data provided by <a href="https://www.radio-browser.info/" target="_blank" class="text-matrix-bright hover:underline">Radio Browser API</a></p>
135
+ <p>© 2023 Matrix Radio Network</p>
136
+ </footer>
137
+ </div>
138
+
139
+ <script>
140
+ document.addEventListener('DOMContentLoaded', function() {
141
+ // Elements
142
+ const searchInput = document.getElementById('searchInput');
143
+ const searchBtn = document.getElementById('searchBtn');
144
+ const resultsContainer = document.getElementById('results');
145
+ const loadingElement = document.getElementById('loading');
146
+ const noResultsElement = document.getElementById('noResults');
147
+ const nowPlayingElement = document.getElementById('nowPlaying');
148
+ const audioPlayer = document.getElementById('audioPlayer');
149
+ const stationNameElement = document.getElementById('stationName');
150
+ const stationCountryElement = document.getElementById('stationCountry');
151
+ const stationTagsElement = document.getElementById('stationTags');
152
+ const stationImageElement = document.getElementById('stationImage');
153
+
154
+ // Variables
155
+ let currentPage = 1;
156
+ let currentSearchTerm = '';
157
+ let currentSearchType = 'search';
158
+ let isLoading = false;
159
+
160
+ // Event Listeners
161
+ searchBtn.addEventListener('click', performSearch);
162
+ searchInput.addEventListener('keypress', function(e) {
163
+ if (e.key === 'Enter') performSearch();
164
+ });
165
+ // Functions
166
+ function performSearch() {
167
+ currentSearchTerm = searchInput.value.trim();
168
+ currentPage = 1;
169
+ currentSearchType = 'search';
170
+
171
+ // Clear previous results
172
+ resultsContainer.innerHTML = '';
173
+ noResultsElement.classList.add('hidden');
174
+
175
+ fetchStations();
176
+ }
177
+
178
+ function fetchStations() {
179
+ isLoading = true;
180
+ loadingElement.classList.remove('hidden');
181
+
182
+ let url = `https://de1.api.radio-browser.info/json/stations/search?name=${encodeURIComponent(currentSearchTerm)}&hidebroken=true&limit=12&offset=${(currentPage - 1) * 12}`;
183
+
184
+ fetch(url)
185
+ .then(response => response.json())
186
+ .then(data => {
187
+ loadingElement.classList.add('hidden');
188
+
189
+ if (data.length === 0 && currentPage === 1) {
190
+ noResultsElement.classList.remove('hidden');
191
+ return;
192
+ }
193
+
194
+ displayStations(data);
195
+
196
+ })
197
+ .catch(error => {
198
+ console.error('Error fetching stations:', error);
199
+ loadingElement.classList.add('hidden');
200
+ noResultsElement.classList.remove('hidden');
201
+ })
202
+ .finally(() => {
203
+ isLoading = false;
204
+ });
205
+ }
206
+
207
+
208
+ function displayStations(stations) {
209
+ if (stations.length === 0 && currentPage === 1) {
210
+ noResultsElement.classList.remove('hidden');
211
+ return;
212
+ }
213
+
214
+ stations.forEach(station => {
215
+ const stationElement = document.createElement('div');
216
+ stationElement.className = 'radio-item bg-matrix-dark p-4 border border-matrix-medium cursor-pointer';
217
+ stationElement.innerHTML = `
218
+ <div class="flex items-start">
219
+ <div class="flex-shrink-0 mr-4">
220
+ <img src="${station.favicon || 'https://via.placeholder.com/100x100/001a00/00cc00?text=NO+IMAGE'}"
221
+ alt="${station.name}"
222
+ class="w-16 h-16 object-cover border border-matrix-light">
223
+ </div>
224
+ <div>
225
+ <h3 class="font-bold text-matrix-bright truncate">${station.name}</h3>
226
+ <p class="text-sm text-matrix-light">${station.country || 'Unknown country'}</p>
227
+ <p class="text-xs text-matrix-light mt-1">${station.tags ? station.tags.split(',').slice(0, 3).join(', ') : ''}</p>
228
+ <div class="flex items-center mt-2 text-xs text-matrix-light">
229
+ <span class="mr-3"><i class="fas fa-heart mr-1"></i> ${station.votes}</span>
230
+ <span><i class="fas fa-headphones mr-1"></i> ${station.clickcount}</span>
231
+ </div>
232
+ </div>
233
+ </div>
234
+ `;
235
+
236
+ stationElement.addEventListener('click', () => playStation(station));
237
+ resultsContainer.appendChild(stationElement);
238
+ });
239
+ }
240
+
241
+ function playStation(station) {
242
+ // Update now playing section
243
+ stationNameElement.textContent = station.name;
244
+ stationCountryElement.textContent = `${station.country || 'Unknown'} • ${station.language || 'Unknown language'}`;
245
+ stationTagsElement.textContent = station.tags ? station.tags.split(',').slice(0, 5).join(' • ') : '';
246
+ stationImageElement.src = station.favicon || 'https://via.placeholder.com/150x150/001a00/00cc00?text=NO+IMAGE';
247
+
248
+ // Set audio source
249
+ audioPlayer.src = station.url_resolved || station.url;
250
+
251
+ // Show now playing section
252
+ nowPlayingElement.classList.remove('hidden');
253
+
254
+ // Try to play (some browsers require user interaction first)
255
+ const playPromise = audioPlayer.play();
256
+
257
+ if (playPromise !== undefined) {
258
+ playPromise.catch(error => {
259
+ console.log('Playback failed:', error);
260
+ // Show play button for user to initiate playback
261
+ audioPlayer.controls = true;
262
+ });
263
+ }
264
+ }
265
+
266
+ // Initial load - show popular stations
267
+ performSearch();
268
+ });
269
+ </script>
270
+ <p style="border-radius: 8px; text-align: center; font-size: 12px; color: #fff; margin-top: 16px;position: fixed; left: 8px; bottom: 8px; z-index: 10; background: rgba(0, 0, 0, 0.8); padding: 4px 8px;">Made with <img src="https://enzostvs-deepsite.hf.space/logo.svg" alt="DeepSite Logo" style="width: 16px; height: 16px; vertical-align: middle;display:inline-block;margin-right:3px;filter:brightness(0) invert(1);"><a href="https://enzostvs-deepsite.hf.space" style="color: #fff;text-decoration: underline;" target="_blank" >DeepSite</a> - 🧬 <a href="https://enzostvs-deepsite.hf.space?remix=Ivan000/matrix-radio-finder" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>
271
+ </html>