From 258e35c94db461a2efcb9089d640024ab123bdb6 Mon Sep 17 00:00:00 2001 From: WebStreamr <210764791+webstreamr@users.noreply.github.com> Date: Fri, 12 Dec 2025 16:12:41 +0000 Subject: [PATCH] fix(source): resolve MegaKino dynamically and cache for an hour --- package-lock.json | 178 ++++++++++++++++-- package.json | 2 + src/source/MegaKino.ts | 18 +- .../MegaKino/head-https:megakino.oneygtoken | 1 + ...no.oneadventure4804-the-lego-movie-2.html} | 61 +++--- ...efilms693-baymax-riesiges-robowabohu.html} | 61 +++--- ...:megakino.onefilms727-the-lego-movie.html} | 63 +++---- ...earchandsubactionsearchandstorytt12345678} | 33 ++-- ...searchandsubactionsearchandstorytt1490017} | 35 ++-- ...searchandsubactionsearchandstorytt2245084} | 35 ++-- ...searchandsubactionsearchandstorytt3513498} | 35 ++-- .../__snapshots__/MegaKino.test.ts.snap | 12 +- src/utils/Fetcher.ts | 19 +- 13 files changed, 364 insertions(+), 189 deletions(-) create mode 100644 src/source/__fixtures__/MegaKino/head-https:megakino.oneygtoken rename src/source/__fixtures__/MegaKino/{https:megakino.clubadventure4804-the-lego-movie-2.html => https:megakino.oneadventure4804-the-lego-movie-2.html} (77%) rename src/source/__fixtures__/MegaKino/{https:megakino.clubfilms693-baymax-riesiges-robowabohu.html => https:megakino.onefilms693-baymax-riesiges-robowabohu.html} (82%) rename src/source/__fixtures__/MegaKino/{https:megakino.clubfilms727-the-lego-movie.html => https:megakino.onefilms727-the-lego-movie.html} (82%) rename src/source/__fixtures__/MegaKino/{post-https:megakino.club-dosearchandsubactionsearchandstorytt12345678 => post-https:megakino.one-dosearchandsubactionsearchandstorytt12345678} (82%) rename src/source/__fixtures__/MegaKino/{post-https:megakino.club-dosearchandsubactionsearchandstorytt1490017 => post-https:megakino.one-dosearchandsubactionsearchandstorytt1490017} (82%) rename src/source/__fixtures__/MegaKino/{post-https:megakino.club-dosearchandsubactionsearchandstorytt2245084 => post-https:megakino.one-dosearchandsubactionsearchandstorytt2245084} (82%) rename src/source/__fixtures__/MegaKino/{post-https:megakino.club-dosearchandsubactionsearchandstorytt3513498 => post-https:megakino.one-dosearchandsubactionsearchandstorytt3513498} (82%) diff --git a/package-lock.json b/package-lock.json index 2c04e6f..6be7ff7 100644 --- a/package-lock.json +++ b/package-lock.json @@ -22,6 +22,7 @@ "fast-levenshtein": "^3.0.0", "http-proxy-agent": "^7.0.2", "https-proxy-agent": "^7.0.6", + "memoizee": "^0.4.17", "minimatch": "^10.0.3", "randomstring": "^1.3.1", "rot13-cipher": "^1.0.0", @@ -39,6 +40,7 @@ "@types/express": "^5.0.1", "@types/fast-levenshtein": "^0.0.4", "@types/jest": "^30.0.0", + "@types/memoizee": "^0.4.12", "@types/node": "^24.0.0", "@types/randomstring": "^1.3.0", "@types/stremio-addon-sdk": "^1.6.11", @@ -87,7 +89,6 @@ "integrity": "sha512-e7jT4DxYvIDLk1ZHmU/m/mB19rex9sv0c2ftBtjSBv+kVM/902eh0fINUzD7UwLLNR+jU585GxUJ8/EBfAM5fw==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "@babel/code-frame": "^7.27.1", "@babel/generator": "^7.28.5", @@ -1765,13 +1766,19 @@ "dev": true, "license": "MIT" }, + "node_modules/@types/memoizee": { + "version": "0.4.12", + "resolved": "https://registry.npmjs.org/@types/memoizee/-/memoizee-0.4.12.tgz", + "integrity": "sha512-EdtpwNYNhe3kZ+4TlXj/++pvBoU0KdrAICMzgI7vjWgu9sIvvUhu9XR8Ks4L6Wh3sxpZ22wkZR7yCLAqUjnZuQ==", + "dev": true, + "license": "MIT" + }, "node_modules/@types/node": { "version": "24.10.1", "resolved": "https://registry.npmjs.org/@types/node/-/node-24.10.1.tgz", "integrity": "sha512-GNWcUTRBgIRJD5zj+Tq0fKOJ5XZajIiBroOF0yvj2bSU1WvNdYS/dn9UxwsujGW4JX06dnHyjV2y9rRaybH0iQ==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "undici-types": "~7.16.0" } @@ -1900,7 +1907,6 @@ "integrity": "sha512-N9lBGA9o9aqb1hVMc9hzySbhKibHmB+N3IpoShyV6HyQYRGIhlrO5rQgttypi+yEeKsKI4idxC8Jw6gXKD4THA==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "@typescript-eslint/scope-manager": "8.49.0", "@typescript-eslint/types": "8.49.0", @@ -2427,7 +2433,6 @@ "integrity": "sha512-NZyJarBfL7nWwIq+FDL6Zp/yHEhePMNnnJ0y3qfieCrmNvYct8uvtiV41UvlSe6apAfk0fY1FbWx+NwfmpvtTg==", "dev": true, "license": "MIT", - "peer": true, "bin": { "acorn": "bin/acorn" }, @@ -2796,7 +2801,6 @@ "resolved": "https://registry.npmjs.org/axios/-/axios-1.13.2.tgz", "integrity": "sha512-VPk9ebNqPcy5lRGuSlKx752IlDatOjT9paPlm8A7yOuW2Fbvp4X3JznJtT4f0GzGLLiWE9W8onz51SqLYwzGaA==", "license": "MIT", - "peer": true, "dependencies": { "follow-redirects": "^1.15.6", "form-data": "^4.0.4", @@ -3108,7 +3112,6 @@ } ], "license": "MIT", - "peer": true, "dependencies": { "baseline-browser-mapping": "^2.9.0", "caniuse-lite": "^1.0.30001759", @@ -3845,6 +3848,19 @@ "url": "https://github.com/sponsors/fb55" } }, + "node_modules/d": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/d/-/d-1.0.2.tgz", + "integrity": "sha512-MOqHvMWF9/9MX6nza0KgvFH4HpMU0EF5uUDXqX/BtxtU8NfB0QzRtJ8Oe/6SuS4kbhyzVJwjd97EA4PKrzJ8bw==", + "license": "ISC", + "dependencies": { + "es5-ext": "^0.10.64", + "type": "^2.7.2" + }, + "engines": { + "node": ">=0.12" + } + }, "node_modules/data-view-buffer": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/data-view-buffer/-/data-view-buffer-1.0.2.tgz", @@ -4415,6 +4431,58 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/es5-ext": { + "version": "0.10.64", + "resolved": "https://registry.npmjs.org/es5-ext/-/es5-ext-0.10.64.tgz", + "integrity": "sha512-p2snDhiLaXe6dahss1LddxqEm+SkuDvV8dnIQG0MWjyHpcMNfXKPE+/Cc0y+PhxJX3A4xGNeFCj5oc0BUh6deg==", + "hasInstallScript": true, + "license": "ISC", + "dependencies": { + "es6-iterator": "^2.0.3", + "es6-symbol": "^3.1.3", + "esniff": "^2.0.1", + "next-tick": "^1.1.0" + }, + "engines": { + "node": ">=0.10" + } + }, + "node_modules/es6-iterator": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/es6-iterator/-/es6-iterator-2.0.3.tgz", + "integrity": "sha512-zw4SRzoUkd+cl+ZoE15A9o1oQd920Bb0iOJMQkQhl3jNc03YqVjAhG7scf9C5KWRU/R13Orf588uCC6525o02g==", + "license": "MIT", + "dependencies": { + "d": "1", + "es5-ext": "^0.10.35", + "es6-symbol": "^3.1.1" + } + }, + "node_modules/es6-symbol": { + "version": "3.1.4", + "resolved": "https://registry.npmjs.org/es6-symbol/-/es6-symbol-3.1.4.tgz", + "integrity": "sha512-U9bFFjX8tFiATgtkJ1zg25+KviIXpgRvRHS8sau3GfhVzThRQrOeksPeT0BWW2MNZs1OEWJ1DPXOQMn0KKRkvg==", + "license": "ISC", + "dependencies": { + "d": "^1.0.2", + "ext": "^1.7.0" + }, + "engines": { + "node": ">=0.12" + } + }, + "node_modules/es6-weak-map": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/es6-weak-map/-/es6-weak-map-2.0.3.tgz", + "integrity": "sha512-p5um32HOTO1kP+w7PRnB+5lQ43Z6muuMuIMffvDN8ZB4GcnjLBV6zGStpbASIMk4DCAvEaamhe2zhyCb/QXXsA==", + "license": "ISC", + "dependencies": { + "d": "1", + "es5-ext": "^0.10.46", + "es6-iterator": "^2.0.3", + "es6-symbol": "^3.1.1" + } + }, "node_modules/escalade": { "version": "3.2.0", "resolved": "https://registry.npmjs.org/escalade/-/escalade-3.2.0.tgz", @@ -4450,7 +4518,6 @@ "integrity": "sha512-BhHmn2yNOFA9H9JmmIVKJmd288g9hrVRDkdoIgRCRuSySRUHH7r/DI6aAXW9T1WwUuY3DFgrcaqB+deURBLR5g==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "@eslint-community/eslint-utils": "^4.8.0", "@eslint-community/regexpp": "^4.12.1", @@ -4704,6 +4771,21 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/esniff": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/esniff/-/esniff-2.0.1.tgz", + "integrity": "sha512-kTUIGKQ/mDPFoJ0oVfcmyJn4iBDRptjNVIzwIFR7tqWXdVI9xfA2RMwY/gbSpJG3lkdWNEjLap/NqVHZiJsdfg==", + "license": "ISC", + "dependencies": { + "d": "^1.0.1", + "es5-ext": "^0.10.62", + "event-emitter": "^0.3.5", + "type": "^2.7.2" + }, + "engines": { + "node": ">=0.10" + } + }, "node_modules/espree": { "version": "10.4.0", "resolved": "https://registry.npmjs.org/espree/-/espree-10.4.0.tgz", @@ -4791,6 +4873,16 @@ "node": ">= 0.6" } }, + "node_modules/event-emitter": { + "version": "0.3.5", + "resolved": "https://registry.npmjs.org/event-emitter/-/event-emitter-0.3.5.tgz", + "integrity": "sha512-D9rRn9y7kLPnJ+hMq7S/nhvoKwwvVJahBi2BPmx3bvbsEdK3W9ii8cBSGjP+72/LnM4n6fo3+dkCX5FeTQruXA==", + "license": "MIT", + "dependencies": { + "d": "1", + "es5-ext": "~0.10.14" + } + }, "node_modules/execa": { "version": "5.1.1", "resolved": "https://registry.npmjs.org/execa/-/execa-5.1.1.tgz", @@ -4902,6 +4994,15 @@ "url": "https://opencollective.com/express" } }, + "node_modules/ext": { + "version": "1.7.0", + "resolved": "https://registry.npmjs.org/ext/-/ext-1.7.0.tgz", + "integrity": "sha512-6hxeJYaL110a9b5TEJSj0gojyHQAmA2ch5Os+ySCiA1QGdS697XWY1pzsrSjqA9LDEEgdB/KypIlR59RcLuHYw==", + "license": "ISC", + "dependencies": { + "type": "^2.7.2" + } + }, "node_modules/fast-deep-equal": { "version": "3.1.3", "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz", @@ -6620,7 +6721,6 @@ "integrity": "sha512-F26gjC0yWN8uAA5m5Ss8ZQf5nDHWGlN/xWZIh8S5SRbsEKBovwZhxGd6LJlbZYxBgCYOtreSUyb8hpXyGC5O4A==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "@jest/core": "30.2.0", "@jest/types": "30.2.0", @@ -7288,7 +7388,6 @@ "resolved": "https://registry.npmjs.org/keyv/-/keyv-5.5.5.tgz", "integrity": "sha512-FA5LmZVF1VziNc0bIdCSA1IoSVnDCqE8HJIZZv2/W8YmoAM50+tnUgJR/gQZwEeIMleuIOnRnHA/UaZRNeV4iQ==", "license": "MIT", - "peer": true, "dependencies": { "@keyv/serialize": "^1.1.1" } @@ -7384,6 +7483,15 @@ "yallist": "^3.0.2" } }, + "node_modules/lru-queue": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/lru-queue/-/lru-queue-0.1.0.tgz", + "integrity": "sha512-BpdYkt9EvGl8OfWHDQPISVpcl5xZthb+XPsbELj5AQXxIC8IriDZIQYjBJPEm5rS420sjZ0TLEzRcq5KdBhYrQ==", + "license": "MIT", + "dependencies": { + "es5-ext": "~0.10.2" + } + }, "node_modules/make-dir": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/make-dir/-/make-dir-4.0.0.tgz", @@ -7576,6 +7684,31 @@ "node": ">= 0.8" } }, + "node_modules/memoizee": { + "version": "0.4.17", + "resolved": "https://registry.npmjs.org/memoizee/-/memoizee-0.4.17.tgz", + "integrity": "sha512-DGqD7Hjpi/1or4F/aYAspXKNm5Yili0QDAFAY4QYvpqpgiY6+1jOfqpmByzjxbWd/T9mChbCArXAbDAsTm5oXA==", + "license": "ISC", + "dependencies": { + "d": "^1.0.2", + "es5-ext": "^0.10.64", + "es6-weak-map": "^2.0.3", + "event-emitter": "^0.3.5", + "is-promise": "^2.2.2", + "lru-queue": "^0.1.0", + "next-tick": "^1.1.0", + "timers-ext": "^0.1.7" + }, + "engines": { + "node": ">=0.12" + } + }, + "node_modules/memoizee/node_modules/is-promise": { + "version": "2.2.2", + "resolved": "https://registry.npmjs.org/is-promise/-/is-promise-2.2.2.tgz", + "integrity": "sha512-+lP4/6lKUBfQjZ2pdxThZvLUAafmZb8OAxFb8XXtiQmS35INgr85hdOGoEs124ez1FCnZJt6jau/T+alh58QFQ==", + "license": "MIT" + }, "node_modules/merge-descriptors": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/merge-descriptors/-/merge-descriptors-2.0.0.tgz", @@ -7973,6 +8106,12 @@ "dev": true, "license": "MIT" }, + "node_modules/next-tick": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/next-tick/-/next-tick-1.1.0.tgz", + "integrity": "sha512-CXdUiJembsNjuToQvxayPZF9Vqht7hewsvy2sOWafLvi2awflj9mOC6bHIg50orX8IJvWKY9wYQ/zB2kogPslQ==", + "license": "ISC" + }, "node_modules/node-abi": { "version": "3.85.0", "resolved": "https://registry.npmjs.org/node-abi/-/node-abi-3.85.0.tgz", @@ -10195,6 +10334,19 @@ "integrity": "sha512-uuVGNWzgJ4yhRaNSiubPY7OjISw4sw4E5Uv0wbjp+OzcbmVU/rsT8ujgcXJhn9ypzsgr5vlzpPqP+MBBKcGvbg==", "license": "MIT" }, + "node_modules/timers-ext": { + "version": "0.1.8", + "resolved": "https://registry.npmjs.org/timers-ext/-/timers-ext-0.1.8.tgz", + "integrity": "sha512-wFH7+SEAcKfJpfLPkrgMPvvwnEtj8W4IurvEyrKsDleXnKLCDw71w8jltvfLa8Rm4qQxxT4jmDBYbJG/z7qoww==", + "license": "ISC", + "dependencies": { + "es5-ext": "^0.10.64", + "next-tick": "^1.1.0" + }, + "engines": { + "node": ">=0.12" + } + }, "node_modules/tinyglobby": { "version": "0.2.15", "resolved": "https://registry.npmjs.org/tinyglobby/-/tinyglobby-0.2.15.tgz", @@ -10397,7 +10549,6 @@ "integrity": "sha512-f0FFpIdcHgn8zcPSbf1dRevwt047YMnaiJM3u2w2RewrB+fob/zePZcrOyQoLMMO7aBIddLcQIEK5dYjkLnGrQ==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "@cspotcode/source-map-support": "^0.8.0", "@tsconfig/node10": "^1.0.7", @@ -10490,6 +10641,12 @@ "node": "*" } }, + "node_modules/type": { + "version": "2.7.3", + "resolved": "https://registry.npmjs.org/type/-/type-2.7.3.tgz", + "integrity": "sha512-8j+1QmAbPvLZow5Qpi6NCaN8FB60p/6x8/vfNqOk/hC+HuvFZhL4+WfekuhQLiqFZXOgQdrs3B+XxEmCc6b3FQ==", + "license": "ISC" + }, "node_modules/type-check": { "version": "0.4.0", "resolved": "https://registry.npmjs.org/type-check/-/type-check-0.4.0.tgz", @@ -10624,7 +10781,6 @@ "integrity": "sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw==", "dev": true, "license": "Apache-2.0", - "peer": true, "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" diff --git a/package.json b/package.json index 34b4b95..691b656 100644 --- a/package.json +++ b/package.json @@ -54,6 +54,7 @@ "fast-levenshtein": "^3.0.0", "http-proxy-agent": "^7.0.2", "https-proxy-agent": "^7.0.6", + "memoizee": "^0.4.17", "minimatch": "^10.0.3", "randomstring": "^1.3.1", "rot13-cipher": "^1.0.0", @@ -71,6 +72,7 @@ "@types/express": "^5.0.1", "@types/fast-levenshtein": "^0.0.4", "@types/jest": "^30.0.0", + "@types/memoizee": "^0.4.12", "@types/node": "^24.0.0", "@types/randomstring": "^1.3.0", "@types/stremio-addon-sdk": "^1.6.11", diff --git a/src/source/MegaKino.ts b/src/source/MegaKino.ts index 11fd3c5..9488a91 100644 --- a/src/source/MegaKino.ts +++ b/src/source/MegaKino.ts @@ -1,4 +1,5 @@ import * as cheerio from 'cheerio'; +import memoize from 'memoizee'; import { ContentType } from 'stremio-addon-sdk'; import { Cookie } from 'tough-cookie'; import { Context, CountryCode } from '../types'; @@ -14,7 +15,7 @@ export class MegaKino extends Source { public readonly countryCodes: CountryCode[] = [CountryCode.de]; - public readonly baseUrl = 'https://megakino.club'; // TODO: determine this more dynamically since cookie fetching does not work otherwise + public readonly baseUrl = 'https://megakino.club'; private readonly fetcher: Fetcher; @@ -22,12 +23,17 @@ export class MegaKino 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 { const imdbId = await getImdbId(ctx, this.fetcher, id); - const tokenResponse = await this.fetcher.fetch(ctx, new URL('/?yg=token', this.baseUrl), { method: 'HEAD' }); + const tokenResponse = await this.fetcher.fetch(ctx, new URL('/?yg=token', await this.getBaseUrl(ctx)), { method: 'HEAD' }); const cookie = Cookie.parse((tokenResponse.headers['set-cookie'] as string[])[0] as string) as Cookie; @@ -56,7 +62,7 @@ export class MegaKino extends Source { form.append('subaction', 'search'); form.append('story', `${imdbId.id}`); - const postUrl = new URL(this.baseUrl); + const postUrl = await this.getBaseUrl(ctx); const html = await this.fetcher.textPost( ctx, @@ -77,4 +83,10 @@ export class MegaKino extends Source { .map((_i, el) => new URL($(el).attr('href') as string)) .get(0); }; + + private readonly getBaseUrl = async (ctx: Context): Promise => { + console.log('get base url'); + + return await this.fetcher.getFinalRedirectUrl(ctx, new URL(this.baseUrl)); + }; } diff --git a/src/source/__fixtures__/MegaKino/head-https:megakino.oneygtoken b/src/source/__fixtures__/MegaKino/head-https:megakino.oneygtoken new file mode 100644 index 0000000..888fd8f --- /dev/null +++ b/src/source/__fixtures__/MegaKino/head-https:megakino.oneygtoken @@ -0,0 +1 @@ +{"date":"Fri, 12 Dec 2025 16:12:13 GMT","content-type":"text/html; charset=UTF-8","connection":"close","server":"cloudflare","set-cookie":["yg_token=1765555933.1f336d38fd24318b81d2097255c89ba1ef6a33f8b52085c9bc34de4742cd0be3; expires=Fri, 12 Dec 2025 16:27:13 GMT; Max-Age=900; path=/; secure; HttpOnly; SameSite=Lax"],"cache-control":"no-store","x-frame-options":"SAMEORIGIN","referrer-policy":"strict-origin-when-cross-origin","cf-cache-status":"DYNAMIC","report-to":"{\"group\":\"cf-nel\",\"max_age\":604800,\"endpoints\":[{\"url\":\"https://a.nel.cloudflare.com/report/v4?s=1KBgm0T%2FdvJWLX91nxadrZ2Cr7ek60ncm5kwP3spoRMG6i9hAIMlGAIArQo3T4OdIN8Ab0r4pHjM4iTnokPj6FgSTwKGjrSU%2BQ27Cw%3D%3D\"}]}","nel":"{\"report_to\":\"cf-nel\",\"success_fraction\":0.0,\"max_age\":604800}","cf-ray":"9ace808a1d89916e-FRA","alt-svc":"h3=\":443\"; ma=86400"} \ No newline at end of file diff --git a/src/source/__fixtures__/MegaKino/https:megakino.clubadventure4804-the-lego-movie-2.html b/src/source/__fixtures__/MegaKino/https:megakino.oneadventure4804-the-lego-movie-2.html similarity index 77% rename from src/source/__fixtures__/MegaKino/https:megakino.clubadventure4804-the-lego-movie-2.html rename to src/source/__fixtures__/MegaKino/https:megakino.oneadventure4804-the-lego-movie-2.html index c3dac0d..5142d8d 100644 --- a/src/source/__fixtures__/MegaKino/https:megakino.clubadventure4804-the-lego-movie-2.html +++ b/src/source/__fixtures__/MegaKino/https:megakino.oneadventure4804-the-lego-movie-2.html @@ -9,12 +9,12 @@ - - + + - - - + + + @@ -37,16 +37,15 @@ - + - @@ -88,7 +87,7 @@
Was interessiert Sie?
@@ -97,27 +96,27 @@ @@ -179,14 +178,14 @@
- MEGAKino Adventure The LEGO Movie 2 + MEGAKino Adventure The LEGO Movie 2
- + @@ -204,7 +203,7 @@

The LEGO Movie 2

The Lego Movie 2: The Second Part
-
Canada, Denmark, United States of America, 2019, 107 min
+
Canada, Denmark, United States of America, 2019, 107 min
Adventure / Animation / Filme
16+
@@ -220,11 +219,11 @@
- +
The Lego Batman Movie
@@ -350,7 +349,7 @@
- +
3 Engel für Charlie
@@ -363,7 +362,7 @@
- +
Wir sind die Neuen
@@ -376,7 +375,7 @@
- +
Batman v Superman: Dawn of Justice
@@ -443,12 +442,12 @@
- + - + diff --git a/src/source/__fixtures__/MegaKino/https:megakino.clubfilms693-baymax-riesiges-robowabohu.html b/src/source/__fixtures__/MegaKino/https:megakino.onefilms693-baymax-riesiges-robowabohu.html similarity index 82% rename from src/source/__fixtures__/MegaKino/https:megakino.clubfilms693-baymax-riesiges-robowabohu.html rename to src/source/__fixtures__/MegaKino/https:megakino.onefilms693-baymax-riesiges-robowabohu.html index 08d3cca..71ef59d 100644 --- a/src/source/__fixtures__/MegaKino/https:megakino.clubfilms693-baymax-riesiges-robowabohu.html +++ b/src/source/__fixtures__/MegaKino/https:megakino.onefilms693-baymax-riesiges-robowabohu.html @@ -9,12 +9,12 @@ - - + + - - - + + + @@ -37,16 +37,15 @@ - + - @@ -88,7 +87,7 @@ @@ -97,27 +96,27 @@
@@ -179,14 +178,14 @@
- MEGAKino Filme Baymax - Riesiges Robowabohu + MEGAKino Filme Baymax - Riesiges Robowabohu
- + @@ -204,7 +203,7 @@

