mirror of
https://github.com/movie-web/providers.git
synced 2025-09-13 17:03:26 +00:00
fix: seperate function
This commit is contained in:
@@ -5,11 +5,43 @@ import { flixHqBase } from '@/providers/sources/flixhq/common';
|
|||||||
import { ScrapeContext } from '@/utils/context';
|
import { ScrapeContext } from '@/utils/context';
|
||||||
import { NotFoundError } from '@/utils/errors';
|
import { NotFoundError } from '@/utils/errors';
|
||||||
|
|
||||||
export async function getFlixhqSources(ctx: ScrapeContext, media: MovieMedia | ShowMedia, id: string) {
|
export async function getFlixhqMovieSources(ctx: ScrapeContext, media: MovieMedia, id: string) {
|
||||||
|
const episodeParts = id.split('-');
|
||||||
|
const episodeId = episodeParts[episodeParts.length - 1];
|
||||||
|
|
||||||
|
const data = await ctx.proxiedFetcher<string>(`/ajax/movie/episodes/${episodeId}`, {
|
||||||
|
baseUrl: flixHqBase,
|
||||||
|
});
|
||||||
|
|
||||||
|
const doc = load(data);
|
||||||
|
const sourceLinks = doc('.nav-item > a')
|
||||||
|
.toArray()
|
||||||
|
.map((el) => {
|
||||||
|
const query = doc(el);
|
||||||
|
const embedTitle = query.attr('title');
|
||||||
|
const linkId = query.attr('data-linkid');
|
||||||
|
if (!embedTitle || !linkId) throw new Error('invalid sources');
|
||||||
|
return {
|
||||||
|
embed: embedTitle,
|
||||||
|
episodeId: linkId,
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
return sourceLinks;
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function getFlixhqSourceDetails(ctx: ScrapeContext, sourceId: string): Promise<string> {
|
||||||
|
const jsonData = await ctx.proxiedFetcher<Record<string, any>>(`/ajax/sources/${sourceId}`, {
|
||||||
|
baseUrl: flixHqBase,
|
||||||
|
});
|
||||||
|
|
||||||
|
return jsonData.link;
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function getFlixhqShowSources(ctx: ScrapeContext, media: ShowMedia, id: string) {
|
||||||
const episodeParts = id.split('-');
|
const episodeParts = id.split('-');
|
||||||
const episodeId = episodeParts[episodeParts.length - 1];
|
const episodeId = episodeParts[episodeParts.length - 1];
|
||||||
|
|
||||||
if (media.type === 'show') {
|
|
||||||
const seasonsListData = await ctx.proxiedFetcher<string>(`/ajax/season/list/${episodeId}`, {
|
const seasonsListData = await ctx.proxiedFetcher<string>(`/ajax/season/list/${episodeId}`, {
|
||||||
baseUrl: flixHqBase,
|
baseUrl: flixHqBase,
|
||||||
});
|
});
|
||||||
@@ -58,32 +90,3 @@ export async function getFlixhqSources(ctx: ScrapeContext, media: MovieMedia | S
|
|||||||
|
|
||||||
return sourceLinks;
|
return sourceLinks;
|
||||||
}
|
}
|
||||||
|
|
||||||
const data = await ctx.proxiedFetcher<string>(`/ajax/movie/episodes/${episodeId}`, {
|
|
||||||
baseUrl: flixHqBase,
|
|
||||||
});
|
|
||||||
|
|
||||||
const doc = load(data);
|
|
||||||
const sourceLinks = doc('.nav-item > a')
|
|
||||||
.toArray()
|
|
||||||
.map((el) => {
|
|
||||||
const query = doc(el);
|
|
||||||
const embedTitle = query.attr('title');
|
|
||||||
const linkId = query.attr('data-linkid');
|
|
||||||
if (!embedTitle || !linkId) throw new Error('invalid sources');
|
|
||||||
return {
|
|
||||||
embed: embedTitle,
|
|
||||||
episodeId: linkId,
|
|
||||||
};
|
|
||||||
});
|
|
||||||
|
|
||||||
return sourceLinks;
|
|
||||||
}
|
|
||||||
|
|
||||||
export async function getFlixhqSourceDetails(ctx: ScrapeContext, sourceId: string): Promise<string> {
|
|
||||||
const jsonData = await ctx.proxiedFetcher<Record<string, any>>(`/ajax/sources/${sourceId}`, {
|
|
||||||
baseUrl: flixHqBase,
|
|
||||||
});
|
|
||||||
|
|
||||||
return jsonData.link;
|
|
||||||
}
|
|
||||||
|
Reference in New Issue
Block a user