Spaces:
Running
Running
Upload server.js
Browse files
server.js
CHANGED
|
@@ -653,11 +653,23 @@ const server = http.createServer(async (req, res) => {
|
|
| 653 |
const searchUrl = 'https://uakinogo.io/index.php?do=search&subaction=search&story=' + encodeURIComponent(q);
|
| 654 |
fetchRaw(searchUrl, { 'user-agent': 'Mozilla/5.0 Chrome/120', 'referer': 'https://uakinogo.io/' }).then(html => {
|
| 655 |
const results = [];
|
| 656 |
-
const
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 657 |
let m;
|
| 658 |
-
while ((m =
|
| 659 |
-
|
| 660 |
-
}
|
| 661 |
jsonResp(res, { ok: true, results: results.slice(0, 10) });
|
| 662 |
}).catch(e => jsonResp(res, { ok: false, error: e.message }, 500));
|
| 663 |
return;
|
|
|
|
| 653 |
const searchUrl = 'https://uakinogo.io/index.php?do=search&subaction=search&story=' + encodeURIComponent(q);
|
| 654 |
fetchRaw(searchUrl, { 'user-agent': 'Mozilla/5.0 Chrome/120', 'referer': 'https://uakinogo.io/' }).then(html => {
|
| 655 |
const results = [];
|
| 656 |
+
const addResult = (rawUrl, id, slug) => {
|
| 657 |
+
if (!rawUrl || !id) return;
|
| 658 |
+
let url = rawUrl;
|
| 659 |
+
if (url.startsWith('//')) url = 'https:' + url;
|
| 660 |
+
if (url.startsWith('/')) url = 'https://uakinogo.io' + url;
|
| 661 |
+
if (!url.startsWith('http')) return;
|
| 662 |
+
if (!url.includes('uakinogo.io/')) return;
|
| 663 |
+
if (url.includes('do=search') || url.includes('/index.php')) return;
|
| 664 |
+
if (!results.find(r => r.id === id)) results.push({ url, id, slug: slug || '' });
|
| 665 |
+
};
|
| 666 |
+
|
| 667 |
+
const reAbs = /href="(https?:\/\/uakinogo\.io\/[^"]*?\/(\d+)-([^"\/]+)\.html)"/g;
|
| 668 |
+
const reRel = /href="(\/[^"]*?\/(\d+)-([^"\/]+)\.html)"/g;
|
| 669 |
let m;
|
| 670 |
+
while ((m = reAbs.exec(html)) !== null) addResult(m[1], m[2], m[3]);
|
| 671 |
+
while ((m = reRel.exec(html)) !== null) addResult(m[1], m[2], m[3]);
|
| 672 |
+
try { console.log('[uakinogo/search] results:', results.length, results[0] ? results[0].url : 'none'); } catch (e) {}
|
| 673 |
jsonResp(res, { ok: true, results: results.slice(0, 10) });
|
| 674 |
}).catch(e => jsonResp(res, { ok: false, error: e.message }, 500));
|
| 675 |
return;
|