Skip to content

Commit

Permalink
Fixed decodeVideoSkipData for aniwave (v0.7.3)
Browse files Browse the repository at this point in the history
  • Loading branch information
Nixuge committed Aug 16, 2024
1 parent 4dbb5f1 commit 68e350c
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 37 deletions.
2 changes: 1 addition & 1 deletion src/aniwave/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export default class Source extends SourceModule implements VideoContent {
metadata = {
id: 'aniwave',
name: 'Aniwave',
version: '0.7.2',
version: '0.7.3',
icon: "https://aniwave.to/assets/s/e8c93166fd4dcf9ab41d5178518295fc1b5fcb27fd90df1c268eb0.png"
}

Expand Down
1 change: 0 additions & 1 deletion src/aniwave/utils/skipData.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { PlaylistEpisodeServerSkipTime, PlaylistEpisodeServerSkipType } from "@mochiapp/js/dist";

export function parseSkipData(data: string): PlaylistEpisodeServerSkipTime[] {
return []; // Temp - broken for now
if (data) {
const parsedData = JSON.parse(data);
return [
Expand Down
62 changes: 27 additions & 35 deletions src/aniwave/utils/urlGrabber.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,20 @@
import { rc4Cypher } from "../../shared/utils/aniwave/rc4";
import { substituteString } from "../../shared/utils/aniwave/substituteString";
import { b64encode } from "../../shared/utils/b64";
import { b64decode, b64encode } from "../../shared/utils/b64";

function serializeText(t: string) {
return "".concat(b64encode(t)).replace(/\//g, "_").replace(/\+/g, "-");
}

export function getVrf(input: string) {
const reverse = (str: string) => str.split("").reverse().join("");
function deserializeText(t: string) {
return b64decode(t.replace(/_/g, '/').replace(/-/g, '+'));
}

function reverse(t: string) {
return t.split("").reverse().join("");
}

export function getVrf(input: string) {
// required - transform to string
input = '' + input;

Expand All @@ -32,38 +38,24 @@ export function getVrf(input: string) {
}


function b64decode(t: string) {
if ((t = (t = (t = "".concat(t)).replace(/[\t\n\f\r]/g, "")).length % 4 == 0 ? t.replace(/==?$/, "") : t).length % 4 == 1 || /[^+/0-9A-Za-z]/.test(t)) {
return null!;
}
var r;
var s = "";
var o = 0;
var u = 0;
for (var h = 0; h < t.length; h++) {
r = t[h];
// @ts-ignore
o = (o <<= 6) | ((r = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".indexOf(r)) < 0 ? undefined : r);
if (24 === (u += 6)) {
s = (s = (s += String.fromCharCode((16711680 & o) >> 16)) + String.fromCharCode((65280 & o) >> 8)) + String.fromCharCode(255 & o);
o = u = 0;
}
}
if (12 === u) {
o >>= 4;
s += String.fromCharCode(o);
} else if (18 === u) {
o >>= 2;
s = (s += String.fromCharCode((65280 & o) >> 8)) + String.fromCharCode(255 & o);
}
return s;
};
export function decodeVideoSkipData(input: string) {
input = '' + input;

input = deserializeText(input);

input = rc4Cypher("736y1uTJpBLUX", deserializeText(input));
input = reverse(input);
input = substituteString(input, "0jHA9CPYu3v", "CPYvHj09Au3");

input = substituteString(input, "da1l2jSmP5QM", "1majSlPQd2M5");
input = deserializeText(input);
input = rc4Cypher("fOyt97QWFB3", input)
input = reverse(input);

input = reverse(input)
input = deserializeText(input);
input = rc4Cypher("ItFKjuWokn4ZpB", input)
input = substituteString(input, "UAz8Gwl10P6ReH", "AP6GeR8H0lwUz1");

export function decodeVideoSkipData(encoded_url: string) {
encoded_url = b64decode("".concat(encoded_url).replace(/_/g, "/").replace(/-/g, "+"));
const decoded_url = decodeURIComponent(rc4Cypher("ctpAbOz5u7S6OMkx", encoded_url));
return (decoded_url);
return input;
}
// clearer name
// export function getVrf(input: string) { return encodeURIComponent(idToVrf(input)) };

0 comments on commit 68e350c

Please sign in to comment.