Skip to content

Commit

Permalink
Bumped mw package added new providers even though they're not returni…
Browse files Browse the repository at this point in the history
…ng streams
  • Loading branch information
BeamlakAschalew committed Apr 18, 2024
1 parent ea5db51 commit 1c79e64
Show file tree
Hide file tree
Showing 8 changed files with 399 additions and 11 deletions.
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"license": "ISC",
"dependencies": {
"@fastify/cors": "^8.4.1",
"@movie-web/providers": "^2.2.7",
"@movie-web/providers": "^2.3.0",
"@types/dotenv": "^8.2.0",
"axios": "^1.6.2",
"chalk": "4.1.2",
Expand Down
17 changes: 13 additions & 4 deletions src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,18 @@ import kissasian from "./routes/kissasian";
import goojara from "./routes/goojara";
import daddylive from "./routes/daddylive";
import nepu from "./routes/nepu";
import warezcdn from "./routes/warezcdn";
import primewire from "./routes/primewire";
import insertunit from "./routes/insertunit";
import chalk from "chalk";
import FastifyCors from "@fastify/cors";
import dotenv from "dotenv";
import Redis from "ioredis";
import {
buildProviders,
targets,
makeStandardFetcher,
} from "@movie-web/providers";
dotenv.config();

export const workers_url = process.env.WORKERS_URL && process.env.WORKERS_URL;
Expand All @@ -29,8 +37,6 @@ export const redis =
password: process.env.REDIS_PASSWORD,
});



