├── LICENSE ├── README.md ├── esm └── index.mjs ├── examples ├── discord.js └── download.js ├── index.js ├── package.json ├── src ├── Structures │ └── Util.js └── TikTok.js └── test ├── TikTok.mp4 └── index.js /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 Snowflake 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # TikTok Search 2 | Simple module to fetch data from TikTok. 3 | 4 | # Installing 5 | 6 | ```sh 7 | npm install tiktok-search 8 | ``` 9 | 10 | # Getting Started 11 | - Fetch song data 12 | 13 | ```js 14 | const TikTok = require("tiktok-search"); 15 | 16 | TikTok.getInfo("https://www.tiktok.com/@scout2015/video/6718335390845095173") 17 | .then(console.log); 18 | 19 | ``` 20 | 21 | # API 22 | ## getInfo(video_url) 23 | Returns video info. 24 | 25 | ## getUser(username) 26 | Returns User info. 27 | 28 | ## getEmbed(embedURL) 29 | Returns embed data. 30 | 31 | ## validateURL(url) 32 | Validates TikTok url. 33 | 34 | # Example 35 | ## Downloading TikTok Video 36 | 37 | ```js 38 | const TikTok = require("tiktok-search"); 39 | const fs = require("fs"); 40 | 41 | TikTok.download("https://vm.tiktok.com/ZMJrea3bs/") 42 | .then(res => { 43 | res.pipe(fs.createWriteStream(`./song.mp4`)); 44 | }); 45 | 46 | ``` 47 | 48 | # Responses 49 | ## Song Info 50 | 51 | ```js 52 | { 53 | id: '6718335390845095173', 54 | title: 'Scout and Suki on TikTok', 55 | description: 'Scramble up ur name & I’ll try to guess it�❤️ #foryoupage #petsoftiktok #aesthetic', 56 | url: 'https://www.tiktok.com/@scout2015/video/6718335390845095173', 57 | embedURL: 'https://www.tiktok.com/oembed?url=https://www.tiktok.com/@scout2015/video/6718335390845095173', 58 | thumbnail: { 59 | url: 'https://p16-sign-va.tiktokcdn.com/obj/tos-maliva-p-0068/06kv6rfcesljdjr45ukb0000d844090v0200000a05?x-expires=1597762800&x-signature=7tCHAFoBKVNGGQ6nUtVIar8LVcM%3D', 60 | size: { width: 720, height: 1280 } 61 | }, 62 | country: 'NP', 63 | streamURL: 'https://v16m.tiktokcdn.com/6faf787cbfcd5c681717b08adf975e5e/5f3bfa67/video/tos/useast2a/tos-useast2a-ve-0068/15fbafb086324317bf77a649580b1f95/?a=1233&br=4778&bt=2389&cr=0&cs=0&dr=0&ds=3&er=&l=2020081615572701011511924012B98AD5&lr=tiktok_m&mime_type=video_mp4&qs=0&rc=M245aWhvZ3U4bjMzZzczM0ApOTtmOzdoaDtnNzM5aTo1ZGczc29gcGdnMXJfLS01MTZzczI2L2FiLWFeLzI0MmJhYV86Yw%3D%3D&vl=&vr=', 64 | streams: [ 65 | 'https://v16m.tiktokcdn.com/6faf787cbfcd5c681717b08adf975e5e/5f3bfa67/video/tos/useast2a/tos-useast2a-ve-0068/15fbafb086324317bf77a649580b1f95/?a=1233&br=4778&bt=2389&cr=0&cs=0&dr=0&ds=3&er=&l=2020081615572701011511924012B98AD5&lr=tiktok_m&mime_type=video_mp4&qs=0&rc=M245aWhvZ3U4bjMzZzczM0ApOTtmOzdoaDtnNzM5aTo1ZGczc29gcGdnMXJfLS01MTZzczI2L2FiLWFeLzI0MmJhYV86Yw%3D%3D&vl=&vr=' 66 | ], 67 | videoDetails: { width: 720, height: 1280, ratio: 10, duration: 10 }, 68 | duration: 10000, 69 | covers: [ 70 | 'https://p16-sign-va.tiktokcdn.com/obj/tos-maliva-p-0068/06kv6rfcesljdjr45ukb0000d844090v0200000a05?x-expires=1597762800&x-signature=7tCHAFoBKVNGGQ6nUtVIar8LVcM%3D' 71 | ], 72 | comments: 8996, 73 | views: 144200, 74 | createTime: '1564234358', 75 | digg: 33700, 76 | shares: 796, 77 | author: { 78 | verified: true, 79 | secUid: 'MS4wLjABAAAAPZWNdkF_cmVSPCvV0Y6MCsH29mlAOlMOX3ikzGvlfMm3K6OMZv-JrRImpEHxdIMI', 80 | username: 'scout2015', 81 | id: '53279706535428096', 82 | displayName: 'Scout and Suki', 83 | covers: [ 84 | 'https://p16-amd-va.tiktokcdn.com/img/musically-maliva-obj/3c3deb8e39fe38fd856147bc5c598ba9~c5_100x100.jpeg', 85 | 'https://p16-tiktok-va-h2.ibyteimg.com/img/musically-maliva-obj/3c3deb8e39fe38fd856147bc5c598ba9~c5_100x100.jpeg' 86 | ], 87 | profile: 'https://www.tiktok.com/@scout2015', 88 | followers: 3700000, 89 | hearts: '54800000' 90 | }, 91 | challenge: { id: null, name: null }, 92 | music: { 93 | id: '6689804660171082501', 94 | name: 'original sound', 95 | author: '�������', 96 | covers: [ 97 | 'https://p16-amd-va.tiktokcdn.com/img/musically-maliva-obj/adf0c5e7b9ee237c29c4350fa892167a~c5_100x100.jpeg', 98 | 'https://p16-tiktok-va-h2.ibyteimg.com/img/musically-maliva-obj/adf0c5e7b9ee237c29c4350fa892167a~c5_100x100.jpeg' 99 | ] 100 | }, 101 | keywords: [ 102 | 'Scout and Suki', 'scout2015', 103 | 'foryoupage', 'PetsOfTikTok', 104 | 'aesthetic', 'bonevoyage', 105 | 'TikTok', 'ティックトック', 106 | 'tik tok', 'tick tock', 107 | 'tic tok', 'tic toc', 108 | 'tictok', 'тик ток', 109 | 'ticktock' 110 | ] 111 | } 112 | 113 | ``` 114 | 115 | ## Embed 116 | 117 | ```js 118 | { 119 | version: '1.0', 120 | type: 'video', 121 | title: 'Scramble up ur name & I’ll try to guess it�❤️ #foryoupage #petsoftiktok #aesthetic', 122 | author: { 123 | username: 'Scout and Suki', 124 | profile: 'https://www.tiktok.com/@scout2015' 125 | }, 126 | scale: { width: '100%', height: '100%' }, 127 | html: '
', 128 | thumbnail: { 129 | url: 'https://p16-sign-va.tiktokcdn.com/obj/tos-maliva-p-0068/06kv6rfcesljdjr45ukb0000d844090v0200000a05?x-expires=1597762800&x-signature=7tCHAFoBKVNGGQ6nUtVIar8LVcM%3D', 130 | height: 1280, 131 | width: 720 132 | }, 133 | provider: { name: 'TikTok', url: 'https://www.tiktok.com' } 134 | } 135 | 136 | ``` 137 | 138 | # User Profile 139 | 140 | ```js 141 | { 142 | id: '53279706535428096', 143 | username: 'scout2015', 144 | displayName: 'Scout and Suki', 145 | title: 'Scout and Suki on TikTok', 146 | description: '@scout2015 3.0m Followers, 1168 Following, 54.0m Likes - Watch awesome short videos created by Scout and Suki', 147 | profile: 'https://www.tiktok.com/@scout2015?lang=en', 148 | avatars: { 149 | thumbnail: 'https://p16-amd-va.tiktokcdn.com/img/musically-maliva-obj/3c3deb8e39fe38fd856147bc5c598ba9~c5_100x100.jpeg', 150 | medium: 'https://p16-amd-va.tiktokcdn.com/img/musically-maliva-obj/3c3deb8e39fe38fd856147bc5c598ba9~c5_720x720.jpeg' 151 | }, 152 | signature: '�3.0M Pawsitive Pack Memebers�\n' + 153 | '� @julyjackplayz �\n' + 154 | '��50% off pet plate��', 155 | verified: true, 156 | private: false, 157 | secUid: 'MS4wLjABAAAAPZWNdkF_cmVSPCvV0Y6MCsH29mlAOlMOX3ikzGvlfMm3K6OMZv-JrRImpEHxdIMI', 158 | following: 1168, 159 | followers: 3700000, 160 | hearts: '54800000', 161 | videos: 1644, 162 | digg: 0 163 | } 164 | 165 | ``` 166 | 167 | # Join my discord 168 | **[https://discord.gg/2SUybzb](https://discord.gg/2SUybzb)** -------------------------------------------------------------------------------- /esm/index.mjs: -------------------------------------------------------------------------------- 1 | import TikTok from "../index.js"; 2 | 3 | export default TikTok; 4 | export const { 5 | download, 6 | getEmbed, 7 | getInfo, 8 | getUser, 9 | validateURL 10 | } = TikTok; -------------------------------------------------------------------------------- /examples/discord.js: -------------------------------------------------------------------------------- 1 | /* 2 | This is a basic example on playing tiktok videos over discord. 3 | For this, you need to install FFmpeg, discord.js & @discordjs/opus. 4 | */ 5 | 6 | const Discord = require("discord.js"); 7 | const client = new Discord.Client(); 8 | const TikTok = require("tiktok-search"); 9 | 10 | client.on("ready", () => { 11 | console.log("Bot is online!"); 12 | }); 13 | 14 | client.on("message", async message => { 15 | if (message.author.bot || !message.guild) return; 16 | const prefix = "!"; 17 | if (!message.content.startsWith(prefix)) return; 18 | const args = message.content.slice(prefix.length).trim().split(" "); 19 | const command = args.shift().toLowerCase(); 20 | 21 | if (command === "ping") { 22 | if (!message.member.voice.channel) return message.reply("Join a voice channel!"); 23 | const song = args[0]; 24 | if (!TikTok.validateURL(song)) return message.channel.send("Provide a valid tiktok url."); 25 | 26 | const video = await TikTok.getInfo(song); 27 | if (!video) return message.channel.send("Invalid url."); 28 | 29 | const stream = await TikTok.download(song); 30 | 31 | message.member.voice.channel.join() 32 | .then(connection => { 33 | connection.play(stream) 34 | .on("start", () => { 35 | message.channel.send(`Started playing **${video.title}**.`); 36 | }) 37 | .on("finish", () => { 38 | message.guild.me.voice.channel.leave(); 39 | message.channel.send("Song ended!"); 40 | }) 41 | }); 42 | } 43 | }); 44 | 45 | client.login("SOME_REAL_TOKEN"); -------------------------------------------------------------------------------- /examples/download.js: -------------------------------------------------------------------------------- 1 | const TikTok = require("../index.js"); 2 | const fs = require("fs"); 3 | 4 | TikTok.download("TIKTOK_VIDEO_URL") 5 | .then(stream => stream.pipe(fs.createWriteStream("./TikTok.mp4"))); -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | module.exports = require("./src/TikTok.js"); -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "tiktok-search", 3 | "version": "2.0.3", 4 | "description": "Simple module to fetch data from TikTok.", 5 | "main": "index.js", 6 | "exports": { 7 | ".": [ 8 | { 9 | "require": "./index.js", 10 | "import": "./esm/index.mjs" 11 | }, 12 | "./index.js" 13 | ], 14 | "./esm": "./esm/index.mjs" 15 | }, 16 | "scripts": { 17 | "test": "cd test && node index.js" 18 | }, 19 | "repository": { 20 | "type": "git", 21 | "url": "git+https://github.com/Snowflake107/TikTok-Search.git" 22 | }, 23 | "keywords": [ 24 | "tiktok", 25 | "tiktok-search", 26 | "tiktok-scraper", 27 | "tiktok-api", 28 | "tiktok-downloader", 29 | "tiktok-video-downloader", 30 | "tiktok-signature", 31 | "tiktok-info" 32 | ], 33 | "author": "Snowflake107", 34 | "license": "MIT", 35 | "bugs": { 36 | "url": "https://github.com/Snowflake107/TikTok-Search/issues" 37 | }, 38 | "homepage": "https://github.com/Snowflake107/TikTok-Search#readme", 39 | "dependencies": { 40 | "cheerio": "^1.0.0-rc.3", 41 | "node-fetch": "^2.6.0" 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/Structures/Util.js: -------------------------------------------------------------------------------- 1 | const fetch = require("node-fetch"); 2 | const cheerio = require("cheerio"); 3 | const USER_AGENT = "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3738.0 Safari/537.36"; 4 | const REGEX = /^https?:\/\/(www\.|vm\.)?(tiktok\.com)\/?(.*)$/; 5 | 6 | class Util { 7 | 8 | /** 9 | * Parses plain html of a given url 10 | * @param {string} url Input url 11 | * @returns {Promise@scout2015 Scramble up ur name & I’ll try to guess it�❤️ #foryoupage #petsoftiktok #aesthetic
♬ original sound - �������