fix(source): determine Frembed domain dynamically
This commit is contained in:
parent
7264fd2ed4
commit
924265b964
7 changed files with 41 additions and 24 deletions
|
|
@ -1,3 +1,4 @@
|
|||
import memoize from 'memoizee';
|
||||
import { ContentType } from 'stremio-addon-sdk';
|
||||
import { Context, CountryCode } from '../types';
|
||||
import { Fetcher, getTmdbId, getTmdbNameAndYear, Id } from '../utils';
|
||||
|
|
@ -12,7 +13,7 @@ export class Frembed extends Source {
|
|||
|
||||
public readonly countryCodes: CountryCode[] = [CountryCode.fr];
|
||||
|
||||
public readonly baseUrl = 'https://frembed.my'; // TODO: determine this more dynamically, e.g. via https://audin213.com/
|
||||
public readonly baseUrl = 'https://frembed.my';
|
||||
|
||||
private readonly fetcher: Fetcher;
|
||||
|
||||
|
|
@ -20,17 +21,24 @@ export class Frembed extends Source {
|
|||
super();
|
||||
|
||||
this.fetcher = fetcher;
|
||||
|
||||
this.getBaseUrl = memoize(this.getBaseUrl, {
|
||||
maxAge: 3600000, // 1 hour
|
||||
normalizer: () => 'baseUrl',
|
||||
});
|
||||
}
|
||||
|
||||
public async handleInternal(ctx: Context, _type: string, id: Id): Promise<SourceResult[]> {
|
||||
const tmdbId = await getTmdbId(ctx, this.fetcher, id);
|
||||
const [, year] = await getTmdbNameAndYear(ctx, this.fetcher, tmdbId);
|
||||
|
||||
const apiUrl = tmdbId.season
|
||||
? new URL(`/api/series?id=${tmdbId.id}&sa=${tmdbId.season}&epi=${tmdbId.episode}&idType=tmdb`, this.baseUrl)
|
||||
: new URL(`/api/films?id=${tmdbId.id}&idType=tmdb`, this.baseUrl);
|
||||
const baseUrl = await this.getBaseUrl(ctx);
|
||||
|
||||
const json = await this.fetcher.json(ctx, apiUrl, { headers: { Referer: this.baseUrl } });
|
||||
const apiUrl = tmdbId.season
|
||||
? new URL(`/api/series?id=${tmdbId.id}&sa=${tmdbId.season}&epi=${tmdbId.episode}&idType=tmdb`, baseUrl)
|
||||
: new URL(`/api/films?id=${tmdbId.id}&idType=tmdb`, baseUrl);
|
||||
|
||||
const json = await this.fetcher.json(ctx, apiUrl, { headers: { Referer: baseUrl.origin } });
|
||||
|
||||
const urls: URL[] = [];
|
||||
for (const key in json) {
|
||||
|
|
@ -47,6 +55,14 @@ export class Frembed extends Source {
|
|||
? `${json['title']} ${tmdbId.formatSeasonAndEpisode()}`
|
||||
: `${json['title']} (${year})`;
|
||||
|
||||
return urls.map(url => ({ url, meta: { countryCodes: [CountryCode.fr], referer: this.baseUrl, title } }));
|
||||
return urls.map(url => ({ url, meta: { countryCodes: [CountryCode.fr], referer: baseUrl.origin, title } }));
|
||||
};
|
||||
|
||||
private readonly getBaseUrl = async (ctx: Context): Promise<URL> => {
|
||||
const html = await this.fetcher.text(ctx, new URL('https://audin213.com/'));
|
||||
|
||||
const frembedMatcher = html.match(/"(https:\/\/frembed.*?)"/) as string[];
|
||||
|
||||
return new URL(frembedMatcher[1] as string);
|
||||
};
|
||||
}
|
||||
|
|
|
|||
1
src/source/__fixtures__/Frembed/https:audin213.com
generated
Normal file
1
src/source/__fixtures__/Frembed/https:audin213.com
generated
Normal file
File diff suppressed because one or more lines are too long
1
src/source/__fixtures__/Frembed/https:frembed.lifeapifilmsid3176andidTypetmdb
generated
Normal file
1
src/source/__fixtures__/Frembed/https:frembed.lifeapifilmsid3176andidTypetmdb
generated
Normal file
|
|
@ -0,0 +1 @@
|
|||
{"tmdb":"3176","title":"Battle Royale","link1":"https://dsvplay.com/e/gtenfs0rffzq","link2":"https://netu.fremtv.lol/e/p0QUHavRbQD0","link3":"https://walterprettytheir.com/e/lbeqm6ofmauq","link4":"https://video.streamtales.cc/player/frvod.php?url=https://streamtales.cc:8443/videos/3176.mp4","link5":null,"link6":"","link7":"https://uqload.cx/embed-pnxmokgrigu9.html","link1vostfr":null,"link2vostfr":null,"link3vostfr":null,"link4vostfr":null,"link5vostfr":null,"link6vostfr":null,"link7vostfr":null,"link1vo":null,"link2vo":null,"link3vo":null,"link4vo":null,"link5vo":null,"link6vo":null,"link7vo":null,"imdb":"tt0266308","year":"2000","version":"TrueFrench","quality":"HD","qualityVostfr":null,"qualityVo":null,"poster":"/8PzexNbQ9eAKxe0p2U4XP3DVJCp.jpg","backdrop":"/pmRtI4QvcBvXjw9mLOEAsV9Bq7i.jpg,/amBvmIshdsSkOtvVIgxl7YSQ9Dg.jpg,/n4rNQUV9S9DMgCkQVt7R7VLYxNr.jpg,/55qVIFhykb6M6CGWRKQd9BsLI5D.jpg,/e9vJTJHkCOyBitE67n8zlp5Qm8q.jpg,/tSbZky1KLzqOSGPzYtqnxTQzNFy.jpg,/cQR3VHRMUL8xGkWK5Up8rI7DHQD.jpg,/4oIoe9tcSRzGSImp9Jqp1SKFwes.jpg,/zajlFkhKugj9tqH57KHXpmTXIku.jpg,/hpP0ELkViFlU8PVWbEBvVx12YtJ.jpg","checked":null,"dead_link":0,"views":"2","date_creation":"2023-08-17T04:06:45.000Z","update_date":"2024-09-19T01:28:34.000Z","original_title":"バトル・ロワイアル","title_vf":"Battle Royale","tatavid":null,"dcsutom":96950}
|
||||
1
src/source/__fixtures__/Frembed/https:frembed.lifeapiseriesid42009andsa4andepi2andidTypetmdb
generated
Normal file
1
src/source/__fixtures__/Frembed/https:frembed.lifeapiseriesid42009andsa4andepi2andidTypetmdb
generated
Normal file
|
|
@ -0,0 +1 @@
|
|||
{"id":44334,"tmdb":"42009","title":"Black Mirror","sa":4,"epi":2,"link":"https://ahvsh.com/e/83izf7qzwpae,https://netu.frembed.fun/e/0DFgfkcXOsDP,https://likessb.com/e/7yjgl1x56n08.html,https://ds2play.com/e/fzfvfq3ngig0","imdb":"tt2085059","year":null,"version":"VF","link_vostfr":"","link1":"https://dsvplay.com/e/dfx8me4un4ul\t","link2":"https://netu.fremtv.lol/e/0DFgfkcXOsDP","link3":"https://walterprettytheir.com/e/cqy9oue7sv0g\t","link4":"https://ds2play.com/e/fzfvfq3ngig0","link5":null,"link6":null,"link7":null,"link1vostfr":"","link2vostfr":null,"link3vostfr":null,"link4vostfr":null,"link5vostfr":null,"link6vostfr":null,"link7vostfr":null,"link1vo":null,"link2vo":null,"link3vo":null,"link4vo":null,"link5vo":null,"link6vo":null,"link7vo":null,"date_creation":"2023-08-17T04:06:31.000Z","update_date":"2025-06-13T23:04:32.000Z","views":2,"backdropImage":"/dg3OindVAGZBjlT3xYKqIAdukPL.jpg","posterImage":"/seN6rRfN0I6n8iDXjlSMk1QjNcq.jpg","prevEpisode":{"sa":4,"epi":1,"url":"/series?id=42009&sa=4&epi=1"},"nextEpisode":{"sa":4,"epi":3,"url":"/series?id=42009&sa=4&epi=3"}}
|
||||
|
|
@ -1 +0,0 @@
|
|||
{"tmdb":"3176","title":"Battle Royale","link1":"https://dsvplay.com/e/gtenfs0rffzq","link2":"https://netu.fremtv.lol/e/p0QUHavRbQD0","link3":"https://christopheruntilpoint.com/e/lbeqm6ofmauq","link4":"https://video.streamtales.cc/player/frvod.php?url=https://streamtales.cc:8443/videos/3176.mp4","link5":null,"link6":"","link7":"https://uqload.cx/embed-pnxmokgrigu9.html","link1vostfr":null,"link2vostfr":null,"link3vostfr":null,"link4vostfr":null,"link5vostfr":null,"link6vostfr":null,"link7vostfr":null,"link1vo":null,"link2vo":null,"link3vo":null,"link4vo":null,"link5vo":null,"link6vo":null,"link7vo":null,"imdb":"tt0266308","year":"2000","version":"TrueFrench","quality":"HD","qualityVostfr":null,"qualityVo":null,"poster":"/8PzexNbQ9eAKxe0p2U4XP3DVJCp.jpg","backdrop":"/pmRtI4QvcBvXjw9mLOEAsV9Bq7i.jpg,/amBvmIshdsSkOtvVIgxl7YSQ9Dg.jpg,/n4rNQUV9S9DMgCkQVt7R7VLYxNr.jpg,/55qVIFhykb6M6CGWRKQd9BsLI5D.jpg,/e9vJTJHkCOyBitE67n8zlp5Qm8q.jpg,/tSbZky1KLzqOSGPzYtqnxTQzNFy.jpg,/cQR3VHRMUL8xGkWK5Up8rI7DHQD.jpg,/4oIoe9tcSRzGSImp9Jqp1SKFwes.jpg,/zajlFkhKugj9tqH57KHXpmTXIku.jpg,/hpP0ELkViFlU8PVWbEBvVx12YtJ.jpg","checked":null,"dead_link":0,"views":"23","date_creation":"2023-08-17T04:06:45.000Z","update_date":"2024-09-19T01:28:34.000Z","original_title":"バトル・ロワイアル","title_vf":"Battle Royale","tatavid":null,"dcsutom":96950}
|
||||
|
|
@ -1 +0,0 @@
|
|||
{"id":44334,"tmdb":"42009","title":"Black Mirror","sa":4,"epi":2,"link":"https://ahvsh.com/e/83izf7qzwpae,https://netu.frembed.fun/e/0DFgfkcXOsDP,https://likessb.com/e/7yjgl1x56n08.html,https://ds2play.com/e/fzfvfq3ngig0","imdb":"tt2085059","year":null,"version":"VF","link_vostfr":"","link1":"https://dsvplay.com/e/dfx8me4un4ul\t","link2":"https://netu.fremtv.lol/e/0DFgfkcXOsDP","link3":"https://christopheruntilpoint.com/e/cqy9oue7sv0g\t","link4":"https://ds2play.com/e/fzfvfq3ngig0","link5":null,"link6":null,"link7":null,"link1vostfr":"","link2vostfr":null,"link3vostfr":null,"link4vostfr":null,"link5vostfr":null,"link6vostfr":null,"link7vostfr":null,"link1vo":null,"link2vo":null,"link3vo":null,"link4vo":null,"link5vo":null,"link6vo":null,"link7vo":null,"date_creation":"2023-08-17T04:06:31.000Z","update_date":"2025-06-13T23:04:32.000Z","views":11,"backdropImage":"/dg3OindVAGZBjlT3xYKqIAdukPL.jpg","posterImage":"/seN6rRfN0I6n8iDXjlSMk1QjNcq.jpg","prevEpisode":{"sa":4,"epi":1,"url":"/series?id=42009&sa=4&epi=1"},"nextEpisode":{"sa":4,"epi":3,"url":"/series?id=42009&sa=4&epi=3"}}
|
||||
|
|
@ -7,7 +7,7 @@ exports[`Frembed handle battle royal 1`] = `
|
|||
"countryCodes": [
|
||||
"fr",
|
||||
],
|
||||
"referer": "https://frembed.my",
|
||||
"referer": "https://frembed.life",
|
||||
"title": "Battle Royale (2000)",
|
||||
},
|
||||
"url": "https://dsvplay.com/e/gtenfs0rffzq",
|
||||
|
|
@ -17,7 +17,7 @@ exports[`Frembed handle battle royal 1`] = `
|
|||
"countryCodes": [
|
||||
"fr",
|
||||
],
|
||||
"referer": "https://frembed.my",
|
||||
"referer": "https://frembed.life",
|
||||
"title": "Battle Royale (2000)",
|
||||
},
|
||||
"url": "https://netu.fremtv.lol/e/p0QUHavRbQD0",
|
||||
|
|
@ -27,17 +27,17 @@ exports[`Frembed handle battle royal 1`] = `
|
|||
"countryCodes": [
|
||||
"fr",
|
||||
],
|
||||
"referer": "https://frembed.my",
|
||||
"referer": "https://frembed.life",
|
||||
"title": "Battle Royale (2000)",
|
||||
},
|
||||
"url": "https://christopheruntilpoint.com/e/lbeqm6ofmauq",
|
||||
"url": "https://walterprettytheir.com/e/lbeqm6ofmauq",
|
||||
},
|
||||
{
|
||||
"meta": {
|
||||
"countryCodes": [
|
||||
"fr",
|
||||
],
|
||||
"referer": "https://frembed.my",
|
||||
"referer": "https://frembed.life",
|
||||
"title": "Battle Royale (2000)",
|
||||
},
|
||||
"url": "https://video.streamtales.cc/player/frvod.php?url=https://streamtales.cc:8443/videos/3176.mp4",
|
||||
|
|
@ -47,7 +47,7 @@ exports[`Frembed handle battle royal 1`] = `
|
|||
"countryCodes": [
|
||||
"fr",
|
||||
],
|
||||
"referer": "https://frembed.my",
|
||||
"referer": "https://frembed.life",
|
||||
"title": "Battle Royale (2000)",
|
||||
},
|
||||
"url": "https://uqload.cx/embed-pnxmokgrigu9.html",
|
||||
|
|
@ -62,7 +62,7 @@ exports[`Frembed handle imdb black mirror s4e2 1`] = `
|
|||
"countryCodes": [
|
||||
"fr",
|
||||
],
|
||||
"referer": "https://frembed.my",
|
||||
"referer": "https://frembed.life",
|
||||
"title": "Black Mirror S04E02",
|
||||
},
|
||||
"url": "https://dsvplay.com/e/dfx8me4un4ul",
|
||||
|
|
@ -72,7 +72,7 @@ exports[`Frembed handle imdb black mirror s4e2 1`] = `
|
|||
"countryCodes": [
|
||||
"fr",
|
||||
],
|
||||
"referer": "https://frembed.my",
|
||||
"referer": "https://frembed.life",
|
||||
"title": "Black Mirror S04E02",
|
||||
},
|
||||
"url": "https://netu.fremtv.lol/e/0DFgfkcXOsDP",
|
||||
|
|
@ -82,17 +82,17 @@ exports[`Frembed handle imdb black mirror s4e2 1`] = `
|
|||
"countryCodes": [
|
||||
"fr",
|
||||
],
|
||||
"referer": "https://frembed.my",
|
||||
"referer": "https://frembed.life",
|
||||
"title": "Black Mirror S04E02",
|
||||
},
|
||||
"url": "https://christopheruntilpoint.com/e/cqy9oue7sv0g",
|
||||
"url": "https://walterprettytheir.com/e/cqy9oue7sv0g",
|
||||
},
|
||||
{
|
||||
"meta": {
|
||||
"countryCodes": [
|
||||
"fr",
|
||||
],
|
||||
"referer": "https://frembed.my",
|
||||
"referer": "https://frembed.life",
|
||||
"title": "Black Mirror S04E02",
|
||||
},
|
||||
"url": "https://ds2play.com/e/fzfvfq3ngig0",
|
||||
|
|
@ -107,7 +107,7 @@ exports[`Frembed handle tmdb black mirror s4e2 1`] = `
|
|||
"countryCodes": [
|
||||
"fr",
|
||||
],
|
||||
"referer": "https://frembed.my",
|
||||
"referer": "https://frembed.life",
|
||||
"title": "Black Mirror S04E02",
|
||||
},
|
||||
"url": "https://dsvplay.com/e/dfx8me4un4ul",
|
||||
|
|
@ -117,7 +117,7 @@ exports[`Frembed handle tmdb black mirror s4e2 1`] = `
|
|||
"countryCodes": [
|
||||
"fr",
|
||||
],
|
||||
"referer": "https://frembed.my",
|
||||
"referer": "https://frembed.life",
|
||||
"title": "Black Mirror S04E02",
|
||||
},
|
||||
"url": "https://netu.fremtv.lol/e/0DFgfkcXOsDP",
|
||||
|
|
@ -127,17 +127,17 @@ exports[`Frembed handle tmdb black mirror s4e2 1`] = `
|
|||
"countryCodes": [
|
||||
"fr",
|
||||
],
|
||||
"referer": "https://frembed.my",
|
||||
"referer": "https://frembed.life",
|
||||
"title": "Black Mirror S04E02",
|
||||
},
|
||||
"url": "https://christopheruntilpoint.com/e/cqy9oue7sv0g",
|
||||
"url": "https://walterprettytheir.com/e/cqy9oue7sv0g",
|
||||
},
|
||||
{
|
||||
"meta": {
|
||||
"countryCodes": [
|
||||
"fr",
|
||||
],
|
||||
"referer": "https://frembed.my",
|
||||
"referer": "https://frembed.life",
|
||||
"title": "Black Mirror S04E02",
|
||||
},
|
||||
"url": "https://ds2play.com/e/fzfvfq3ngig0",
|
||||
|
|
|
|||
Loading…
Reference in a new issue