Update server.js
Browse files
server.js
CHANGED
@@ -1,5 +1,6 @@
|
|
1 |
const express = require('express');
|
2 |
const axios = require('axios');
|
|
|
3 |
const cheerio = require('cheerio');
|
4 |
|
5 |
const app = express();
|
@@ -54,5 +55,56 @@ async function searchGogoanime(animeTitle, episodeNumber) {
|
|
54 |
}
|
55 |
}
|
56 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
57 |
// Start API Server
|
58 |
app.listen(PORT, () => console.log(`Server running on http://localhost:${PORT}`));
|
|
|
1 |
const express = require('express');
|
2 |
const axios = require('axios');
|
3 |
+
const crypto = require('crypto');
|
4 |
const cheerio = require('cheerio');
|
5 |
|
6 |
const app = express();
|
|
|
55 |
}
|
56 |
}
|
57 |
|
58 |
+
app.get('/q', (req, res) => {
|
59 |
+
const filemoonUrl = req.query.q;
|
60 |
+
|
61 |
+
if (!filemoonUrl || !filemoonUrl.startsWith('https://filemoon.')) {
|
62 |
+
return res.status(400).send('Invalid or missing Filemoon URL.');
|
63 |
+
}
|
64 |
+
|
65 |
+
// Generate a random 16-character hex path
|
66 |
+
const randomPath = crypto.randomBytes(8).toString('hex');
|
67 |
+
|
68 |
+
urlMap.set(randomPath, filemoonUrl);
|
69 |
+
res.send(`${req.protocol}://${req.get('host')}/${randomPath}`);
|
70 |
+
});
|
71 |
+
|
72 |
+
// Dynamic route to serve the embedded Filemoon player
|
73 |
+
app.get('/vid/:id', (req, res) => {
|
74 |
+
const filemoonUrl = urlMap.get(req.params.id);
|
75 |
+
|
76 |
+
if (!filemoonUrl) {
|
77 |
+
return res.status(404).send('Not found');
|
78 |
+
}
|
79 |
+
|
80 |
+
// Convert /s/ URL to /e/ for embedding
|
81 |
+
const embedUrl = filemoonUrl.replace('/s/', '/e/');
|
82 |
+
|
83 |
+
res.send(`
|
84 |
+
<!DOCTYPE html>
|
85 |
+
<html>
|
86 |
+
<head>
|
87 |
+
<title>Filemoon Embed</title>
|
88 |
+
<style>
|
89 |
+
body, html {
|
90 |
+
margin: 0;
|
91 |
+
padding: 0;
|
92 |
+
height: 100%;
|
93 |
+
background-color: #000;
|
94 |
+
}
|
95 |
+
iframe {
|
96 |
+
width: 100%;
|
97 |
+
height: 100%;
|
98 |
+
border: none;
|
99 |
+
}
|
100 |
+
</style>
|
101 |
+
</head>
|
102 |
+
<body>
|
103 |
+
<iframe src="${embedUrl}" allowfullscreen></iframe>
|
104 |
+
</body>
|
105 |
+
</html>
|
106 |
+
`);
|
107 |
+
});
|
108 |
+
|
109 |
// Start API Server
|
110 |
app.listen(PORT, () => console.log(`Server running on http://localhost:${PORT}`));
|