Baymax - Riesiges Robowabohu

Big Hero 6
-
United States of America, 2014, 102 min
+
United States of America, 2014, 102 min
Filme / Animation / Action / Adventure / Comedy / Family
16+
@@ -220,11 +219,11 @@
- +
Die Maske 2 - Die nächste Generation
@@ -354,7 +353,7 @@
- +
Harry Potter und die Heiligtümer des Todes - Teil 1
@@ -367,7 +366,7 @@
- +
Ramstein - Das durchstoßene Herz
@@ -380,7 +379,7 @@
- +
Drachenzähmen leicht gemacht
@@ -447,12 +446,12 @@
- + - + diff --git a/src/source/__fixtures__/MegaKino/https:megakino.clubfilms727-the-lego-movie.html b/src/source/__fixtures__/MegaKino/https:megakino.onefilms727-the-lego-movie.html similarity index 82% rename from src/source/__fixtures__/MegaKino/https:megakino.clubfilms727-the-lego-movie.html rename to src/source/__fixtures__/MegaKino/https:megakino.onefilms727-the-lego-movie.html index 3f0b41f..3a774f3 100644 --- a/src/source/__fixtures__/MegaKino/https:megakino.clubfilms727-the-lego-movie.html +++ b/src/source/__fixtures__/MegaKino/https:megakino.onefilms727-the-lego-movie.html @@ -9,12 +9,12 @@ - - + + - - - + + + @@ -37,16 +37,15 @@ - + - @@ -88,7 +87,7 @@ @@ -97,27 +96,27 @@
@@ -179,14 +178,14 @@
- MEGAKino Filme The Lego Movie + MEGAKino Filme The Lego Movie
- + @@ -204,7 +203,7 @@

