mirror of
https://github.com/hansputera/tiktok-dl.git
synced 2026-04-05 19:51:57 +02:00
chore: update turbo, and husky. And, using ESM
Signed-off-by: GitHub <noreply@github.com>
This commit is contained in:
committed by
GitHub
parent
bce4d2f36d
commit
a3a0c2a95c
@@ -24,7 +24,7 @@ export const ratelimitMiddleware = async (
|
||||
client.incr('rate-' + ip);
|
||||
return true;
|
||||
} else {
|
||||
client.set('rate-' + ip, '1', 'ex', rateLimitConfig.ratelimitTime);
|
||||
client.set('rate-' + ip, '1', 'EX', rateLimitConfig.ratelimitTime);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
@@ -8,6 +8,7 @@ const {parsed: cusEnv} = require('dotenv').config({
|
||||
|
||||
module.exports = withTM({
|
||||
reactStrictMode: true,
|
||||
experimental: { esmExternals: true },
|
||||
webpack(config) {
|
||||
// adding windicss plugin
|
||||
config.plugins.push(new WindiCSSWebpackPlugin());
|
||||
|
||||
@@ -7,8 +7,8 @@
|
||||
"strictFunctionTypes": true,
|
||||
"strictNullChecks": true,
|
||||
"outDir": "dist",
|
||||
"target": "ES2016",
|
||||
"module": "CommonJS",
|
||||
"target": "ESNext",
|
||||
"module": "ESNext",
|
||||
"removeComments": true,
|
||||
"esModuleInterop": true,
|
||||
"skipLibCheck": true,
|
||||
|
||||
@@ -5,8 +5,8 @@
|
||||
"private": true,
|
||||
"license": "MIT",
|
||||
"devDependencies": {
|
||||
"husky": "^7.0.4",
|
||||
"turbo": "^1.1.2"
|
||||
"husky": "^8.0.1",
|
||||
"turbo": "^1.2.11"
|
||||
},
|
||||
"workspaces": [
|
||||
"packages/*",
|
||||
@@ -22,5 +22,6 @@
|
||||
"packageManager": "yarn@3.2.1",
|
||||
"engines": {
|
||||
"node": ">=14.x"
|
||||
}
|
||||
},
|
||||
"type": "module"
|
||||
}
|
||||
|
||||
@@ -10,7 +10,6 @@ import {TikDownProvider} from './tikDownProvider';
|
||||
import {DownTikProvider} from './downTikProvider';
|
||||
import {LoveTikProvider} from './loveTikProvider';
|
||||
import {DDDTikProvider} from './dddTikProvider';
|
||||
import {TokupProvider} from './tokupProvider';
|
||||
import {DownloadOne} from './downloaderOneProvider';
|
||||
import {NativeProvider} from './nativeProvider';
|
||||
import {GetVidTikProvider} from './getVidTikProvider';
|
||||
@@ -26,7 +25,6 @@ export const Providers: BaseProvider[] = [
|
||||
new DownTikProvider(), // SaveTik Mirror
|
||||
new LoveTikProvider(),
|
||||
new DDDTikProvider(),
|
||||
new TokupProvider(), // ttsave alternative
|
||||
new DownloadOne(),
|
||||
new NativeProvider(),
|
||||
new GetVidTikProvider(),
|
||||
|
||||
@@ -1,100 +0,0 @@
|
||||
import {BaseProvider, ExtractedInfo} from './base';
|
||||
import {getFetch} from '../fetch';
|
||||
import type {Shape} from 'ow';
|
||||
|
||||
/**
|
||||
* @class TokupProvider
|
||||
*/
|
||||
export class TokupProvider extends BaseProvider {
|
||||
/**
|
||||
* Get provider name
|
||||
* @return {string}
|
||||
*/
|
||||
public resourceName(): string {
|
||||
return 'tokup';
|
||||
}
|
||||
|
||||
public client = getFetch('https://tokup.app');
|
||||
|
||||
public maintenance = {
|
||||
reason: "Tokup site returned 'Oops! Something went wrong!'",
|
||||
};
|
||||
|
||||
/**
|
||||
* Fetch tokup
|
||||
* @param {string} url - TikTok Video URL
|
||||
* @return {Promise<ExtractedInfo>}
|
||||
*/
|
||||
public async fetch(url: string): Promise<ExtractedInfo> {
|
||||
const response = await this.client.post('./', {
|
||||
form: {
|
||||
url: url,
|
||||
},
|
||||
headers: {
|
||||
Origin: this.client.defaults.options.prefixUrl,
|
||||
Referer: this.client.defaults.options.prefixUrl,
|
||||
},
|
||||
timeout: 3000,
|
||||
});
|
||||
|
||||
if (
|
||||
response.statusCode !== 200 ||
|
||||
/video not found\b/gi.test(response.body)
|
||||
) {
|
||||
return {
|
||||
error: 'Video Not Found',
|
||||
};
|
||||
} else if (/oops/gi.test(response.body)) {
|
||||
return {
|
||||
error: 'Tokup Error',
|
||||
};
|
||||
} else {
|
||||
return this.extract(response.body);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Extract tokup html elements
|
||||
* @param {string} html
|
||||
* @return {ExtractedInfo}
|
||||
*/
|
||||
extract(html: string): ExtractedInfo {
|
||||
console.log(html);
|
||||
const authorProfile = (
|
||||
/http(s)?(:\/\/(.*)\.tiktokcdn\.com\/(.*))/gi.exec(html) as string[]
|
||||
)[0];
|
||||
const nums = (html.match(/<td>[0-9]+<\/td>/g) as string[]).map((n) =>
|
||||
n.replace(/<(\/)?[a-zA-Z0-9]+>/gi, ''),
|
||||
);
|
||||
const url = [
|
||||
...new Set(
|
||||
html.match(
|
||||
// eslint-disable-next-line max-len
|
||||
/http(s)?(:\/\/tikmate\.app\/download\/[A-Za-z0-9\-\_]+\/[0-9]+\.mp4+)/gi,
|
||||
) as string[],
|
||||
),
|
||||
][0];
|
||||
|
||||
return {
|
||||
video: {
|
||||
urls: [url, url + '?hd=1'],
|
||||
},
|
||||
author: {
|
||||
username: (/target="_blank"\>(.*)\</.exec(html) as string[])[1],
|
||||
thumb: authorProfile.substring(0, authorProfile.length - 1),
|
||||
},
|
||||
uploadedAt: (html.match(/<p>(.+)<\/p>/) as string[])[1],
|
||||
likesCount: nums[0] as unknown as number,
|
||||
commentsCount: nums[1] as unknown as number,
|
||||
sharesCount: nums[2] as unknown as number,
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Get ow.Shape params.
|
||||
* @return {Shape | undefined}
|
||||
*/
|
||||
public getParams(): Shape | undefined {
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
@@ -7,8 +7,8 @@
|
||||
"strictFunctionTypes": true,
|
||||
"strictNullChecks": true,
|
||||
"outDir": "dist",
|
||||
"target": "ES2016",
|
||||
"module": "CommonJS",
|
||||
"target": "ESNext",
|
||||
"module": "ESNext",
|
||||
"removeComments": true,
|
||||
"esModuleInterop": true,
|
||||
"skipLibCheck": true,
|
||||
|
||||
14
yarn.lock
14
yarn.lock
@@ -1157,12 +1157,12 @@ __metadata:
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"husky@npm:^7.0.4":
|
||||
version: 7.0.4
|
||||
resolution: "husky@npm:7.0.4"
|
||||
"husky@npm:^8.0.1":
|
||||
version: 8.0.1
|
||||
resolution: "husky@npm:8.0.1"
|
||||
bin:
|
||||
husky: lib/bin.js
|
||||
checksum: c6ec4af63da2c9522da8674a20ad9b48362cc92704896cc8a58c6a2a39d797feb2b806f93fbd83a6d653fbdceb2c3b6e0b602c6b2e8565206ffc2882ef7db9e9
|
||||
checksum: 943a73a13d0201318fd30e83d299bb81d866bd245b69e6277804c3b462638dc1921694cb94c2b8c920a4a187060f7d6058d3365152865406352e934c5fff70dc
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
@@ -1992,8 +1992,8 @@ __metadata:
|
||||
version: 0.0.0-use.local
|
||||
resolution: "tktk@workspace:."
|
||||
dependencies:
|
||||
husky: ^7.0.4
|
||||
turbo: ^1.1.2
|
||||
husky: ^8.0.1
|
||||
turbo: ^1.2.11
|
||||
languageName: unknown
|
||||
linkType: soft
|
||||
|
||||
@@ -2115,7 +2115,7 @@ __metadata:
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"turbo@npm:^1.1.2":
|
||||
"turbo@npm:^1.2.11":
|
||||
version: 1.2.11
|
||||
resolution: "turbo@npm:1.2.11"
|
||||
dependencies:
|
||||
|
||||
Reference in New Issue
Block a user