File size: 3,699 Bytes
d2e5f0d
 
 
 
411b780
d2e5f0d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
411b780
d2e5f0d
 
 
 
 
 
40a909c
d2e5f0d
 
 
 
 
 
 
 
 
 
411b780
d2e5f0d
411b780
 
 
d2e5f0d
 
 
 
411b780
d2e5f0d
 
 
 
 
 
 
411b780
 
 
 
 
 
 
 
 
d2e5f0d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
c3dbe39
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
<!DOCTYPE html>
<html lang="ru">
<head>
  <meta charset="UTF-8">
  <title>Поиск по названию (с CORS‑прокси через AllOrigins)</title>
  <style>
    body {
      font-family: Arial, sans-serif;
      margin: 20px;
    }
    #results {
      margin-top: 20px;
    }
    .item {
      border: 1px solid #ccc;
      padding: 10px;
      margin-bottom: 10px;
    }
    .item h3 {
      margin: 0;
    }
  </style>
</head>
<body>
  <h1>Поиск по названию (с CORS‑прокси через AllOrigins)</h1>
  <input type="text" id="searchInput" placeholder="Введите название" />
  <button id="searchBtn">Найти</button>
  
  <div id="results"></div>
  
  <script>
    // Клиентский ID и API‑токен
    const clientID = "zR0vDH4SV0zd";
    const apiToken = "7KRyeRqk77NXXRRQ99R0JDhpvzWesA4L";
    
    document.getElementById('searchBtn').addEventListener('click', function() {
      const title = document.getElementById('searchInput').value.trim();
      if (!title) {
        alert('Введите название для поиска');
        return;
      }
      
      // URL для запроса к API
      const targetUrl = `https://portal.lumex.host/api/short?api_token=${apiToken}&title=${encodeURIComponent(title)}`;
      
      // Используем AllOrigins для обхода CORS‑ограничений
      const allOriginsUrl = "https://api.allorigins.hexocode.repl.co/get?disableCache=true&url=" + encodeURIComponent(targetUrl);
      
      const resultsContainer = document.getElementById('results');
      resultsContainer.innerHTML = 'Загрузка...';
      
      fetch(allOriginsUrl)
        .then(response => {
          if (!response.ok) {
            throw new Error("Ошибка сети: " + response.status);
          }
          return response.json();
        })
        .then(data => {
          let jsonData;
          try {
            jsonData = JSON.parse(data.contents);
          } catch (e) {
            throw new Error("Ошибка разбора данных: " + e.message);
          }
          
          if (jsonData.result) {
            const items = jsonData.data;
            let html = '';
            if (items.length === 0) {
              html = '<p>Нет результатов</p>';
            } else {
              items.forEach(item => {
                let iframeUrl = item.iframe_src;
                if (iframeUrl && iframeUrl.startsWith('//')) {
                  iframeUrl = 'https:' + iframeUrl;
                }
                html += `<div class="item">
                          <h3>${item.title}</h3>
                          <p><strong>ID:</strong> ${item.id}</p>
                          <p><strong>Kinopoisk ID:</strong> ${item.kp_id}</p>
                          <p><strong>IMDB ID:</strong> ${item.imdb_id}</p>
                          <p><strong>Тип:</strong> ${item.type}</p>
                          <p><strong>Год:</strong> ${item.year}</p>`;
                if (iframeUrl) {
                  html += `<p><a href="${iframeUrl}" target="_blank">Смотреть видео</a></p>`;
                }
                html += `</div>`;
              });
            }
            resultsContainer.innerHTML = html;
          } else {
            resultsContainer.innerHTML = '<p>Ошибка при получении данных</p>';
          }
        })
        .catch(error => {
          console.error('Ошибка:', error);
          resultsContainer.innerHTML = '<p>Ошибка при выполнении запроса: ' + error.message + '</p>';
        });
    });
  </script>
</body>
</html>