The Lego Movie

The Lego Movie
-
Denmark, United States of America, 2014, 100 min
+
Denmark, United States of America, 2014, 100 min
Filme / Animation / Adventure / Comedy / Family / Fantasy
16+
@@ -220,11 +219,11 @@
- +
Batman v Superman: Dawn of Justice
@@ -354,7 +353,7 @@
- +
Drachenzähmen leicht gemacht
@@ -367,7 +366,7 @@
- +
Die Tribute von Panem 3 - Mockingjay Teil 1
@@ -380,7 +379,7 @@
- +
Ramstein - Das durchstoßene Herz
@@ -447,12 +446,12 @@
- + - + diff --git a/src/source/__fixtures__/MegaKino/post-https:megakino.club-dosearchandsubactionsearchandstorytt12345678 b/src/source/__fixtures__/MegaKino/post-https:megakino.one-dosearchandsubactionsearchandstorytt12345678 similarity index 82% rename from src/source/__fixtures__/MegaKino/post-https:megakino.club-dosearchandsubactionsearchandstorytt12345678 rename to src/source/__fixtures__/MegaKino/post-https:megakino.one-dosearchandsubactionsearchandstorytt12345678 index 919c879..950270d 100644 --- a/src/source/__fixtures__/MegaKino/post-https:megakino.club-dosearchandsubactionsearchandstorytt12345678 +++ b/src/source/__fixtures__/MegaKino/post-https:megakino.one-dosearchandsubactionsearchandstorytt12345678 @@ -6,8 +6,8 @@ - - + + @@ -30,16 +30,15 @@ - + - @@ -81,7 +80,7 @@ @@ -90,27 +89,27 @@
@@ -177,7 +176,7 @@ -
+
diff --git a/src/source/__fixtures__/MegaKino/post-https:megakino.club-dosearchandsubactionsearchandstorytt1490017 b/src/source/__fixtures__/MegaKino/post-https:megakino.one-dosearchandsubactionsearchandstorytt1490017 similarity index 82% rename from src/source/__fixtures__/MegaKino/post-https:megakino.club-dosearchandsubactionsearchandstorytt1490017 rename to src/source/__fixtures__/MegaKino/post-https:megakino.one-dosearchandsubactionsearchandstorytt1490017 index 907601f..a87b83b 100644 --- a/src/source/__fixtures__/MegaKino/post-https:megakino.club-dosearchandsubactionsearchandstorytt1490017 +++ b/src/source/__fixtures__/MegaKino/post-https:megakino.one-dosearchandsubactionsearchandstorytt1490017 @@ -6,8 +6,8 @@ - - + + @@ -30,16 +30,15 @@ - + - @@ -81,7 +80,7 @@
Was interessiert Sie?
@@ -90,27 +89,27 @@
@@ -174,7 +173,7 @@ -
+
@@ -236,7 +235,7 @@ function full_submit(prm){ - +
The Lego Movie
HD
diff --git a/src/source/__fixtures__/MegaKino/post-https:megakino.club-dosearchandsubactionsearchandstorytt2245084 b/src/source/__fixtures__/MegaKino/post-https:megakino.one-dosearchandsubactionsearchandstorytt2245084 similarity index 82% rename from src/source/__fixtures__/MegaKino/post-https:megakino.club-dosearchandsubactionsearchandstorytt2245084 rename to src/source/__fixtures__/MegaKino/post-https:megakino.one-dosearchandsubactionsearchandstorytt2245084 index 0370af0..9d44653 100644 --- a/src/source/__fixtures__/MegaKino/post-https:megakino.club-dosearchandsubactionsearchandstorytt2245084 +++ b/src/source/__fixtures__/MegaKino/post-https:megakino.one-dosearchandsubactionsearchandstorytt2245084 @@ -6,8 +6,8 @@ - - + + @@ -30,16 +30,15 @@ - + - @@ -81,7 +80,7 @@
@@ -90,27 +89,27 @@
@@ -174,7 +173,7 @@ -
+
@@ -236,7 +235,7 @@ function full_submit(prm){ - +
Baymax - Riesiges Robowabohu
HD
diff --git a/src/source/__fixtures__/MegaKino/post-https:megakino.club-dosearchandsubactionsearchandstorytt3513498 b/src/source/__fixtures__/MegaKino/post-https:megakino.one-dosearchandsubactionsearchandstorytt3513498 similarity index 82% rename from src/source/__fixtures__/MegaKino/post-https:megakino.club-dosearchandsubactionsearchandstorytt3513498 rename to src/source/__fixtures__/MegaKino/post-https:megakino.one-dosearchandsubactionsearchandstorytt3513498 index 659f85f..4aaa2a0 100644 --- a/src/source/__fixtures__/MegaKino/post-https:megakino.club-dosearchandsubactionsearchandstorytt3513498 +++ b/src/source/__fixtures__/MegaKino/post-https:megakino.one-dosearchandsubactionsearchandstorytt3513498 @@ -6,8 +6,8 @@ - - + + @@ -30,16 +30,15 @@ - + - @@ -81,7 +80,7 @@
@@ -90,27 +89,27 @@
@@ -174,7 +173,7 @@ -
+
@@ -236,7 +235,7 @@ function full_submit(prm){ - +
The LEGO Movie 2
HD
diff --git a/src/source/__snapshots__/MegaKino.test.ts.snap b/src/source/__snapshots__/MegaKino.test.ts.snap index 5fdc3b2..da57d1c 100644 --- a/src/source/__snapshots__/MegaKino.test.ts.snap +++ b/src/source/__snapshots__/MegaKino.test.ts.snap @@ -7,7 +7,7 @@ exports[`MegaKino handle imdb baymax 1`] = ` "countryCodes": [ "de", ], - "referer": "https://megakino.club/films/693-baymax-riesiges-robowabohu.html", + "referer": "https://megakino.one/films/693-baymax-riesiges-robowabohu.html", "title": "Baymax - Riesiges Robowabohu", }, "url": "https://voe.sx/e/8doq7gwiwtig", @@ -17,7 +17,7 @@ exports[`MegaKino handle imdb baymax 1`] = ` "countryCodes": [ "de", ], - "referer": "https://megakino.club/films/693-baymax-riesiges-robowabohu.html", + "referer": "https://megakino.one/films/693-baymax-riesiges-robowabohu.html", "title": "Baymax - Riesiges Robowabohu", }, "url": "https://watch.gxplayer.xyz/watch?v=MEKI92PU", @@ -32,7 +32,7 @@ exports[`MegaKino lego movie 2 2019 1`] = ` "countryCodes": [ "de", ], - "referer": "https://megakino.club/adventure/4804-the-lego-movie-2.html", + "referer": "https://megakino.one/adventure/4804-the-lego-movie-2.html", "title": "The LEGO Movie 2", }, "url": "https://voe.sx/e/gkd0hqdinrex", @@ -47,17 +47,17 @@ exports[`MegaKino lego movie 2014 1`] = ` "countryCodes": [ "de", ], - "referer": "https://megakino.club/films/727-the-lego-movie.html", + "referer": "https://megakino.one/films/727-the-lego-movie.html", "title": "The Lego Movie", }, - "url": "https://voe.sx/e/mjh2ti2qolpb", + "url": "https://voe.sx/e/vgklostzmeje", }, { "meta": { "countryCodes": [ "de", ], - "referer": "https://megakino.club/films/727-the-lego-movie.html", + "referer": "https://megakino.one/films/727-the-lego-movie.html", "title": "The Lego Movie", }, "url": "https://watch.gxplayer.xyz/watch?v=XE0LK8H7", diff --git a/src/utils/Fetcher.ts b/src/utils/Fetcher.ts index 0079ab0..0ddce63 100644 --- a/src/utils/Fetcher.ts +++ b/src/utils/Fetcher.ts @@ -92,6 +92,17 @@ export class Fetcher { return (await this.queuedFetch(ctx, url, { ...requestConfig, method: 'HEAD' })).headers; }; + public async getFinalRedirectUrl(ctx: Context, url: URL, requestConfig?: CustomRequestConfig): Promise { + const newRequestConfig = { ...requestConfig, method: 'HEAD', maxRedirects: 0 }; + + const response = await this.queuedFetch(ctx, url, newRequestConfig); + if (response.status >= 300 && response.status < 400) { + return await this.getFinalRedirectUrl(ctx, new URL(response.headers['location']), newRequestConfig); + } + + return url; + } + // eslint-disable-next-line @typescript-eslint/no-explicit-any public async json(ctx: Context, url: URL, requestConfig?: CustomRequestConfig): Promise { const jsonRequestConfig = { @@ -300,16 +311,16 @@ export class Fetcher { return sem; } - private async queuedFetch(ctx: Context, url: URL, init?: CustomRequestConfig): Promise { - const queueLimit = init?.queueLimit ?? this.DEFAULT_QUEUE_LIMIT; - const queueTimeout = init?.queueTimeout ?? this.DEFAULT_QUEUE_TIMEOUT; + private async queuedFetch(ctx: Context, url: URL, requestConfig?: CustomRequestConfig): Promise { + const queueLimit = requestConfig?.queueLimit ?? this.DEFAULT_QUEUE_LIMIT; + const queueTimeout = requestConfig?.queueTimeout ?? this.DEFAULT_QUEUE_TIMEOUT; const semaphore = this.getSemaphore(url, queueLimit, queueTimeout); const [,release] = await semaphore.acquire(); try { - return await this.fetchWithTimeout(ctx, url, init); + return await this.fetchWithTimeout(ctx, url, requestConfig); } finally { release(); }