Skip to content

Commit

Permalink
refactor: Update dcGetPosts and modGetStream functions
Browse files Browse the repository at this point in the history
  • Loading branch information
himanshu8443 committed Aug 2, 2024
1 parent 1ceb81c commit 5051ef0
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 38 deletions.
7 changes: 4 additions & 3 deletions src/lib/providers/dramacool/dcGetPosts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,11 @@ export const dcGetPosts = async function (
): Promise<Post[]> {
try {
const urlRes = await axios.get(
'https://consumet8.vercel.app/movies/dramacool/info?id=drama-detail/shogun',
'https://himanshu8443.github.io/providers/modflix.json',
);
const resData = urlRes.data.episodes[0].url;
const baseUrl = resData.split('/').slice(0, 3).join('/');
const dataRes = urlRes.data;
// console.log(dataRes.hdhub.url);
const baseUrl = dataRes?.dc?.url;
console.log('dcBaseUrl', baseUrl);
const url = filter.includes('query')
? `${baseUrl}/search?type=movies&keyword=${filter.replace(
Expand Down
74 changes: 39 additions & 35 deletions src/lib/providers/mod/modGetStream.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,42 +74,46 @@ export const modGetStream = async (
const driveRes = await axios.get(driveLink, {headers});
const driveHtml = driveRes.data;
const $drive = cheerio.load(driveHtml);
const resumeBot = $drive('.btn.btn-light').attr('href') || '';
const resumeBotRes = await axios.get(resumeBot, {headers});
const resumeBotToken = resumeBotRes.data.match(
/formData\.append\('token', '([a-f0-9]+)'\)/,
)[1];
const resumeBotBody = new FormData();
resumeBotBody.append('token', resumeBotToken);
const resumeBotPath = resumeBotRes.data.match(
/fetch\('\/download\?id=([a-zA-Z0-9\/+]+)'/,
)[1];
const resumeBotBaseUrl = resumeBot.split('/download')[0];
// console.log(
// 'resumeBotPath',
// resumeBotBaseUrl + '/download?id=' + resumeBotPath,
// );
// console.log('resumeBotBody', resumeBotToken);

const resumeBotDownload = await fetch(
resumeBotBaseUrl + '/download?id=' + resumeBotPath,
{
method: 'POST',
body: resumeBotBody,
headers: {
Referer: resumeBot,
Cookie: 'PHPSESSID=7e9658ce7c805dab5bbcea9046f7f308',
},
},
);
const resumeBotDownloadData = await resumeBotDownload.json();
console.log('resumeBotDownloadData', resumeBotDownloadData.url);
servers.push({
server: 'ResumeBot',
link: resumeBotDownloadData.url,
type: 'mkv',
});
try {
const resumeBot = $drive('.btn.btn-light').attr('href') || '';
const resumeBotRes = await axios.get(resumeBot, {headers});
const resumeBotToken = resumeBotRes.data.match(
/formData\.append\('token', '([a-f0-9]+)'\)/,
)[1];
const resumeBotBody = new FormData();
resumeBotBody.append('token', resumeBotToken);
const resumeBotPath = resumeBotRes.data.match(
/fetch\('\/download\?id=([a-zA-Z0-9\/+]+)'/,
)[1];
const resumeBotBaseUrl = resumeBot.split('/download')[0];
// console.log(
// 'resumeBotPath',
// resumeBotBaseUrl + '/download?id=' + resumeBotPath,
// );
// console.log('resumeBotBody', resumeBotToken);

const resumeBotDownload = await fetch(
resumeBotBaseUrl + '/download?id=' + resumeBotPath,
{
method: 'POST',
body: resumeBotBody,
headers: {
Referer: resumeBot,
Cookie: 'PHPSESSID=7e9658ce7c805dab5bbcea9046f7f308',
},
},
);
const resumeBotDownloadData = await resumeBotDownload.json();
console.log('resumeBotDownloadData', resumeBotDownloadData.url);
servers.push({
server: 'ResumeBot',
link: resumeBotDownloadData.url,
type: 'mkv',
});
} catch (err) {
console.log('ResumeBot link not found', err);
}
// CF workers type 1
try {
const cfWorkersLink = driveLink.replace('/file', '/wfile') + '?type=1';
Expand Down Expand Up @@ -199,7 +203,7 @@ const isDriveLink = async (ddl: string) => {
/window\.location\.replace\("([^"]+)"\)/,
)[1];
const mainUrl = ddl.split('/')[2];
console.log(`https://${mainUrl}${path}`);
console.log(`driveUrl = https://${mainUrl}${path}`);
return `https://${mainUrl}${path}`;
} else {
return ddl;
Expand Down

0 comments on commit 5051ef0

Please sign in to comment.