init
This commit is contained in:
10
Dockerfile
Normal file
10
Dockerfile
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
FROM node:20-alpine
|
||||||
|
|
||||||
|
WORKDIR /app
|
||||||
|
COPY package*.json ./
|
||||||
|
RUN npm install --only=production
|
||||||
|
COPY server.js config.json ./
|
||||||
|
|
||||||
|
EXPOSE 3000
|
||||||
|
CMD ["node", "server.js"]
|
||||||
|
|
||||||
5
README.md
Normal file
5
README.md
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
# AniX Share
|
||||||
|
|
||||||
|
Сервис для создания ссылки на аниме/профиль/коллекцию в AniX/Anixart.
|
||||||
|
Все настройки находятся в `config.json`. Для запуска используется docker.
|
||||||
|
|
||||||
12
config.json
Normal file
12
config.json
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
{
|
||||||
|
"port": 3000,
|
||||||
|
"targetUrl": "https://anix.0x174.su",
|
||||||
|
"auth": {
|
||||||
|
"username": "anime",
|
||||||
|
"password": "just_watch"
|
||||||
|
},
|
||||||
|
"redirectDelay": 3000,
|
||||||
|
"timeout": 5000,
|
||||||
|
"userAgent": "MetaFetcherBot/1.0"
|
||||||
|
}
|
||||||
|
|
||||||
13
package-lock.json
generated
Normal file
13
package-lock.json
generated
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
{
|
||||||
|
"name": "anix-share",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"lockfileVersion": 3,
|
||||||
|
"requires": true,
|
||||||
|
"packages": {
|
||||||
|
"": {
|
||||||
|
"name": "anix-share",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"license": "MIT"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
24
package.json
Normal file
24
package.json
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
{
|
||||||
|
"name": "anix-share",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"description": "",
|
||||||
|
"main": "server.js",
|
||||||
|
"dependencies": {
|
||||||
|
"express": "^4.19.0",
|
||||||
|
"axios": "^1.7.0",
|
||||||
|
"cheerio": "^1.0.0"
|
||||||
|
},
|
||||||
|
"scripts": {
|
||||||
|
"test": "echo \"Error: no test specified\" && exit 1",
|
||||||
|
"start": "node server.js"
|
||||||
|
},
|
||||||
|
"repository": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "git.0x174.su/wowlikon/anix-share"
|
||||||
|
},
|
||||||
|
"keywords": [
|
||||||
|
"anix"
|
||||||
|
],
|
||||||
|
"author": "wowlikon",
|
||||||
|
"license": "MIT"
|
||||||
|
}
|
||||||
51
server.js
Normal file
51
server.js
Normal file
@@ -0,0 +1,51 @@
|
|||||||
|
import express from 'express';
|
||||||
|
import axios from 'axios';
|
||||||
|
import * as cheerio from 'cheerio';
|
||||||
|
import fs from 'fs';
|
||||||
|
|
||||||
|
const config = JSON.parse(fs.readFileSync('./config.json', 'utf-8'));
|
||||||
|
const { port, targetUrl, auth, redirectDelay, timeout, userAgent } = config;
|
||||||
|
|
||||||
|
const app = express();
|
||||||
|
|
||||||
|
app.get('*', async (req, res) => {
|
||||||
|
try {
|
||||||
|
const path = req.path === '/' ? '' : req.path;
|
||||||
|
const fullUrl = new URL(path, targetUrl).toString();
|
||||||
|
const response = await axios.get(fullUrl, {
|
||||||
|
auth, timeout,
|
||||||
|
headers: {'User-Agent': userAgent}
|
||||||
|
});
|
||||||
|
|
||||||
|
const $ = cheerio.load(response.data);
|
||||||
|
const metas = [];
|
||||||
|
$('meta').each((_, el) => {metas.push(el.attribs);});
|
||||||
|
|
||||||
|
res.send(`
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="ru">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8" />
|
||||||
|
<title>Meta Redirect</title>
|
||||||
|
${metas.map(m => `<meta ${Object.entries(m).map(([k, v]) => `${k}="${v}"`).join(' ')}>`).join('\n')}
|
||||||
|
<script>
|
||||||
|
setTimeout(() => {window.location.href = ${JSON.stringify(fullUrl)};}, ${redirectDelay});
|
||||||
|
</script>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<h1>Anix</h1>
|
||||||
|
<p>Редирект через ${redirectDelay / 1000} сек на <a href="${fullUrl}">${fullUrl}</a></p>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
`);
|
||||||
|
} catch (err) {
|
||||||
|
console.error('Ошибка:', err.message);
|
||||||
|
res.status(500).send(`<h1>Ошибка при загрузке ${req.path}</h1><pre>${err.message}</pre>`);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
app.listen(port, () => {
|
||||||
|
console.log(`🚀 Сервер запущен: http://localhost:${port}`);
|
||||||
|
console.log(`🔗 Пример: http://localhost:${port}/news`);
|
||||||
|
});
|
||||||
|
|
||||||
Reference in New Issue
Block a user