async function startServer() {
const PORT = Number(process.env.PORT) || 3000;
console.log(chalk.green(`Starting server on port ${PORT}... 🚀`));
Expand Down Expand Up @@ -69,7 +75,10 @@ async function startServer() {
await fastify.register(kissasian, { prefix: "/kissasian" });
await fastify.register(goojara, { prefix: "/goojara" });
await fastify.register(nepu, { prefix: "/nepu" });
await fastify.register(daddylive, {prefix: "/daddylive"});
await fastify.register(daddylive, { prefix: "/daddylive" });
await fastify.register(warezcdn, { prefix: "/warez" });
await fastify.register(primewire, { prefix: "/primewire" });
await fastify.register(insertunit, { prefix: "/insertunit" });

try {
fastify.get("/", async (_, rp) => {
Expand All @@ -91,4 +100,4 @@ async function startServer() {
process.exit(1);
}
}
export default startServer;
export default startServer;
8 changes: 7 additions & 1 deletion src/routes/flixhq.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,13 @@ const routes = async (fastify: FastifyInstance) => {
tmdbId: tmdbId,
};

await fetchHlsLinks(proxied, reply, media, "flixhq", server);
await fetchHlsLinks(
proxied,
reply,
media,
"ridomovies",
server,
);
} catch (error) {
reply.status(500).send({
message: "Something went wrong. Please try again",
Expand Down
132 changes: 132 additions & 0 deletions src/routes/insertunit.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
import { MovieMedia, ShowMedia } from "@movie-web/providers";
import { FastifyRequest, FastifyReply, FastifyInstance } from "fastify";
import { fetchHlsLinks, fetchMovieData, fetchTVData } from "../utils/functions";

const routes = async (fastify: FastifyInstance) => {
fastify.get("/", (_, rp) => {
rp.status(200).send({
intro: "Welcome to the insertunit provider",
routes: "/watch-movie " + "/watch-tv",
});
});

// media from TMDB

fastify.get(
"/watch-movie",
async (request: FastifyRequest, reply: FastifyReply) => {
const tmdbId = (request.query as { tmdbId: string }).tmdbId;
const proxied = (request.query as { proxied: string }).proxied;
const server = (request.query as { server: string }).server;

let releaseYear: string = "";
let title: string = "";

if (typeof tmdbId === "undefined")
return reply
.status(400)
.send({ message: "tmdb id is required" });

try {
await fetchMovieData(tmdbId).then((data) => {
if (data) {
releaseYear = data?.year.toString();
title = data?.title;
}
});

const media: MovieMedia = {
type: "movie",
title: title,
releaseYear: parseInt(releaseYear),
tmdbId: tmdbId,
};

await fetchHlsLinks(
proxied,
reply,
media,
"insertunit",
server,
);
} catch (error) {
reply.status(500).send({
message: "Something went wrong. Please try again",
error: error,
});
}
},
);

fastify.get(
"/watch-tv",
async (request: FastifyRequest, reply: FastifyReply) => {
const tmdbId = (request.query as { tmdbId: string }).tmdbId;
const episode = (request.query as { episode: string }).episode;
const season = (request.query as { season: string }).season;
const proxied = (request.query as { proxied: string }).proxied;
const server = (request.query as { server: string }).server;

let title: string = "";
let episodeId: string = "";
let seasonId: string = "";
let releaseYear: string = "";
let numberOfSeasons: string = "";

if (typeof tmdbId === "undefined")
return reply
.status(400)
.send({ message: "tmdb id is required" });
if (typeof episode === "undefined")
return reply
.status(400)
.send({ message: "episode is required" });
if (typeof season === "undefined")
return reply.status(400).send({
message: "season is required",
});

try {
await fetchTVData(tmdbId, season, episode).then((data) => {
if (data) {
title = data?.title;
episodeId = data?.episodeId.toString();
seasonId = data?.seasonId.toString();
releaseYear = data?.year.toString();
numberOfSeasons = data?.numberOfSeasons.toString();
}
});

const media: ShowMedia = {
type: "show",
title: title,
episode: {
number: parseInt(episode),
tmdbId: episodeId,
},
season: {
number: parseInt(season),
tmdbId: seasonId,
},
releaseYear: parseInt(releaseYear),
tmdbId: tmdbId,
};

await fetchHlsLinks(
proxied,
reply,
media,
"insertunit",
server,
);
} catch (error) {
reply.status(500).send({
message: "Something went wrong. Please try again",
error: error,
});
}
},
);
};

export default routes;
120 changes: 120 additions & 0 deletions src/routes/primewire.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
import { MovieMedia, ShowMedia } from "@movie-web/providers";
import { FastifyRequest, FastifyReply, FastifyInstance } from "fastify";
import { fetchHlsLinks, fetchMovieData, fetchTVData } from "../utils/functions";

const routes = async (fastify: FastifyInstance) => {
fastify.get("/", (_, rp) => {
rp.status(200).send({
intro: "Welcome to the primewire provider",
routes: "/watch-movie " + "/watch-tv",
});
});

// media from TMDB

fastify.get(
"/watch-movie",
async (request: FastifyRequest, reply: FastifyReply) => {
const tmdbId = (request.query as { tmdbId: string }).tmdbId;
const proxied = (request.query as { proxied: string }).proxied;
const server = (request.query as { server: string }).server;

let releaseYear: string = "";
let title: string = "";

if (typeof tmdbId === "undefined")
return reply
.status(400)
.send({ message: "tmdb id is required" });

try {
await fetchMovieData(tmdbId).then((data) => {
if (data) {
releaseYear = data?.year.toString();
title = data?.title;
}
});

const media: MovieMedia = {
type: "movie",
title: title,
releaseYear: parseInt(releaseYear),
tmdbId: tmdbId,
};

await fetchHlsLinks(proxied, reply, media, "primewire", server);
} catch (error) {
reply.status(500).send({
message: "Something went wrong. Please try again",
error: error,
});
}
},
);

fastify.get(
"/watch-tv",
async (request: FastifyRequest, reply: FastifyReply) => {
const tmdbId = (request.query as { tmdbId: string }).tmdbId;
const episode = (request.query as { episode: string }).episode;
const season = (request.query as { season: string }).season;
const proxied = (request.query as { proxied: string }).proxied;
const server = (request.query as { server: string }).server;

let title: string = "";
let episodeId: string = "";
let seasonId: string = "";
let releaseYear: string = "";
let numberOfSeasons: string = "";

if (typeof tmdbId === "undefined")
return reply
.status(400)
.send({ message: "tmdb id is required" });
if (typeof episode === "undefined")
return reply
.status(400)
.send({ message: "episode is required" });
if (typeof season === "undefined")
return reply.status(400).send({
message: "season is required",
});

try {
await fetchTVData(tmdbId, season, episode).then((data) => {
if (data) {
title = data?.title;
episodeId = data?.episodeId.toString();
seasonId = data?.seasonId.toString();
releaseYear = data?.year.toString();
numberOfSeasons = data?.numberOfSeasons.toString();
}
});

const media: ShowMedia = {
type: "show",
title: title,
episode: {
number: parseInt(episode),
tmdbId: episodeId,
},
season: {
number: parseInt(season),
tmdbId: seasonId,
},
releaseYear: parseInt(releaseYear),
tmdbId: tmdbId,
};

await fetchHlsLinks(proxied, reply, media, "primewire", server);
} catch (error) {
reply.status(500).send({
message: "Something went wrong. Please try again",
error: error,
});
}
},
);
};

export default routes;
Loading

0 comments on commit 1c79e64

Please sign in to comment.