Skip to content

Commit

Permalink
Merge pull request #15 from BeamlakAschalew/dev
Browse files Browse the repository at this point in the history
added daddylive back
  • Loading branch information
BeamlakAschalew authored Feb 21, 2024
2 parents 53b72ed + 990954f commit 9e96934
Show file tree
Hide file tree
Showing 18 changed files with 83 additions and 26 deletions.
5 changes: 5 additions & 0 deletions src/constants/api_constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,8 @@ dotenv.config();

export const tmdbBaseUrl = "https://api.themoviedb.org";
export const tmdbKey = process.env.TMDB_KEY;
export const daddyliveReferrer = "https://olalivehdplay.ru/z.m3u8";
export const daddyliveUserAgent = "MXPlayer/1.50.1 (Linux; Android 13; en-GB; SM-M127G Build/TP1A.220624.014.M127GXXU6DWJ1)";
export const daddyliveStreamBaseUrl = "https://webudit.webhd.ru/lb/premium"
export const daddyliveTrailingUrl = `/index.m3u8?|referer=${daddyliveReferrer}`;
export const daddylive247Url = "https://dlhd.sx/24-7-channels.php";
16 changes: 3 additions & 13 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,12 @@ import vidsrc from "./routes/vidsrc";
import vidsrcto from "./routes/vidsrcto";
import kissasian from "./routes/kissasian";
import goojara from "./routes/goojara";
import daddylive from "./routes/daddylive";
import nepu from "./routes/nepu";
import chalk from "chalk";
import FastifyCors from "@fastify/cors";
import dotenv from "dotenv";
import Redis from "ioredis";
import {
buildProviders,
makeProviders,
makeStandardFetcher,
} from "@movie-web/providers";
dotenv.config();

export const workers_url = process.env.WORKERS_URL && process.env.WORKERS_URL;
Expand Down Expand Up @@ -73,17 +69,11 @@ 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"});

