Starchik1 commited on
Commit
d2e5f0d
·
verified ·
1 Parent(s): c3dbe39

Update index.html

Browse files
Files changed (1) hide show
  1. index.html +97 -18
index.html CHANGED
@@ -1,19 +1,98 @@
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="ru">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <title>Поиск по названию (с CORS-прокси)</title>
6
+ <style>
7
+ body {
8
+ font-family: Arial, sans-serif;
9
+ margin: 20px;
10
+ }
11
+ #results {
12
+ margin-top: 20px;
13
+ }
14
+ .item {
15
+ border: 1px solid #ccc;
16
+ padding: 10px;
17
+ margin-bottom: 10px;
18
+ }
19
+ .item h3 {
20
+ margin: 0;
21
+ }
22
+ </style>
23
+ </head>
24
+ <body>
25
+ <h1>Поиск по названию (с CORS-прокси)</h1>
26
+ <input type="text" id="searchInput" placeholder="Введите название" />
27
+ <button id="searchBtn">Найти</button>
28
+
29
+ <div id="results"></div>
30
+
31
+ <script>
32
+ // Клиентский ID и API-токен
33
+ const clientID = "zR0vDH4SV0zd";
34
+ const apiToken = "7KRyeRqk77NXXRRQ99R0JDhpvzWesA4L";
35
+ // URL публичного CORS-прокси. Для работы может потребоваться предварительное получение доступа.
36
+ const corsProxy = "https://cors-anywhere.herokuapp.com/";
37
+
38
+ document.getElementById('searchBtn').addEventListener('click', function() {
39
+ const title = document.getElementById('searchInput').value.trim();
40
+ if (!title) {
41
+ alert('Введите название для поиска');
42
+ return;
43
+ }
44
+
45
+ // Формирование URL запроса к API
46
+ const targetUrl = `https://portal.lumex.host/api/short?api_token=${apiToken}&title=${encodeURIComponent(title)}`;
47
+ // Добавляем URL CORS-прокси для обхода ограничений CORS
48
+ const url = corsProxy + targetUrl;
49
+
50
+ const resultsContainer = document.getElementById('results');
51
+ resultsContainer.innerHTML = 'Загрузка...';
52
+
53
+ fetch(url)
54
+ .then(response => {
55
+ if (!response.ok) {
56
+ throw new Error("Ошибка сети: " + response.status);
57
+ }
58
+ return response.json();
59
+ })
60
+ .then(data => {
61
+ if (data.result) {
62
+ const items = data.data;
63
+ let html = '';
64
+ if (items.length === 0) {
65
+ html = '<p>Нет результатов</p>';
66
+ } else {
67
+ items.forEach(item => {
68
+ // Если ссылка для iframe начинается с //, дополняем протоколом
69
+ let iframeUrl = item.iframe_src;
70
+ if (iframeUrl && iframeUrl.startsWith('//')) {
71
+ iframeUrl = 'https:' + iframeUrl;
72
+ }
73
+ html += `<div class="item">
74
+ <h3>${item.title}</h3>
75
+ <p><strong>ID:</strong> ${item.id}</p>
76
+ <p><strong>Kinopoisk ID:</strong> ${item.kp_id}</p>
77
+ <p><strong>IMDB ID:</strong> ${item.imdb_id}</p>
78
+ <p><strong>Тип:</strong> ${item.type}</p>
79
+ <p><strong>Год:</strong> ${item.year}</p>`;
80
+ if (iframeUrl) {
81
+ html += `<p><a href="${iframeUrl}" target="_blank">Смотреть видео</a></p>`;
82
+ }
83
+ html += `</div>`;
84
+ });
85
+ }
86
+ resultsContainer.innerHTML = html;
87
+ } else {
88
+ resultsContainer.innerHTML = '<p>Ошибка при получении данных</p>';
89
+ }
90
+ })
91
+ .catch(error => {
92
+ console.error('Ошибка:', error);
93
+ resultsContainer.innerHTML = '<p>Ошибка при выполнении запроса: ' + error.message + '</p>';
94
+ });
95
+ });
96
+ </script>
97
+ </body>
98
  </html>