fix: regex validate tiktok url
This commit is contained in:
parent
1b4d55be6a
commit
f00fa49394
37
README.md
37
README.md
@ -19,6 +19,7 @@
|
||||
|
||||
- [Description](#description)
|
||||
- [How to get Tiktok Cookie](#how-to-get-tiktok-cookie)
|
||||
- [Build this project](#build-this-project)
|
||||
- [Install](#install)
|
||||
- [From NPM](#from-npm)
|
||||
- [From Yarn](#from-yarn)
|
||||
@ -41,12 +42,32 @@ This project uses the Unofficial API from Tiktok.
|
||||
|
||||
# How to get Tiktok Cookie
|
||||
|
||||
(If the Default Cookie Has Expired)
|
||||
You can use cookies in the form of String or JSON
|
||||
|
||||
- Login at [Tiktok](https://www.tiktok.com/)
|
||||
- When you have finished logging in, you can press CTRL + SHIFT + I or Right Click and select Inspect
|
||||
- Go to the Console section then type <b>document.cookie<b>
|
||||
- Then Copy Paste your Cookie and Use it for TiktokStalk
|
||||
- Method 1 (String) :
|
||||
|
||||
Login to the [Tiktok website](https://tiktok/.com) -> Open the **Inspect Element** or you can press the shortcut **CTRL + SHIFT + I** -> Go to network -> Find the request that goes to tiktok then open the request and look for **Cookie**
|
||||
|
||||

|
||||
|
||||
- Method 2 (JSON) :
|
||||
|
||||
You can use the chrome extension [EditThisCookies](https://chromewebstore.google.com/detail/editthiscookie/fngmhnnpilhplaeedifhccceomclgfbg) -> Login to the [Tiktok website](https://tiktok/.com) -> Then open the **EditThisCookie** extension -> Then click **Export Cookie**
|
||||
|
||||

|
||||
|
||||
# Build this project
|
||||
|
||||
- Clone the repository
|
||||
- Install the dependencies
|
||||
- Run the build script
|
||||
|
||||
```bash
|
||||
git clone https://github.com/TobyG74/tiktok-api-dl.git
|
||||
cd tiktok-api-dl
|
||||
npm install
|
||||
npm run build
|
||||
```
|
||||
|
||||
# Install
|
||||
|
||||
@ -79,7 +100,7 @@ npm install github:TobyG74/tiktok-api-dl
|
||||
- V3 uses the API from [MusicalDown](https://musicaldown.com/)
|
||||
|
||||
```js
|
||||
const { default: Tiktok } = require("@tobyg74/tiktok-api-dl")
|
||||
const Tiktok = require("@tobyg74/tiktok-api-dl")
|
||||
|
||||
const tiktok_url = "https://vt.tiktok.com/ZS84BnrU9"
|
||||
|
||||
@ -97,7 +118,7 @@ Tiktok.Downloader(tiktok_url, {
|
||||
- Using Your Cookie
|
||||
|
||||
```js
|
||||
const { default: Tiktok } = require("@tobyg74/tiktok-api-dl")
|
||||
const Tiktok = require("@tobyg74/tiktok-api-dl")
|
||||
|
||||
const username = "tobz2k19"
|
||||
|
||||
@ -115,7 +136,7 @@ Tiktok.Search(username, {
|
||||
- Using Your Cookie
|
||||
|
||||
```js
|
||||
const { default: Tiktok } = require("@tobyg74/tiktok-api-dl")
|
||||
const Tiktok = require("@tobyg74/tiktok-api-dl")
|
||||
|
||||
const username = "tobz2k19"
|
||||
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@tobyg74/tiktok-api-dl",
|
||||
"version": "1.1.1",
|
||||
"version": "1.1.2",
|
||||
"description": "Scraper for downloading media in the form of videos, images and audio from Tiktok. Also for stalking Tiktok Users",
|
||||
"main": "lib/index.js",
|
||||
"types": "lib/index.d.ts",
|
||||
|
||||
@ -17,7 +17,7 @@ import { StalkResult } from "./types/search/stalker"
|
||||
type TiktokDownloaderResponse<T extends "v1" | "v2" | "v3"> = T extends "v1" ? TiktokAPIResponse : T extends "v2" ? SSSTikResponse : T extends "v3" ? MusicalDownResponse : TiktokAPIResponse
|
||||
type TiktokSearchResponse<T extends "user" | "video"> = T extends "user" ? TiktokUserSearchResponse : T extends "video" ? any : TiktokUserSearchResponse
|
||||
|
||||
export const Tiktok = {
|
||||
export = {
|
||||
Downloader: async <T extends "v1" | "v2" | "v3">(url: string, options?: { version: T }): Promise<TiktokDownloaderResponse<T>> => {
|
||||
switch (options?.version) {
|
||||
case "v1": {
|
||||
@ -59,5 +59,3 @@ export const Tiktok = {
|
||||
return response
|
||||
}
|
||||
}
|
||||
|
||||
export default Tiktok
|
||||
|
||||
@ -8,7 +8,7 @@ import { _musicaldownapi, _musicaldownmusicapi, _musicaldownurl } from "../../co
|
||||
* BASE URL : https://ssstik.io
|
||||
*/
|
||||
|
||||
const TiktokURLregex = /(?:http[s]?:\/\/)?(?:www\.|m\.)?(?:tiktok\.com\/(?:@[\w.-]+\/video\/|@[\w.-]+\/video\/))?(\d+)/
|
||||
const TiktokURLregex = /https:\/\/(?:m|www|vm|vt)?\.?tiktok\.com\/((?:.*\b(?:(?:usr|v|embed|user|video)\/|\?shareId=|\&item_id=)(\d+))|\w+)/
|
||||
|
||||
const getRequest = (url: string) =>
|
||||
new Promise<getRequest>((resolve, reject) => {
|
||||
|
||||
@ -8,7 +8,7 @@ import { _ssstikapi, _ssstikurl } from "../../constants/api"
|
||||
* BASE URL : https://ssstik.io
|
||||
*/
|
||||
|
||||
const TiktokURLregex = /(?:http[s]?:\/\/)?(?:www\.|m\.)?(?:tiktok\.com\/(?:@[\w.-]+\/video\/|@[\w.-]+\/video\/))?(\d+)/
|
||||
const TiktokURLregex = /https:\/\/(?:m|www|vm|vt)?\.?tiktok\.com\/((?:.*\b(?:(?:usr|v|embed|user|video)\/|\?shareId=|\&item_id=)(\d+))|\w+)/
|
||||
|
||||
const fetchTT = () =>
|
||||
new Promise<SSSTikFetchTT>(async (resolve, reject) => {
|
||||
|
||||
@ -3,7 +3,7 @@ import { _tiktokapi, _tiktokurl } from "../../constants/api"
|
||||
import { _tiktokApiParams } from "../../constants/params"
|
||||
import { Author, TiktokAPIResponse, Statistics, Music, responseParser, Video } from "../../types/downloader/tiktokApi"
|
||||
|
||||
const TiktokURLregex = /(?:http[s]?:\/\/)?(?:www\.|m\.)?(?:tiktok\.com\/(?:@[\w.-]+\/video\/|@[\w.-]+\/video\/))?(\d+)/
|
||||
const TiktokURLregex = /https:\/\/(?:m|www|vm|vt)?\.?tiktok\.com\/((?:.*\b(?:(?:usr|v|embed|user|video)\/|\?shareId=|\&item_id=)(\d+))|\w+)/
|
||||
|
||||
/**
|
||||
* Tiktok API Downloader
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user