Skip to content

Commit 94c45cb

Browse files
committed
feat(animeowl): Add Animeowl provider and update environment configuration
1 parent 1fd1659 commit 94c45cb

File tree

3 files changed

+229
-0
lines changed

3 files changed

+229
-0
lines changed

.env.example

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,5 @@ GOGOANIME_URL=Gogoanime custom url (optional)
1111
ZORO_URL=Zoro custom url (optional)
1212
ANIMEKAI_URL=Animekai custom url (optional)
1313
MULTIMOVIES_URL=Multimovies custom url (optional)
14+
ANIMEOWL_URL=Animeowl custom url (optional)
1415
NODE_ENV=Environment (optional) (DEMO or PROD)

src/routes/anime/animeowl.ts

Lines changed: 226 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,226 @@
1+
import { FastifyRequest, FastifyReply, FastifyInstance, RegisterOptions } from 'fastify';
2+
import { ANIME } from '@consumet/extensions';
3+
import { StreamingServers, SubOrSub } from '@consumet/extensions/dist/models';
4+
5+
const routes = async (fastify: FastifyInstance, options: RegisterOptions) => {
6+
const animeowl = new ANIME.AnimeOwl(process.env.ANIMEOWL_URL);
7+
let baseUrl = 'https://animeowl.me';
8+
if (process.env.ANIMEOWL_URL) {
9+
baseUrl = `https://${process.env.ANIMEOWL_URL}`;
10+
}
11+
12+
fastify.get('/', (_, rp) => {
13+
rp.status(200).send({
14+
intro: `Welcome to the animeowl provider: check out the provider's website @ ${baseUrl}`,
15+
routes: [
16+
'/:query',
17+
'/recent-episodes',
18+
'/top-airing',
19+
'/spotlight',
20+
'/search-suggestions/:query',
21+
'/info?id',
22+
'/watch/:episodeId',
23+
'/watch?episodeId',
24+
'/genre/list',
25+
'/genre/:genre',
26+
'/movies',
27+
'/ona',
28+
'/ova',
29+
'/specials',
30+
'/tv',
31+
],
32+
documentation: 'https://docs.consumet.org/#tag/animeowl',
33+
});
34+
});
35+
36+
fastify.get('/:query', async (request: FastifyRequest, reply: FastifyReply) => {
37+
const query = (request.params as { query: string }).query;
38+
39+
const page = (request.query as { page: number }).page;
40+
41+
const res = await animeowl.search(query, page);
42+
43+
reply.status(200).send(res);
44+
});
45+
46+
fastify.get(
47+
'/recent-episodes',
48+
async (request: FastifyRequest, reply: FastifyReply) => {
49+
const page = (request.query as { page: number }).page;
50+
51+
const res = await animeowl.fetchRecentlyUpdated(page);
52+
53+
reply.status(200).send(res);
54+
},
55+
);
56+
57+
fastify.get('/top-airing', async (request: FastifyRequest, reply: FastifyReply) => {
58+
const page = (request.query as { page: number }).page;
59+
60+
const res = await animeowl.fetchTopAiring(page);
61+
62+
reply.status(200).send(res);
63+
});
64+
65+
66+
fastify.get('/spotlight', async (request: FastifyRequest, reply: FastifyReply) => {
67+
const res = await animeowl.fetchSpotlight();
68+
69+
reply.status(200).send(res);
70+
});
71+
72+
fastify.get(
73+
'/search-suggestions/:query',
74+
async (request: FastifyRequest, reply: FastifyReply) => {
75+
const query = (request.params as { query: string }).query;
76+
77+
const res = await animeowl.fetchSearchSuggestions(query);
78+
79+
reply.status(200).send(res);
80+
},
81+
);
82+
83+
fastify.get('/info', async (request: FastifyRequest, reply: FastifyReply) => {
84+
const id = (request.query as { id: string }).id;
85+
86+
if (typeof id === 'undefined')
87+
return reply.status(400).send({ message: 'id is required' });
88+
89+
try {
90+
const res = await animeowl
91+
.fetchAnimeInfo(id)
92+
.catch((err) => reply.status(404).send({ message: err }));
93+
94+
return reply.status(200).send(res);
95+
} catch (err) {
96+
reply
97+
.status(500)
98+
.send({ message: 'Something went wrong. Contact developer for help.' });
99+
}
100+
});
101+
const watch = async (request: FastifyRequest, reply: FastifyReply) => {
102+
let episodeId = (request.params as { episodeId: string }).episodeId;
103+
if (!episodeId) {
104+
episodeId = (request.query as { episodeId: string }).episodeId;
105+
}
106+
107+
const server = (request.query as { server: string }).server as StreamingServers;
108+
let dub = (request.query as { dub?: string | boolean }).dub;
109+
if (dub === 'true' || dub === '1') dub = true;
110+
else dub = false;
111+
112+
if (server && !Object.values(StreamingServers).includes(server))
113+
return reply.status(400).send({ message: 'server is invalid' });
114+
115+
if (typeof episodeId === 'undefined')
116+
return reply.status(400).send({ message: 'id is required' });
117+
118+
try {
119+
const res = await animeowl
120+
.fetchEpisodeSources(
121+
episodeId,
122+
server,
123+
dub === true ? SubOrSub.DUB : SubOrSub.SUB,
124+
)
125+
.catch((err) => reply.status(404).send({ message: err }));
126+
127+
reply.status(200).send(res);
128+
} catch (err) {
129+
reply
130+
.status(500)
131+
.send({ message: 'Something went wrong. Contact developer for help.' });
132+
}
133+
};
134+
fastify.get('/watch', watch);
135+
fastify.get('/watch/:episodeId', watch);
136+
137+
fastify.get('/genre/list', async (_, reply) => {
138+
try {
139+
const res = await animeowl.fetchGenres();
140+
reply.status(200).send(res);
141+
} catch (error) {
142+
reply.status(500).send({
143+
message: 'Something went wrong. Contact developer for help.',
144+
});
145+
}
146+
});
147+
148+
fastify.get('/genre/:genre', async (request: FastifyRequest, reply: FastifyReply) => {
149+
const genre = (request.params as { genre: string }).genre;
150+
const page = (request.query as { page: number }).page;
151+
152+
if (typeof genre === 'undefined')
153+
return reply.status(400).send({ message: 'genre is required' });
154+
155+
try {
156+
const res = await animeowl.genreSearch(genre, page);
157+
reply.status(200).send(res);
158+
} catch (error) {
159+
reply.status(500).send({
160+
message: 'Something went wrong. Contact developer for help.',
161+
});
162+
}
163+
});
164+
165+
fastify.get('/movies', async (request: FastifyRequest, reply: FastifyReply) => {
166+
const page = (request.query as { page: number }).page;
167+
try {
168+
const res = await animeowl.fetchMovie(page);
169+
reply.status(200).send(res);
170+
} catch (err) {
171+
reply
172+
.status(500)
173+
.send({ message: 'Something went wrong. Contact developer for help.' });
174+
}
175+
});
176+
177+
fastify.get('/ona', async (request: FastifyRequest, reply: FastifyReply) => {
178+
const page = (request.query as { page: number }).page;
179+
try {
180+
const res = await animeowl.fetchONA(page);
181+
reply.status(200).send(res);
182+
} catch (err) {
183+
reply
184+
.status(500)
185+
.send({ message: 'Something went wrong. Contact developer for help.' });
186+
}
187+
});
188+
189+
fastify.get('/ova', async (request: FastifyRequest, reply: FastifyReply) => {
190+
const page = (request.query as { page: number }).page;
191+
try {
192+
const res = await animeowl.fetchOVA(page);
193+
reply.status(200).send(res);
194+
} catch (err) {
195+
reply
196+
.status(500)
197+
.send({ message: 'Something went wrong. Contact developer for help.' });
198+
}
199+
});
200+
201+
fastify.get('/specials', async (request: FastifyRequest, reply: FastifyReply) => {
202+
const page = (request.query as { page: number }).page;
203+
try {
204+
const res = await animeowl.fetchSpecial(page);
205+
reply.status(200).send(res);
206+
} catch (err) {
207+
reply
208+
.status(500)
209+
.send({ message: 'Something went wrong. Contact developer for help.' });
210+
}
211+
});
212+
213+
fastify.get('/tv', async (request: FastifyRequest, reply: FastifyReply) => {
214+
const page = (request.query as { page: number }).page;
215+
try {
216+
const res = await animeowl.fetchTV(page);
217+
reply.status(200).send(res);
218+
} catch (err) {
219+
reply
220+
.status(500)
221+
.send({ message: 'Something went wrong. Contact developer for help.' });
222+
}
223+
});
224+
};
225+
226+
export default routes;

src/routes/anime/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import bilibili from './bilibili';
1212
import marin from './marin';
1313
import anix from './anix';
1414
import animekai from './animekai';
15+
import animeowl from './animeowl';
1516

1617
const routes = async (fastify: FastifyInstance, options: RegisterOptions) => {
1718
await fastify.register(gogoanime, { prefix: '/gogoanime' });
@@ -25,6 +26,7 @@ const routes = async (fastify: FastifyInstance, options: RegisterOptions) => {
2526
await fastify.register(marin, { prefix: '/marin' });
2627
await fastify.register(anix, { prefix: '/anix' });
2728
await fastify.register(animekai, { prefix: '/animekai' });
29+
await fastify.register(animeowl, { prefix: '/animeowl' });
2830

2931
fastify.get('/', async (request: any, reply: any) => {
3032
reply.status(200).send('Welcome to Consumet Anime 🗾');

0 commit comments

Comments
 (0)