From b6a8e6f448c30dd91e3ac3ea624e4e01c8e4ac2b Mon Sep 17 00:00:00 2001 From: WebStreamr <210764791+webstreamr@users.noreply.github.com> Date: Tue, 19 Aug 2025 09:50:04 +0000 Subject: [PATCH] feat(source): add Einschalten --- src/source/Einschalten.test.ts | 18 ++++++++++ src/source/Einschalten.ts | 35 +++++++++++++++++++ .../https:einschalten.inapimovies1061474watch | 1 + .../__snapshots__/Einschalten.test.ts.snap | 11 ++++++ src/source/index.ts | 2 ++ src/utils/__snapshots__/manifest.test.ts.snap | 2 +- 6 files changed, 68 insertions(+), 1 deletion(-) create mode 100644 src/source/Einschalten.test.ts create mode 100644 src/source/Einschalten.ts create mode 100644 src/source/__fixtures__/Einschalten/https:einschalten.inapimovies1061474watch create mode 100644 src/source/__snapshots__/Einschalten.test.ts.snap diff --git a/src/source/Einschalten.test.ts b/src/source/Einschalten.test.ts new file mode 100644 index 0000000..64239fa --- /dev/null +++ b/src/source/Einschalten.test.ts @@ -0,0 +1,18 @@ +import { createTestContext } from '../test'; +import { FetcherMock, TmdbId } from '../utils'; +import { Einschalten } from './Einschalten'; + +const ctx = createTestContext({ de: 'on' }); + +describe('Einschalten', () => { + let source: Einschalten; + + beforeEach(() => { + source = new Einschalten(new FetcherMock(`${__dirname}/__fixtures__/Einschalten`)); + }); + + test('handle superman', async () => { + const streams = await source.handle(ctx, 'movie', new TmdbId(1061474, undefined, undefined)); + expect(streams).toMatchSnapshot(); + }); +}); diff --git a/src/source/Einschalten.ts b/src/source/Einschalten.ts new file mode 100644 index 0000000..36b20a3 --- /dev/null +++ b/src/source/Einschalten.ts @@ -0,0 +1,35 @@ +import { ContentType } from 'stremio-addon-sdk'; +import { Context, CountryCode } from '../types'; +import { Fetcher, getTmdbId, Id } from '../utils'; +import { Source, SourceResult } from './types'; + +interface EinschaltenResponse { + releaseName: string; + streamUrl: string; +} + +export class Einschalten implements Source { + public readonly id = 'einschalten'; + + public readonly label = 'Einschalten'; + + public readonly contentTypes: ContentType[] = ['movie']; + + public readonly countryCodes: CountryCode[] = [CountryCode.de]; + + public readonly baseUrl = 'https://einschalten.in'; + + private readonly fetcher: Fetcher; + + public constructor(fetcher: Fetcher) { + this.fetcher = fetcher; + } + + public async handle(ctx: Context, _type: string, id: Id): Promise { + const tmdbId = await getTmdbId(ctx, this.fetcher, id); + + const { releaseName, streamUrl } = JSON.parse(await this.fetcher.text(ctx, new URL(`/api/movies/${tmdbId.id}/watch`, this.baseUrl))) as EinschaltenResponse; + + return [{ countryCode: CountryCode.de, title: releaseName, url: new URL(streamUrl) }]; + }; +} diff --git a/src/source/__fixtures__/Einschalten/https:einschalten.inapimovies1061474watch b/src/source/__fixtures__/Einschalten/https:einschalten.inapimovies1061474watch new file mode 100644 index 0000000..ef906e1 --- /dev/null +++ b/src/source/__fixtures__/Einschalten/https:einschalten.inapimovies1061474watch @@ -0,0 +1 @@ +{"releaseName":"Superman.2025.German.DL.720p.WEB.H264-ZeroTwo","streamUrl":"https://vide0.net/e/qtvqjblhu74i"} \ No newline at end of file diff --git a/src/source/__snapshots__/Einschalten.test.ts.snap b/src/source/__snapshots__/Einschalten.test.ts.snap new file mode 100644 index 0000000..46532c7 --- /dev/null +++ b/src/source/__snapshots__/Einschalten.test.ts.snap @@ -0,0 +1,11 @@ +// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing + +exports[`Einschalten handle superman 1`] = ` +[ + { + "countryCode": "de", + "title": "Superman.2025.German.DL.720p.WEB.H264-ZeroTwo", + "url": "https://vide0.net/e/qtvqjblhu74i", + }, +] +`; diff --git a/src/source/index.ts b/src/source/index.ts index ab44a51..94f506c 100644 --- a/src/source/index.ts +++ b/src/source/index.ts @@ -1,6 +1,7 @@ import { Fetcher } from '../utils'; import { CineHDPlus } from './CineHDPlus'; import { Cuevana } from './Cuevana'; +import { Einschalten } from './Einschalten'; import { Eurostreaming } from './Eurostreaming'; import { Frembed } from './Frembed'; import { FrenchCloud } from './FrenchCloud'; @@ -34,6 +35,7 @@ export const createSources = (fetcher: Fetcher): Source[] => [ new HomeCine(fetcher), new VerHdLink(fetcher), // DE + new Einschalten(fetcher), new KinoGer(fetcher), new MegaKino(fetcher), new MeineCloud(fetcher), diff --git a/src/utils/__snapshots__/manifest.test.ts.snap b/src/utils/__snapshots__/manifest.test.ts.snap index a1d343e..d91227e 100644 --- a/src/utils/__snapshots__/manifest.test.ts.snap +++ b/src/utils/__snapshots__/manifest.test.ts.snap @@ -16,7 +16,7 @@ exports[`buildManifest default manifest 1`] = ` }, { "key": "de", - "title": "German 🇩🇪 (KinoGer, MegaKino, MeineCloud, StreamKiste)", + "title": "German 🇩🇪 (Einschalten, KinoGer, MegaKino, MeineCloud, StreamKiste)", "type": "checkbox", }, {