mirror of
https://github.com/hansputera/tiktok-dl.git
synced 2026-04-05 19:51:57 +02:00
feat(*): add husky and prettier
This commit is contained in:
@@ -4,7 +4,8 @@
|
||||
"node": true
|
||||
},
|
||||
"extends": [
|
||||
"google"
|
||||
"google",
|
||||
"prettier"
|
||||
],
|
||||
"parser": "@typescript-eslint/parser",
|
||||
"parserOptions": {
|
||||
|
||||
4
.husky/pre-commit
Executable file
4
.husky/pre-commit
Executable file
@@ -0,0 +1,4 @@
|
||||
#!/bin/sh
|
||||
. "$(dirname "$0")/_/husky.sh"
|
||||
|
||||
yarn lint
|
||||
3
.prettierignore
Normal file
3
.prettierignore
Normal file
@@ -0,0 +1,3 @@
|
||||
# Ignore artifacts:
|
||||
build
|
||||
coverage
|
||||
1
.prettierrc.json
Normal file
1
.prettierrc.json
Normal file
@@ -0,0 +1 @@
|
||||
{}
|
||||
@@ -1,6 +1,9 @@
|
||||
import {getFetch} from '..';
|
||||
import {handleException} from '../decorators';
|
||||
import {BaseProvider, ExtractedInfo} from './baseProvider';
|
||||
import {deObfuscateSaveFromScript} from './util';
|
||||
|
||||
import Prettier from 'prettier';
|
||||
|
||||
/**
|
||||
* @class saveFromProvider
|
||||
@@ -50,7 +53,8 @@ export class SaveFromProvider extends BaseProvider {
|
||||
*/
|
||||
@handleException
|
||||
extract(html: string): ExtractedInfo {
|
||||
console.log(html);
|
||||
console.log(Prettier.format(
|
||||
deObfuscateSaveFromScript(html)));
|
||||
return {
|
||||
'error': undefined,
|
||||
};
|
||||
|
||||
@@ -40,14 +40,12 @@ export const matchTikmateDownload = (raw: string): string[] => {
|
||||
|
||||
export const deObfuscateSaveFromScript = (scriptContent: string): string => {
|
||||
const safeScript = 'let result;' +
|
||||
scriptContent.replace(/eval\(a\)/gi, 'return a')
|
||||
.replace('[]["filter"]["constructor"](b).call(a);', `
|
||||
if (b.includes("showResult")) {
|
||||
result = b;
|
||||
return;
|
||||
} else []["filter"]["constructor"](b).call(a);
|
||||
`) + 'result';
|
||||
scriptContent.replace(/\/\*js\-response\*\//gi, '')
|
||||
.replace(/eval\(a\)/gi, 'return a')
|
||||
// eslint-disable-next-line max-len
|
||||
.replace('[]["filter"]["constructor"](b).call(a);', `console.log(b);if (b.includes("showResult")){result = b;return;} else []["filter"]["constructor"](b).call(a);`) + 'result';
|
||||
|
||||
console.log(safeScript);
|
||||
const result = eval(safeScript);
|
||||
return result;
|
||||
};
|
||||
|
||||
@@ -9,6 +9,7 @@ export const rotateProvider = async (
|
||||
provider: BaseProvider, url: string,
|
||||
noCache: boolean = false):
|
||||
Promise<ExtractedInfo & { provider: string; }> => {
|
||||
console.log(provider.resourceName());
|
||||
const cachedData = await redisClient.get(url);
|
||||
if (!cachedData) {
|
||||
const data = await provider.fetch(url);
|
||||
|
||||
@@ -10,15 +10,20 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/ioredis": "^4.28.1",
|
||||
"@types/prettier": "^2.4.1",
|
||||
"@typescript-eslint/eslint-plugin": "^5.3.0",
|
||||
"@typescript-eslint/parser": "^5.3.0",
|
||||
"@vercel/node": "^1.12.1",
|
||||
"eslint": "^8.2.0",
|
||||
"eslint-config-google": "^0.14.0",
|
||||
"eslint-config-prettier": "^8.3.0",
|
||||
"husky": "^7.0.4",
|
||||
"prettier": "^2.4.1",
|
||||
"typescript": "^4.4.4"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "echo build",
|
||||
"lint": "eslint \"./middleware/**/*.ts\" \"./lib/**/*.ts\" \"./types/*.ts\" \"./api/**/*.ts\" --fix"
|
||||
"lint": "eslint \"./middleware/**/*.ts\" \"./lib/**/*.ts\" \"./types/*.ts\" \"./api/**/*.ts\" --fix",
|
||||
"prepare": "husky install"
|
||||
}
|
||||
}
|
||||
|
||||
20
yarn.lock
20
yarn.lock
@@ -103,6 +103,11 @@
|
||||
resolved "https://registry.npmjs.org/@types/node/-/node-16.11.6.tgz"
|
||||
integrity sha512-ua7PgUoeQFjmWPcoo9khiPum3Pd60k4/2ZGXt18sm2Slk0W0xZTqt5Y0Ny1NyBiN1EVQ/+FaF9NcY4Qe6rwk5w==
|
||||
|
||||
"@types/prettier@^2.4.1":
|
||||
version "2.4.1"
|
||||
resolved "https://registry.yarnpkg.com/@types/prettier/-/prettier-2.4.1.tgz#e1303048d5389563e130f5bdd89d37a99acb75eb"
|
||||
integrity sha512-Fo79ojj3vdEZOHg3wR9ksAMRz4P3S5fDB5e/YWZiFnyFQI1WY2Vftu9XoXVVtJfxB7Bpce/QTqWSSntkz2Znrw==
|
||||
|
||||
"@types/responselike@*", "@types/responselike@^1.0.0":
|
||||
version "1.0.0"
|
||||
resolved "https://registry.npmjs.org/@types/responselike/-/responselike-1.0.0.tgz"
|
||||
@@ -414,6 +419,11 @@ eslint-config-google@^0.14.0:
|
||||
resolved "https://registry.npmjs.org/eslint-config-google/-/eslint-config-google-0.14.0.tgz"
|
||||
integrity sha512-WsbX4WbjuMvTdeVL6+J3rK1RGhCTqjsFjX7UMSMgZiyxxaNLkoJENbrGExzERFeoTpGw3F3FypTiWAP9ZXzkEw==
|
||||
|
||||
eslint-config-prettier@^8.3.0:
|
||||
version "8.3.0"
|
||||
resolved "https://registry.yarnpkg.com/eslint-config-prettier/-/eslint-config-prettier-8.3.0.tgz#f7471b20b6fe8a9a9254cc684454202886a2dd7a"
|
||||
integrity sha512-BgZuLUSeKzvlL/VUjx/Yb787VQ26RU3gGjA3iiFvdsp/2bMfVIWUVP7tjxtjS0e+HP409cPlPvNkQloz8C91ew==
|
||||
|
||||
eslint-scope@^5.1.1:
|
||||
version "5.1.1"
|
||||
resolved "https://registry.npmjs.org/eslint-scope/-/eslint-scope-5.1.1.tgz"
|
||||
@@ -686,6 +696,11 @@ http2-wrapper@^1.0.0-beta.5.2:
|
||||
quick-lru "^5.1.1"
|
||||
resolve-alpn "^1.0.0"
|
||||
|
||||
husky@^7.0.4:
|
||||
version "7.0.4"
|
||||
resolved "https://registry.yarnpkg.com/husky/-/husky-7.0.4.tgz#242048245dc49c8fb1bf0cc7cfb98dd722531535"
|
||||
integrity sha512-vbaCKN2QLtP/vD4yvs6iz6hBEo6wkSzs8HpRah1Z6aGmF2KW5PdYuAd7uX5a+OyBZHBhd+TFLqgjUgytQr4RvQ==
|
||||
|
||||
ignore@^4.0.6:
|
||||
version "4.0.6"
|
||||
resolved "https://registry.npmjs.org/ignore/-/ignore-4.0.6.tgz"
|
||||
@@ -963,6 +978,11 @@ prelude-ls@^1.2.1:
|
||||
resolved "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.2.1.tgz"
|
||||
integrity sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g==
|
||||
|
||||
prettier@^2.4.1:
|
||||
version "2.4.1"
|
||||
resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.4.1.tgz#671e11c89c14a4cfc876ce564106c4a6726c9f5c"
|
||||
integrity sha512-9fbDAXSBcc6Bs1mZrDYb3XKzDLm4EXXL9sC1LqKP5rZkT6KRr/rf9amVUcODVXgguK/isJz0d0hP72WeaKWsvA==
|
||||
|
||||
progress@^2.0.0:
|
||||
version "2.0.3"
|
||||
resolved "https://registry.npmjs.org/progress/-/progress-2.0.3.tgz"
|
||||
|
||||
Reference in New Issue
Block a user