try {
fastify.get("/", async (_, rp) => {
let p = buildProviders()
.setTarget('any')
.setFetcher(makeStandardFetcher(fetch))
.addBuiltinProviders()
.build();
console.log(p.listSources());

let prov = rp.status(200).send("Welcome to FlixQuest API! 🎉");
rp.status(200).send("Welcome to FlixQuest API! 🎉");
});
fastify.get("*", (request, reply) => {
reply.status(404).send({
Expand Down
33 changes: 33 additions & 0 deletions src/providers/daddylive.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import axios from "axios";
import { load } from "cheerio";
import { ChannelEntry } from "../utils/types";
import { daddylive247Url } from "../constants/api_constants";

export async function get247() : Promise<ChannelEntry[] | null> {
const channels = await axios.get(daddylive247Url);
const $ = load(channels.data);
const firstGridContainer = $('.grid-container').first();
const gridItems = firstGridContainer.find('.grid-item').toArray();

const parsedChannels: ChannelEntry[] = [];
gridItems.forEach((element) => {
const isChannelIdValid = extractChannelId($(element).find('a').attr('href')!);
if (typeof isChannelIdValid !== "boolean" && !$(element).find('strong').text().startsWith("18+")) {
parsedChannels.push({id: isChannelIdValid, channel_name: $(element).find('strong').text()});
}
});


return parsedChannels;
}

function extractChannelId(text: string) : number | boolean {
const regex = /(\d+)/;
const match = text.match(regex);

if (match) {
return Number.parseInt(match[0]);
} else {
return false;
}
}
24 changes: 24 additions & 0 deletions src/routes/daddylive.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { FastifyInstance } from "fastify";
import { get247 } from "../providers/daddylive";
import { daddyliveReferrer, daddyliveStreamBaseUrl, daddyliveTrailingUrl, daddyliveUserAgent } from "../constants/api_constants";

const routes = async (fastify: FastifyInstance) => {
fastify.get("/", async (_, rp) => {

rp.status(200).send({
intro: "Welcome to the daddylive provider",
routes: "/live",
});
});

fastify.get("/live", async (_, rp) => {
const channels = await get247();
if (channels) {
rp.status(200).send({base_url: daddyliveStreamBaseUrl, trailing_url: daddyliveTrailingUrl, referrer: daddyliveReferrer, user_agent: daddyliveUserAgent, channels: channels});
} else {
rp.status(500).send({message: "Unknown error occured. Could not fetch channels"});
}
});
};

export default routes;
2 changes: 1 addition & 1 deletion src/routes/flixhq.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
fetchHlsLinks,
fetchMovieData,
fetchTVData,
} from "../models/functions";
} from "../utils/functions";

const routes = async (fastify: FastifyInstance) => {
fastify.get("/", (_, rp) => {
Expand Down
2 changes: 1 addition & 1 deletion src/routes/gomovies.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
fetchHlsLinks,
fetchMovieData,
fetchTVData,
} from "../models/functions";
} from "../utils/functions";

const routes = async (fastify: FastifyInstance) => {
fastify.get("/", (_, rp) => {
Expand Down
2 changes: 1 addition & 1 deletion src/routes/goojara.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
fetchHlsLinks,
fetchMovieData,
fetchTVData,
} from "../models/functions";
} from "../utils/functions";

const routes = async (fastify: FastifyInstance) => {
fastify.get("/", (_, rp) => {
Expand Down
2 changes: 1 addition & 1 deletion src/routes/kissasian.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
fetchHlsLinks,
fetchMovieData,
fetchTVData,
} from "../models/functions";
} from "../utils/functions";

const routes = async (fastify: FastifyInstance) => {
fastify.get("/", (_, rp) => {
Expand Down
2 changes: 1 addition & 1 deletion src/routes/nepu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
fetchHlsLinks,
fetchMovieData,
fetchTVData,
} from "../models/functions";
} from "../utils/functions";

const routes = async (fastify: FastifyInstance) => {
fastify.get("/", (_, rp) => {
Expand Down
2 changes: 1 addition & 1 deletion src/routes/remotestream.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
fetchHlsLinks,
fetchMovieData,
fetchTVData,
} from "../models/functions";
} from "../utils/functions";

const routes = async (fastify: FastifyInstance) => {
fastify.get("/", (_, rp) => {
Expand Down
2 changes: 1 addition & 1 deletion src/routes/ridomovies.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
fetchHlsLinks,
fetchMovieData,
fetchTVData,
} from "../models/functions";
} from "../utils/functions";

const routes = async (fastify: FastifyInstance) => {
fastify.get("/", (_, rp) => {
Expand Down
2 changes: 1 addition & 1 deletion src/routes/showbox.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { MovieMedia, ShowMedia } from "@movie-web/providers";
import { FastifyRequest, FastifyReply, FastifyInstance } from "fastify";
import { fetchDash, fetchMovieData, fetchTVData } from "../models/functions";
import { fetchDash, fetchMovieData, fetchTVData } from "../utils/functions";

const routes = async (fastify: FastifyInstance) => {
fastify.get("/", (_, rp) => {
Expand Down
2 changes: 1 addition & 1 deletion src/routes/smashystream.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
fetchHlsLinks,
fetchMovieData,
fetchTVData,
} from "../models/functions";
} from "../utils/functions";

const routes = async (fastify: FastifyInstance) => {
fastify.get("/", (_, rp) => {
Expand Down
2 changes: 1 addition & 1 deletion src/routes/vidsrc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
fetchHlsLinks,
fetchMovieData,
fetchTVData,
} from "../models/functions";
} from "../utils/functions";

const routes = async (fastify: FastifyInstance) => {
fastify.get("/", (_, rp) => {
Expand Down
2 changes: 1 addition & 1 deletion src/routes/vidsrcto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
fetchHlsLinks,
fetchMovieData,
fetchTVData,
} from "../models/functions";
} from "../utils/functions";

const routes = async (fastify: FastifyInstance) => {
fastify.get("/", (_, rp) => {
Expand Down
2 changes: 1 addition & 1 deletion src/routes/zoe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
fetchHlsLinks,
fetchMovieData,
fetchTVData,
} from "../models/functions";
} from "../utils/functions";

const routes = async (fastify: FastifyInstance) => {
fastify.get("/", (_, rp) => {
Expand Down
2 changes: 1 addition & 1 deletion src/models/functions.ts → src/utils/functions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { tmdbBaseUrl, tmdbKey } from "../constants/api_constants";
import { ResolutionStream, SubData, supportedLanguages } from "./types";
import { FastifyReply } from "fastify";
import { redis } from "../index";
import cache from "../utils/cache";
import cache from "./cache";
dotenv.config();
const proxyUrl = process.env.WORKERS_URL;

Expand Down
5 changes: 5 additions & 0 deletions src/models/types.ts → src/utils/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ export type SubFormat = {
longName: string;
};

export type ChannelEntry = {
channel_name: string;
id: number;
}

export const supportedLanguages: SubFormat[] = [
{ shortCode: "ar", longName: "Arabic" },
{ shortCode: "bg", longName: "Bulgarian" },
Expand Down

0 comments on commit 9e96934

Please sign in to comment.