Skip to content

Commit

Permalink
Fetch more sites config from IMDB Scout script
Browse files Browse the repository at this point in the history
  • Loading branch information
Morea committed Aug 25, 2024
1 parent 7774e21 commit d91a26e
Show file tree
Hide file tree
Showing 2 changed files with 1,651 additions and 827 deletions.
17 changes: 15 additions & 2 deletions common/scripts/PrivateSitesGenerator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@ let code: string = await new Promise((resolve, reject) => {
const ast = esprima.parseScript(code, { tolerant: true });

let privateSitesConfig: PrivateSiteConfig[] = [];
const sites = [
"private_sites",
"chinese_sites",
"french_sites",
"german_sites",
];

estraverse.traverse(ast, {
enter: function (node) {
Expand All @@ -36,10 +42,10 @@ estraverse.traverse(ast, {
continue;
}
if (
declaration.id.name === "private_sites" &&
sites.includes(declaration.id.name) &&
declaration.init.type === "ArrayExpression"
) {
privateSitesConfig = declaration.init.elements.map((element: any) => {
const sitesConfig = declaration.init.elements.map((element: any) => {
if (element.type === "Literal") {
return element.value;
} else if (element.type === "ObjectExpression") {
Expand All @@ -64,6 +70,7 @@ estraverse.traverse(ast, {
return obj;
}
});
privateSitesConfig = privateSitesConfig.concat(sitesConfig);
return;
}
}
Expand All @@ -83,6 +90,12 @@ if (privateSitesConfig) {
[key: string]: boolean | string | RegExp | undefined | number;
};\n\n`;

privateSitesConfig.sort((a, b) => {
if (a.name < b.name) return -1;
if (a.name > b.name) return 1;
return 0;
});

for (const item of privateSitesConfig) {
const itemName = item.name;
let itemProps = "";
Expand Down
Loading

0 comments on commit d91a26e

Please sign in to comment.