shirayuki-anime-scraper-api 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. package/Dockerfile +14 -0
  2. package/LICENSE +24 -0
  3. package/README.md +539 -0
  4. package/config/database.js +37 -0
  5. package/index.js +63 -0
  6. package/models/Episode.js +49 -0
  7. package/models/Schedule.js +50 -0
  8. package/package.json +46 -0
  9. package/routes/anime-list.js +67 -0
  10. package/routes/episodeStream.js +64 -0
  11. package/routes/genre.js +67 -0
  12. package/routes/home.js +30 -0
  13. package/routes/monthly.js +37 -0
  14. package/routes/schedule.js +174 -0
  15. package/routes/search.js +79 -0
  16. package/routes/top10.js +37 -0
  17. package/routes/weekly.js +37 -0
  18. package/save.txt +431 -0
  19. package/scrapeanime/A-Z/AnimeList/filter.js +43 -0
  20. package/scrapeanime/A-Z/Genre/genre.js +42 -0
  21. package/scrapeanime/AnimeDetails/animedetails.js +73 -0
  22. package/scrapeanime/Browse/Search/search.js +119 -0
  23. package/scrapeanime/Browse/Suggestion/suggestion.js +50 -0
  24. package/scrapeanime/Leaderboard/Monthly/scrapeHiAnimeMonthlyTop10.js +137 -0
  25. package/scrapeanime/Leaderboard/Top/scrapeHiAnimeTop10.js +125 -0
  26. package/scrapeanime/Leaderboard/Weekly/scrapeHiAnimeWeeklyTop10.js +188 -0
  27. package/scrapeanime/Schedule/schedule.js +174 -0
  28. package/scrapeanime/SingleEpisode/scrapeSingleEpisode.js +496 -0
  29. package/scrapeanime/homepage/latest/latest.js +118 -0
  30. package/scrapeanime/homepage/most_favorite/mostFavorite.js +55 -0
  31. package/scrapeanime/homepage/most_popular/mostPopular.js +55 -0
  32. package/scrapeanime/homepage/recently_updated/recentlyUpdated.js +56 -0
  33. package/scrapeanime/homepage/scrapeAnimeDetails.js +128 -0
  34. package/scrapeanime/homepage/scrapehomepage.js +2 -0
  35. package/scrapeanime/homepage/scrapeservice.js +158 -0
  36. package/scrapeanime/homepage/slider/slider.js +151 -0
  37. package/scrapeanime/homepage/top_airing/topAiring.js +55 -0
  38. package/scrapeanime/homepage/trending/trending.js +59 -0
  39. package/service/scraperService.js +38 -0
