Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const got = require('got');
- const querystring = require('querystring');
- const ANIME_NAME = 'A Certain Magical Index'; // This is case-sensitive and must be exact
- const ANIME_EPISODE = 2;
- const ENCRYPTION_KEY = 'ysdgetcfc'; // Seems to be static? It works for all the series I've tried
- const QUERY = querystring.stringify({
- a: ANIME_NAME,
- e: ANIME_EPISODE
- });
- const STREAM_1_REGEX = /var soienfu="(.*)";/;
- const STREAM_2_REGEX = /var iusfdb="(.*)";/;
- const STREAM_3_REGEX = /var ufbjhse="(.*)";/;
- // https://stackoverflow.com/a/4209150
- String.prototype.decodeEscapeSequence = function() {
- return this.replace(/\\x([0-9A-Fa-f]{2})/g, function() {
- return String.fromCharCode(parseInt(arguments[1], 16));
- });
- };
- (async () => {
- const streams = {};
- console.log(`Searching for streams for ${ANIME_NAME}, episode ${ANIME_EPISODE}...`);
- const response = await got(`http://animeheaven.eu/watch.php?${QUERY}`);
- const body = response.body;
- let STREAM_REGEX_DATA = STREAM_1_REGEX.exec(body);
- if (STREAM_REGEX_DATA) {
- let encoded = STREAM_REGEX_DATA[1].decodeEscapeSequence();
- encoded = encoded.replace(/\|/g, "0");
- const encrypted = base64Decode(encoded);
- streams.stream_1 = decrypt(ENCRYPTION_KEY, encrypted);
- }
- STREAM_REGEX_DATA = STREAM_2_REGEX.exec(body);
- if (STREAM_REGEX_DATA) {
- let encoded = STREAM_REGEX_DATA[1].decodeEscapeSequence();
- encoded = encoded.replace(/\|/g, "0");
- const encrypted = base64Decode(encoded);
- streams.stream_2 = decrypt(ENCRYPTION_KEY, encrypted);
- }
- STREAM_REGEX_DATA = STREAM_3_REGEX.exec(body);
- if (STREAM_REGEX_DATA) {
- let encoded = STREAM_REGEX_DATA[1].decodeEscapeSequence();
- encoded = encoded.replace(/\|/g, "0");
- const encrypted = base64Decode(encoded);
- streams.stream_3 = decrypt(ENCRYPTION_KEY, encrypted);
- }
- console.log(streams);
- })();
- function base64Decode(base64) {
- return Buffer.from(base64, 'base64').toString('binary');
- }
- function decrypt(key, crypted) {
- const unknown_3 = [];
- let j = 0;
- let unknown_1;
- let unknown_2 = '';
- for (let i = 0; i < 256; i++) {
- unknown_3[i] = i;
- }
- for (i = 0; i < 256; i++) {
- j = (j + unknown_3[i] + key.charCodeAt(i % key.length)) % 256;
- unknown_1 = unknown_3[i];
- unknown_3[i] = unknown_3[j];
- unknown_3[j] = unknown_1;
- }
- i = 0;
- j = 0;
- for (let k = 0; k < crypted.length; k++) {
- i = (i + 1) % 256;
- j = (j + unknown_3[i]) % 256;
- unknown_1 = unknown_3[i];
- unknown_3[i] = unknown_3[j];
- unknown_3[j] = unknown_1;
- unknown_2 += String.fromCharCode(crypted.charCodeAt(k) ^ unknown_3[(unknown_3[i] + unknown_3[j]) % 256]);
- }
- return unknown_2;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement