Skip to content

Commit

Permalink
Merge pull request #97 from himanshu8443/feature
Browse files Browse the repository at this point in the history
new provider and fix
  • Loading branch information
Zenda-Cross authored Aug 29, 2024
2 parents e0e83d7 + 6441304 commit 784f716
Show file tree
Hide file tree
Showing 10 changed files with 242 additions and 99 deletions.
14 changes: 9 additions & 5 deletions src/components/SeasonList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,12 @@ const SeasonList = ({
// handle external player playback
const handleExternalPlayer = async (link: string, type: string) => {
setVlcLoading(true);
const stream = await manifest[providerValue].getStream(link, type);
const controller = new AbortController();
const stream = await manifest[providerValue].getStream(
link,
type,
controller.signal,
);
const availableStream = stream.filter(
e => !manifest[providerValue].nonStreamableServer?.includes(e.server),
);
Expand Down Expand Up @@ -260,9 +265,8 @@ const SeasonList = ({
`}>
<View className="flex-row w-full justify-between gap-2 items-center">
<TouchableOpacity
className={
'rounded-md bg-white/30 w-[80%] h-12 justify-center items-center p-2 flex-row gap-x-2 relative '
}
className={`rounded-md bg-white/30 w-[80%] h-12 items-center p-1 flex-row gap-x-2 relative
${item.title.length < 20 ? 'justify-center' : ''}`}
onPress={() =>
playHandler({
link: item.link,
Expand All @@ -278,7 +282,7 @@ const SeasonList = ({
onLongPress={() =>
onLongPressHandler(true, item.link, 'series')
}>
<Ionicons name="play-circle" size={28} color={primary} />
<Ionicons name="play-circle" size={32} color={primary} />
<Text className="text-white">
{item.title.length > 30
? item.title.slice(0, 30) + '...'
Expand Down
5 changes: 4 additions & 1 deletion src/lib/Manifest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ import {katMoviesHd} from './providers/katmovies';
import {primewire} from './providers/primewire';
import {autoEmbed} from './providers/autoEmbed';
import {HiAnime} from './providers/hiAnime';
import {vadapavProvider} from './providers/vadapav';
import {netflixMirror} from './providers/netflixMirror';

export interface ProviderType {
searchFilter?: string;
Expand Down Expand Up @@ -64,11 +66,12 @@ export const manifest: Manifest = {
hdhub4u: hdhub4uProvider,
katmovies: katMoviesHd,
primewire: primewire,
netflixMirror: multiMovies,
netflixMirror: netflixMirror,
autoEmbed: autoEmbed,
multiStream: autoEmbed,
dooflix: dooflixProvider,
AEDrama: autoEmbedDrama,
AEAnime: AEAnime,
hiAnime: HiAnime,
vadapav: vadapavProvider,
};
6 changes: 6 additions & 0 deletions src/lib/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,12 @@ export const providersList: ProvidersList[] = [
type: 'global',
flag: '🌏',
},
{
name: 'VadaPav',
value: 'vadapav',
type: 'global',
flag: '🌏',
},
{
name: 'FlixHQ',
value: 'flixhq',
Expand Down
16 changes: 16 additions & 0 deletions src/lib/providers/vadapav/VagapavCatalog.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
export const vadapavCatalogList = [
{
title: 'Movies',
filter: '/608c853f-704e-48f0-b785-4ae1f48ea70d',
},
{
title: 'Tv Shows',
filter: '/72983eef-a12f-4be4-99a7-e8f6afa568c1',
},
{
title: 'Anime',
filter: '/36abf81c-1032-4fbf-9a55-347a05ce2ca3',
},
];

export const vadapavGenresList = [];
15 changes: 15 additions & 0 deletions src/lib/providers/vadapav/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import {vadapavGetPosts} from './vadapavGetPosts';
import {vadapavCatalogList, vadapavGenresList} from './VagapavCatalog';
import {ProviderType} from '../../Manifest';
import {vadapavGetInfo} from './vadapavGetInfo';
import {vadapavGetStream} from './vadapavGetStream';
import {vadapavGetEpisodeLinks} from './vadapavGetEpisodes';

export const vadapavProvider: ProviderType = {
catalog: vadapavCatalogList,
genres: vadapavGenresList,
getPosts: vadapavGetPosts,
getEpisodeLinks: vadapavGetEpisodeLinks,
getInfo: vadapavGetInfo,
getStream: vadapavGetStream,
};
37 changes: 37 additions & 0 deletions src/lib/providers/vadapav/vadapavGetEpisodes.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import axios from 'axios';
import * as cheerio from 'cheerio';
import {EpisodeLink} from '../types';

export const vadapavGetEpisodeLinks = async function (
url: string,
): Promise<EpisodeLink[]> {
try {
const baseUrl = url?.split('/').slice(0, 3).join('/');
const res = await axios.get(url);
const html = res.data;
let $ = cheerio.load(html);
const episodeLinks: EpisodeLink[] = [];

$('.file-entry:not(:contains("Parent Directory"))').map((i, element) => {
const link = $(element).attr('href');
if (
link &&
($(element).text()?.includes('.mp4') ||
$(element).text()?.includes('.mkv'))
) {
episodeLinks.push({
title:
$(element).text()?.match(/E\d+/)?.[0]?.replace('E', 'Episode ') ||
i + 1 + '. ' + $(element).text(),
link: baseUrl + link,
});
}
});

// console.log(episodeLinks);
return episodeLinks;
} catch (err) {
console.error(err);
return [];
}
};
80 changes: 80 additions & 0 deletions src/lib/providers/vadapav/vadapavGetInfo.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
import axios from 'axios';
import * as cheerio from 'cheerio';
import {EpisodeLink, Info, Link} from '../types';

export const vadapavGetInfo = async function (link: string): Promise<Info> {
try {
const baseUrl = link?.split('/').slice(0, 3).join('/');
const url = link;
const res = await axios.get(url);
const data = res.data;
const $ = cheerio.load(data);
const title = $('.directory')
.children()
.first()
.text()
.trim()
?.split('/')
.pop()
?.trim();
console.log('title', title);
const links: Link[] = [];

$('.directory-entry:not(:contains("Parent Directory"))').map(
(i, element) => {
const link = $(element).attr('href');
if (link) {
links.push({
episodesLink: baseUrl + link,
title: $(element).text(),
movieLinks: '',
quality: '',
});
}
},
);
const directLinks: EpisodeLink[] = [];
$('.file-entry:not(:contains("Parent Directory"))').map((i, element) => {
const link = $(element).attr('href');
if (
link &&
($(element).text()?.includes('.mp4') ||
$(element).text()?.includes('.mkv'))
) {
directLinks.push({
title: i + 1 + '. ' + $(element).text(),
link: baseUrl + link,
});
}
});

if (directLinks.length > 0) {
links.push({
episodesLink: '',
title: title + ' DL',
movieLinks: '',
quality: '',
directLinks: directLinks,
});
}

return {
title: title,
synopsis: '',
image: '',
imdbId: '',
type: '',
linkList: links,
};
} catch (err) {
console.error(err);
return {
title: '',
synopsis: '',
image: '',
imdbId: '',
type: '',
linkList: [],
};
}
};
53 changes: 53 additions & 0 deletions src/lib/providers/vadapav/vadapavGetPosts.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import axios from 'axios';
import * as cheerio from 'cheerio';
import {Post} from '../types';
import {getBaseUrl} from '../getBaseUrl';

export const vadapavGetPosts = async function (
filter: string,
page: number,
providerValue: string,
signal: AbortSignal,
): Promise<Post[]> {
try {
const baseUrl = 'https://vadapav.mov';
if (page > 1) {
return [];
}
const url = filter.includes('searchQuery=')
? `${baseUrl}/s/${filter.replace('searchQuery=', '')}`
: `${baseUrl + filter}`;
console.log('vadapavGetPosts', url);
const res = await axios.get(url, {signal});
const data = res.data;
const $ = cheerio.load(data);
const catalog: Post[] = [];
$('.directory-entry:not(:contains("Parent Directory"))').map(
(i, element) => {
const title = $(element).text();
const link = $(element).attr('href');
const imageTitle =
title?.length > 30
? title?.slice(0, 30)?.replaceAll('.', ' ')
: title?.replaceAll('.', ' ');

const image = `https://placehold.jp/23/000000/ffffff/200x400.png?text=${encodeURIComponent(
imageTitle,
)}&css=%7B%22background%22%3A%22%20-webkit-gradient(linear%2C%20left%20bottom%2C%20left%20top%2C%20from(%233f3b3b)%2C%20to(%23000000))%22%2C%22text-transform%22%3A%22%20capitalize%22%7D`;
// console.log('title', image);
if (title && link) {
catalog.push({
title: title,
link: baseUrl + link,
image: image,
});
}
},
);
// console.log(catalog);
return catalog;
} catch (err) {
console.error('vadapav error ', err);
return [];
}
};
21 changes: 21 additions & 0 deletions src/lib/providers/vadapav/vadapavGetStream.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import {Stream} from '../types';

export const vadapavGetStream = async (
url: string,
type: string,
): Promise<Stream[]> => {
try {
const stream: Stream[] = [];
console.log('vadapavGetStream', type, url);
stream.push({
server: 'vadapav',
link: url,
type: url?.split('.').pop() || 'mkv',
});

return stream;
} catch (err) {
console.log('getStream error', err);
return [];
}
};
Loading

0 comments on commit 784f716

Please sign in to comment.