-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #15 from BeamlakAschalew/dev
added daddylive back
- Loading branch information
Showing
18 changed files
with
83 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters