From 53b05bce3aacfe001925108057850e8a681161b0 Mon Sep 17 00:00:00 2001 From: Inside4ndroid Date: Mon, 4 Nov 2024 16:46:12 +0000 Subject: [PATCH] added new provider route and updated readme --- README.md | 75 +++++++++++++++++++++++++------ index.js | 26 +++++++++-- src/asiaheroku.js | 44 ++++++++++++++++++ src/vidsrcpro.js | 112 +++++----------------------------------------- 4 files changed, 138 insertions(+), 119 deletions(-) create mode 100644 src/asiaheroku.js diff --git a/README.md b/README.md index 47f4af5..ac3876e 100644 --- a/README.md +++ b/README.md @@ -1,25 +1,72 @@ -### USAGE -- base url: - https://your-vercel-domain +# Unoffical Vidsrc API! 👋 +## Sponsorship / Donations -- endpoint: - - `/vidsrc/{tmdb_id}` +Your sponsorship is vital in helping me achieve this mission. With your support, I can: -- parameters: - - `s` - season (series only) - - `e` - episodes (series only) +Dedicate more time to developing and improving my projects +Cover costs for essential tools, services and premium hosting to run public projects +Provide detailed documentation and support for users +Every contribution, no matter the size, makes a significant impact. -### EXAMPLE MOVIE +[Sponsor Me!](https://github.com/sponsors/Inside4ndroid) + +Thank you for considering supporting my work! + +### NOTE: + +This is an api for id's provided at [TMDB](https://www.themoviedb.org/) + +you must use the ID from the tmdb url like this : + +so ``` -https://your-vercel-domain/vidsrc/916224 +MOVIES: + +https://www.themoviedb.org/movie/1034541-terrifier-3?language=en-GB + +TV SHOWS: + +https://www.themoviedb.org/tv/124364-from?language=en-GB +``` +would be +``` +MOVIES: + +`/{provider}/1034541` + +TVSHOWS : + +`/{provider}/124364?s=1&e=1` (s - Season / e - Episode) ``` -### EXAMPLE SHOW +## Providers + +The providers are currently : + ``` -https://your-vercel-domain/vidsrc/1429?s=1&e=1 +vidsrc +asiaheroku ``` -### Vercel -Host your own instance of vidsrc-api on Vercel using the button below. +## Example Movie +``` +https://your-domain/vidsrc/916224 +``` + +## Example Show +``` +https://your-domain/asiaheroku/1429?s=1&e=1 +``` + +## Deployment + +You can self host by doing the following : + +1. `git clone https://github.com/Inside4ndroid/vidsrc-api-js.git` +2. `cd vidsrc-api-js` +3. `npm install` +4. `npm run main` + +or you can deploy to vercel using the button below: [![Deploy with Vercel](https://vercel.com/button)](https://vercel.com/new/clone?repository-url=https%3A%2F%2Fgithub.com%2FInside4ndroid%2Fvidsrc-api-js) diff --git a/index.js b/index.js index 11e22a4..65cb1c8 100644 --- a/index.js +++ b/index.js @@ -1,5 +1,6 @@ import express from "express"; -import { getvmovie } from "./src/vidsrcpro.js"; +import { getvidsrc } from "./src/vidsrcpro.js"; +import { getasiaheroku } from "./src/asiaheroku.js"; const port = 3000; @@ -23,10 +24,29 @@ app.get('/vidsrc/:tmdbId', async (req, res) => { try { if (season && episode) { - const vidsrcresponse = await getvmovie(id, season, episode); + const vidsrcresponse = await getvidsrc(id, season, episode); res.status(200).json(vidsrcresponse); } else { - const vidsrcresponse = await getvmovie(id); + const vidsrcresponse = await getvidsrc(id); + res.status(200).json(vidsrcresponse); + } + } catch (error) { + console.error('Error fetching data:', error); + res.status(500).json({ error: 'Failed to fetch data' }); + } +}); + +app.get('/asiaheroku/:tmdbId', async (req, res) => { + const id = req.params.tmdbId; + const season = req.query.s; + const episode = req.query.e; + + try { + if (season && episode) { + const srcresponse = await getasiaheroku(id, season, episode); + res.status(200).json(srcresponse); + } else { + const vidsrcresponse = await getasiaheroku(id); res.status(200).json(vidsrcresponse); } } catch (error) { diff --git a/src/asiaheroku.js b/src/asiaheroku.js new file mode 100644 index 0000000..e1c4e52 --- /dev/null +++ b/src/asiaheroku.js @@ -0,0 +1,44 @@ +export async function getasiaheroku(tmdb_id, s, e) { + const DOMAIN = "https://asia.heroku.uk/"; + const headers = { + 'user-agent': "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36", + 'Referer': `${DOMAIN}`, + 'Origin': `${DOMAIN}`, + }; + + try { + let urlSearch = ''; + + if(s && e){ + urlSearch = `${DOMAIN}/embed/tv/${tmdb_id}/${s}/${e}`; + } else { + urlSearch = `${DOMAIN}/embed/movie/${tmdb_id}`; + } + + const htmlSearch = await fetch(urlSearch, { + method: 'GET', + headers: headers, + }); + const textSearch = await htmlSearch.text(); + const sourceMatch = textSearch.match(/