package/Dockerfile ADDED
@@ -0,0 +1,14 @@
1
+ FROM ghcr.io/puppeteer/puppeteer:24.10.1
2
+
3
+ ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true \
4
+ NODE_ENV=production
5
+
6
+ WORKDIR /usr/src/app
7
+
8
+ COPY package*.json ./
9
+
10
+ RUN npm ci
11
+
12
+ COPY . .
13
+
14
+ CMD ["node", "index.js"]
package/LICENSE ADDED
@@ -0,0 +1,24 @@
1
+ BSD 2-Clause License
2
+
3
+ Copyright (c) 2025, Ananda Dev Nath
4
+
5
+ Redistribution and use in source and binary forms, with or without
6
+ modification, are permitted provided that the following conditions are met:
7
+
8
+ 1. Redistributions of source code must retain the above copyright notice, this
9
+ list of conditions and the following disclaimer.
10
+
11
+ 2. Redistributions in binary form must reproduce the above copyright notice,
12
+ this list of conditions and the following disclaimer in the documentation
13
+ and/or other materials provided with the distribution.
14
+
15
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
16
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
19
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
21
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
22
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
23
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
24
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package/README.md ADDED
@@ -0,0 +1,539 @@
1
+ # 🌸 Shirayuki Anime Scraper API
2
+
3
+ It is a anime scraping API that provides anime information, streaming links, and search functionality from HiAnime and 123animehub.
4
+
5
+ ## 🎯 Goals of this Website
6
+
7
+ - **🤖 AI Agent for Animes** - Intelligent recommendation system that learns user preferences and suggests personalized anime content
8
+ - **📊 Ranking System** - Comprehensive ranking algorithms that analyze popularity, ratings, and user engagement to provide accurate anime rankings
9
+ - **📝 Auto Watchlist Save** - Seamless integration with MyAnimeList website for automatic watchlist synchronization and progress tracking
10
+
11
+ ## ✨ Features
12
+
13
+ - 🏠 Homepage with trending anime
14
+ - 🔍 Search anime by title
15
+ - 📺 Get streaming links for episodes
16
+ - 🎭 Browse anime by genre
17
+ - 📝 A-Z anime listing
18
+ - 🏆 Top 10 anime rankings (daily, weekly, monthly)
19
+ - 💡 Search suggestions
20
+ - 📖 Detailed anime information
21
+ - ⚡ Fast and reliable scraping
22
+
23
+ ## 🚀 Installation
24
+
25
+ 1. Clone the repository:
26
+
27
+ ```bash
28
+ git clone https://github.com/Anandadevnath/anime-mega-stream-api.git
29
+ cd shirayuki-backend
30
+ ```
31
+
32
+ 2. Install dependencies:
33
+
34
+ ```bash
35
+ npm install
36
+ ```
37
+
38
+ 3. Start the server:
39
+
40
+ ```bash
41
+ npm start
42
+ ```
43
+
44
+ The API will be available at `http://localhost:5000`
45
+
46
+ ## 🎯 Usage
47
+
48
+ The API provides RESTful endpoints for accessing anime data. All responses are in JSON format.
49
+
50
+ Base URL: `http://localhost:5000`
51
+
52
+ ## 📍 API Endpoints
53
+
54
+ ### 🏠 Homepage
55
+
56
+ - **GET** `/home`
57
+ - Get trending anime, latest releases, popular anime, and more
58
+
59
+ ### 🔍 Search
60
+
61
+ - **GET** `/search?keyword={query}`
62
+ - Search for anime by title
63
+ - **Parameters:**
64
+ - `keyword` (required): Search query
65
+
66
+ ### 💡 Search Suggestions
67
+
68
+ - **GET** `/search/suggestions?q={query}`
69
+ - Get search suggestions for anime titles
70
+ - **Parameters:**
71
+ - `q` (required): Query for suggestions
72
+
73
+ ### 🎭 Browse by Genre
74
+
75
+ - **GET** `/genere/{genre}?page={page}`
76
+ - Get anime by specific genre
77
+ - **Parameters:**
78
+ - `genre` (required): Genre name (e.g., Action, Comedy, Romance)
79
+ - `page` (optional): Page number (default: 1)
80
+
81
+ ### 📝 A-Z Anime Listing
82
+
83
+ - **GET** `/az-all-anime/{letter}?page={page}`
84
+ - Get anime starting with specific letter
85
+ - **Parameters:**
86
+ - `letter` (required): Letter or "all" for all anime
87
+ - `page` (optional): Page number (default: 1)
88
+
89
+ ### 🏆 Top Rankings
90
+
91
+ - **GET** `/top10` - Daily top 10 anime
92
+ - **GET** `/weekly10` - Weekly top 10 anime
93
+ - **GET** `/monthly10` - Monthly top 10 anime
94
+
95
+ ### 📺 Episode Streaming
96
+
97
+ - **GET** `/episode-stream?id={anime_id}&ep={episode_number}`
98
+ - Get streaming links for specific episode
99
+ - **Parameters:**
100
+ - `id` (required): Anime ID/slug
101
+ - `ep` (required): Episode number
102
+
103
+ ### 📖 Anime Details
104
+
105
+ - **GET** `/anime/{slug}`
106
+ - Get detailed information about specific anime
107
+ - **Parameters:**
108
+ - `slug` (required): Anime slug/identifier
109
+
110
+ ## 📊 Example Responses
111
+
112
+ ### Search Results
113
+
114
+ ```http
115
+ GET /search?keyword=one%20piece
116
+ ```
117
+
118
+ ```json
119
+ {
120
+ "success": true,
121
+ "total_results": 28,
122
+ "data": [
123
+ {
124
+ "title": "One Piece",
125
+ "sub": true,
126
+ "dub": false,
127
+ "image": "https://123animehub.cc/imgs/poster/one-piece.jpg",
128
+ "episodes": "1145"
129
+ },
130
+ {
131
+ "title": "One Piece (Dub)",
132
+ "sub": false,
133
+ "dub": true,
134
+ "image": "https://123animehub.cc/imgs/poster/one-piece-dub.jpg",
135
+ "episodes": "1133"
136
+ }
137
+ ],
138
+ "extraction_time_seconds": 1.224,
139
+ "message": "Search results for \"one piece\"",
140
+ "timestamp": "2025-10-08T16:54:26.438Z",
141
+ "source_url": "https://123animehub.cc/search?keyword=one%20piece"
142
+ }
143
+ ```
144
+
145
+ ### Genre Listing
146
+
147
+ ```http
148
+ GET /genere/Action?page=1
149
+ ```
150
+
151
+ ```json
152
+ {
153
+ "success": true,
154
+ "data": [
155
+ {
156
+ "index": 1,
157
+ "title": "Attack on Titan",
158
+ "image": "https://123animehub.cc/imgs/poster/attack-on-titan.jpg",
159
+ "sub": true,
160
+ "dub": true,
161
+ "episodes": "87"
162
+ },
163
+ {
164
+ "index": 2,
165
+ "title": "Demon Slayer",
166
+ "image": "https://123animehub.cc/imgs/poster/demon-slayer.jpg",
167
+ "sub": true,
168
+ "dub": true,
169
+ "episodes": "44"
170
+ }
171
+ ],
172
+ "extraction_time_seconds": 0.892,
173
+ "message": "Anime list for genre 'Action' - Page 1",
174
+ "timestamp": "2025-10-08T16:54:26.438Z"
175
+ }
176
+ ```
177
+
178
+ ### A-Z Anime Listing
179
+
180
+ ```http
181
+ GET /az-all-anime/all?page=1
182
+ ```
183
+
184
+ ```json
185
+ {
186
+ "success": true,
187
+ "data": [
188
+ {
189
+ "index": 1,
190
+ "title": "86 EIGHTY-SIX",
191
+ "image": "https://123animehub.cc/imgs/poster/86-eighty-six.jpg",
192
+ "sub": true,
193
+ "dub": true,
194
+ "episodes": "23"
195
+ }
196
+ ],
197
+ "pagination": {
198
+ "current_page": 1,
199
+ "total_found": 36,
200
+ "total_counts": 15420,
201
+ "has_next_page": true,
202
+ "has_previous_page": false,
203
+ "next_page": 2,
204
+ "previous_page": null
205
+ },
206
+ "extraction_time_seconds": 1.156,
207
+ "message": "Anime list for letter 'all' - Page 1",
208
+ "timestamp": "2025-10-08T16:54:26.438Z"
209
+ }
210
+ ```
211
+
212
+ ### Top 10 Rankings
213
+
214
+ ```http
215
+ GET /top10
216
+ ```
217
+
218
+ ```json
219
+ {
220
+ "success": true,
221
+ "data": [
222
+ {
223
+ "index": 1,
224
+ "title": "Demon Slayer: Kimetsu no Yaiba",
225
+ "image": "https://123animehub.cc/imgs/poster/demon-slayer.jpg",
226
+ "anime_redirect_link": "/anime/demon-slayer",
227
+ "episodes": "44",
228
+ "audio_type": "SUB"
229
+ }
230
+ ],
231
+ "extraction_time_seconds": 2.145,
232
+ "message": "Top 10 anime rankings",
233
+ "timestamp": "2025-10-08T16:54:26.438Z"
234
+ }
235
+ ```
236
+
237
+ ### Episode Streaming
238
+
239
+ ```http
240
+ GET /episode-stream?id=one-piece-dub&ep=1
241
+ ```
242
+
243
+ ```json
244
+ {
245
+ "success": true,
246
+ "data": {
247
+ "episode": 1,
248
+ "anime_title": "One Piece (Dub)",
249
+ "streaming_links": [
250
+ {
251
+ "server": "mp4upload",
252
+ "url": "https://mp4upload.com/embed-xyz123.html",
253
+ "quality": "720p"
254
+ },
255
+ {
256
+ "server": "streamtape",
257
+ "url": "https://streamtape.com/e/xyz123",
258
+ "quality": "480p"
259
+ }
260
+ ]
261
+ },
262
+ "extraction_time_seconds": 1.892,
263
+ "message": "Streaming links for One Piece (Dub) - Episode 1",
264
+ "timestamp": "2025-10-08T16:54:26.438Z"
265
+ }
266
+ ```
267
+
268
+ ### Search Suggestions
269
+
270
+ ```http
271
+ GET /search/suggestions?q=demon
272
+ ```
273
+
274
+ ```json
275
+ {
276
+ "success": true,
277
+ "data": [
278
+ {
279
+ "index": 1,
280
+ "title": "Demon Slayer: Kimetsu no Yaiba",
281
+ "image": "https://123animehub.cc/imgs/poster/demon-slayer.jpg",
282
+ "episode": "44",
283
+ "calendar_date": "2023",
284
+ "status": "completed",
285
+ "type": "sub"
286
+ }
287
+ ],
288
+ "extraction_time_seconds": 0.756,
289
+ "message": "Search suggestions for \"demon\"",
290
+ "timestamp": "2025-10-08T16:54:26.438Z"
291
+ }
292
+ ```
293
+
294
+ ### Homepage Data
295
+
296
+ ```http
297
+ GET /home
298
+ ```
299
+
300
+ ```json
301
+ {
302
+ "success": true,
303
+ "data": {
304
+ "trending": [
305
+ {
306
+ "title": "Jujutsu Kaisen",
307
+ "image": "https://123animehub.cc/imgs/poster/jujutsu-kaisen.jpg",
308
+ "episode": "24",
309
+ "status": "completed"
310
+ }
311
+ ],
312
+ "latest": [
313
+ {
314
+ "title": "Chainsaw Man",
315
+ "image": "https://123animehub.cc/imgs/poster/chainsaw-man.jpg",
316
+ "episode": "12",
317
+ "status": "airing"
318
+ }
319
+ ],
320
+ "popular": [
321
+ {
322
+ "title": "Attack on Titan",
323
+ "image": "https://123animehub.cc/imgs/poster/attack-on-titan.jpg",
324
+ "episode": "87",
325
+ "status": "completed"
326
+ }
327
+ ]
328
+ },
329
+ "extraction_time_seconds": 2.341,
330
+ "message": "Homepage data retrieved successfully",
331
+ "timestamp": "2025-10-08T16:54:26.438Z"
332
+ }
333
+ ```
334
+
335
+ ### Weekly Top 10 Rankings
336
+
337
+ ```http
338
+ GET /weekly10
339
+ ```
340
+
341
+ ```json
342
+ {
343
+ "success": true,
344
+ "data": [
345
+ {
346
+ "index": 1,
347
+ "title": "Frieren: Beyond Journey's End",
348
+ "image": "https://123animehub.cc/imgs/poster/frieren.jpg",
349
+ "anime_redirect_link": "/anime/frieren",
350
+ "episodes": "28",
351
+ "audio_type": "SUB"
352
+ },
353
+ {
354
+ "index": 2,
355
+ "title": "Demon Slayer: Kimetsu no Yaiba",
356
+ "image": "https://123animehub.cc/imgs/poster/demon-slayer.jpg",
357
+ "anime_redirect_link": "/anime/demon-slayer",
358
+ "episodes": "44",
359
+ "audio_type": "SUB"
360
+ }
361
+ ],
362
+ "extraction_time_seconds": 1.892,
363
+ "message": "Weekly top 10 anime rankings",
364
+ "timestamp": "2025-10-08T16:54:26.438Z"
365
+ }
366
+ ```
367
+
368
+ ### Monthly Top 10 Rankings
369
+
370
+ ```http
371
+ GET /monthly10
372
+ ```
373
+
374
+ ```json
375
+ {
376
+ "success": true,
377
+ "data": [
378
+ {
379
+ "index": 1,
380
+ "title": "One Piece",
381
+ "image": "https://123animehub.cc/imgs/poster/one-piece.jpg",
382
+ "anime_redirect_link": "/anime/one-piece",
383
+ "episodes": "1145",
384
+ "audio_type": "SUB"
385
+ },
386
+ {
387
+ "index": 2,
388
+ "title": "Attack on Titan",
389
+ "image": "https://123animehub.cc/imgs/poster/attack-on-titan.jpg",
390
+ "anime_redirect_link": "/anime/attack-on-titan",
391
+ "episodes": "87",
392
+ "audio_type": "SUB"
393
+ }
394
+ ],
395
+ "extraction_time_seconds": 2.156,
396
+ "message": "Monthly top 10 anime rankings",
397
+ "timestamp": "2025-10-08T16:54:26.438Z"
398
+ }
399
+ ```
400
+
401
+ ### Anime Details
402
+
403
+ ```http
404
+ GET /anime/one-piece-dub
405
+ ```
406
+
407
+ ```json
408
+ {
409
+ "success": true,
410
+ "data": {
411
+ "title": "One Piece (Dub)",
412
+ "anime_id": "one-piece-dub",
413
+ "image": "https://123animehub.cc/imgs/poster/one-piece-dub.jpg",
414
+ "description": "Monkey D. Luffy refuses to let anyone or anything stand in the way of his quest to become the king of all pirates...",
415
+ "status": "Ongoing",
416
+ "release_date": "1999",
417
+ "genres": ["Action", "Adventure", "Comedy", "Drama", "Fantasy", "Shounen"],
418
+ "total_episodes": "1133",
419
+ "rating": "9.0",
420
+ "studio": "Toei Animation",
421
+ "audio_type": "DUB",
422
+ "episodes": [
423
+ {
424
+ "episode_number": "1",
425
+ "episode_title": "I'm Luffy! The Man Who's Gonna Be King of the Pirates!",
426
+ "episode_url": "/anime/one-piece-dub/episode/1"
427
+ },
428
+ {
429
+ "episode_number": "2",
430
+ "episode_title": "Enter the Great Swordsman! Pirate Hunter Roronoa Zoro!",
431
+ "episode_url": "/anime/one-piece-dub/episode/2"
432
+ }
433
+ ]
434
+ },
435
+ "extraction_time_seconds": 3.245,
436
+ "message": "Anime details for 'one-piece-dub'",
437
+ "timestamp": "2025-10-08T16:54:26.438Z"
438
+ }
439
+ ```
440
+
441
+ ### Single Episode Streaming (Updated Format)
442
+
443
+ ```http
444
+ GET /episode-stream?id=one-piece-dub&ep=1000
445
+ ```
446
+
447
+ ````json
448
+ {
449
+ "success": true,
450
+ "anime_id": "one-piece-dub",
451
+ "episode": "1000",
452
+ "data": {
453
+ "title": "One Piece Dub",
454
+ "episode_number": "1000",
455
+ "streaming_link": "https://play.bunnycdn.to/embed-3/UWxwb05ERkJXU1pUV1pXMFVrNEFBQXIv...",
456
+ "range_id": "997-1046",
457
+ "all_ranges": ["1-46", "47-96", "97-146", "147-196", "197-246", "247-296", "297-346", "347-396", "397-446", "447-496", "497-546", "547-596", "597-646", "647-696", "697-746", "747-796", "797-846", "847-896", "897-946", "947-996", "997-1046"]
458
+ },
459
+ "extraction_time_seconds": 5.408
460
+ }
461
+
462
+ ## ⚠️ Error Handling
463
+
464
+ All error responses follow this format:
465
+
466
+ ```json
467
+ {
468
+ "success": false,
469
+ "error": "Error message description",
470
+ "extraction_time_seconds": 0.123,
471
+ "timestamp": "2025-10-08T16:54:26.438Z"
472
+ }
473
+ ````
474
+
475
+ ## 🛠️ Technologies Used
476
+
477
+ - **Node.js** - Runtime environment
478
+ - **Express.js** - Web framework
479
+ - **Axios** - HTTP client for web scraping
480
+ - **Cheerio** - Server-side HTML parsing
481
+ - **Puppeteer** - Browser automation for complex scraping
482
+
483
+ ## � Deployment
484
+
485
+ You can deploy it on any cloud service that supports Puppeteer
486
+
487
+ ### ☁️ Cloud Platforms with Puppeteer Support
488
+
489
+ 1. **Railway** ⭐ (Recommended)
490
+ - Built-in Puppeteer support
491
+ - Easy deployment with Git integration
492
+ - Automatic SSL certificates
493
+ - Generous free tier
494
+
495
+ 2. **Render**
496
+ - Native Puppeteer support
497
+ - Free tier available
498
+ - Automatic builds from GitHub
499
+ - Built-in environment variables
500
+
501
+ 3. **Heroku**
502
+ - Requires buildpack for Puppeteer
503
+ - Add `heroku/nodejs` and `jontewks/puppeteer` buildpacks
504
+ - Free tier discontinued, but hobby tier available
505
+
506
+
507
+ ### 📦 Deployment Configuration
508
+
509
+ For most platforms, add these environment variables:
510
+ ```bash
511
+ NODE_ENV=production
512
+ PORT=5000
513
+ PUPPETEER_ARGS=--no-sandbox,--disable-setuid-sandbox,--disable-dev-shm-usage
514
+ ```
515
+
516
+ ### 🐳 Docker Deployment
517
+
518
+ The included `Dockerfile` is optimized for cloud deployment:
519
+ ```bash
520
+ docker build -t shirayuki-api .
521
+ docker run -p 5000:5000 shirayuki-api
522
+ ```
523
+
524
+ ## �📄 License
525
+
526
+ This project is licensed under the ISC License - see the [LICENSE](LICENSE) file for details.
527
+
528
+ ## ⚠️ Disclaimer
529
+
530
+ This API is for educational and personal use only. Please respect the terms of service of the scraped websites and use responsibly.
531
+
532
+ ## 🔗 Links
533
+
534
+ - [GitHub Repository](https://github.com/Anandadevnath/Shirayuki-Scrapper-API)
535
+ - [Issues](https://github.com/Anandadevnath/Shirayuki-Scrapper-API/issues)
536
+
537
+ ---
538
+
539
+ Made with ❤️ by the Shirayuki team
@@ -0,0 +1,37 @@
1
+ import mongoose from 'mongoose';
2
+ import dotenv from 'dotenv';
3
+
4
+ dotenv.config();
5
+
6
+ let isConnected = false;
7
+
8
+ const connectDB = async () => {
9
+ if (isConnected) {
10
+ console.log('📄 Using existing MongoDB connection');
11
+ return;
12
+ }
13
+
14
+ try {
15
+ const mongoUri = process.env.MONGODB_URI;
16
+
17
+ if (!mongoUri) {
18
+ throw new Error('MONGODB_URI environment variable is not defined');
19
+ }
20
+
21
+ const connection = await mongoose.connect(mongoUri, {
22
+ useNewUrlParser: true,
23
+ useUnifiedTopology: true,
24
+ maxPoolSize: 10,
25
+ serverSelectionTimeoutMS: 5000,
26
+ socketTimeoutMS: 45000,
27
+ });
28
+
29
+ isConnected = true;
30
+ console.log(`🗄️ MongoDB connected: ${connection.connection.host}`);
31
+ } catch (error) {
32
+ console.error('❌ MongoDB connection error:', error);
33
+ process.exit(1);
34
+ }
35
+ };
36
+
37
+ export default connectDB;
package/index.js ADDED
@@ -0,0 +1,63 @@
1
+ import express from 'express';
2
+ import dotenv from 'dotenv';
3
+ import episodeRouter from './routes/episodeStream.js';
4
+ import homeRouter from './routes/home.js';
5
+ import top10Router from './routes/top10.js';
6
+ import monthlyRouter from './routes/monthly.js';
7
+ import weeklyRouter from './routes/weekly.js';
8
+ import animeListRouter from './routes/anime-list.js';
9
+ import animedetailsRouter from './scrapeanime/AnimeDetails/animedetails.js';
10
+ import scheduleRouter from './routes/schedule.js';
11
+
12
+ import genreRouter from './routes/genre.js';
13
+ import searchRouter from './routes/search.js';
14
+
15
+ dotenv.config();
16
+ const app = express();
17
+ app.use(express.json());
18
+
19
+ app.use((req, res, next) => {
20
+ res.header('Access-Control-Allow-Origin', '*');
21
+ res.header('Access-Control-Allow-Headers', 'Origin, X-Requested-With, Content-Type, Accept');
22
+ res.header('Access-Control-Allow-Methods', 'GET, POST, PUT, DELETE, OPTIONS');
23
+ next();
24
+ });
25
+
26
+
27
+ app.get('/', (req, res) => {
28
+ res.json({
29
+ message: " Welcome to Shirayuki Anime Scraper!",
30
+ version: "1.0.0",
31
+ endpoints: [
32
+ { name: "Homepage", path: "/home" },
33
+ { name: "Top 10 animes", path: "/top10" },
34
+ { name: "Monthly Top 10 animes", path: "/monthly10" },
35
+ { name: "Weekly Top 10 animes", path: "/weekly10" },
36
+ { name: "Anime Schedule", path: "/schedule" },
37
+ { name: "A-Z animes based on alphabets", path: "/az-all-anime/all/?page=1" },
38
+ { name: "Anime by Genre", path: "/genere/Action?page=2" },
39
+ { name: "Search Anime", path: "/search?keyword=one%20piece" },
40
+ { name: "Search Suggestions", path: "/search/suggestions?q=demon%20slayer" },
41
+ { name: "Streaming url", path: "/episode-stream?id=one-piece-dub&ep=1" },
42
+ { name: "AnimeDetails by title", path: "/anime/sozai-saishuka-no-isekai-ryokouki" },
43
+ ],
44
+ });
45
+ });
46
+
47
+ app.use('/', episodeRouter);
48
+ app.use('/home', homeRouter);
49
+ app.use('/top10', top10Router);
50
+ app.use('/monthly10', monthlyRouter);
51
+ app.use('/weekly10', weeklyRouter);
52
+ app.use('/schedule', scheduleRouter);
53
+ app.get('/anime/:slug', animedetailsRouter);
54
+ app.use('/genere', genreRouter);
55
+ app.use('/search', searchRouter);
56
+ app.use('/az-all-anime', animeListRouter);
57
+
58
+
59
+ const PORT = process.env.PORT || 5000;
60
+
61
+ app.listen(PORT, () => {
62
+ console.log(`🚀 Anime Scraper API v2.1 running at http://localhost:${PORT}`);
63
+ });