Skip to content

Commit

Permalink
Merge pull request #10 from hansputera/dev
Browse files Browse the repository at this point in the history
feat(provider): add titkokdownloader.one
  • Loading branch information
hansputera authored Dec 21, 2021
2 parents ce490af + a82978f commit fec4c1e
Show file tree
Hide file tree
Showing 5 changed files with 106 additions and 12 deletions.
23 changes: 12 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,34 +1,34 @@
# TikTok Downloader
# TikTok Downloader

Video TikTok Downloader using NodeJS with Watermark and Non-Watermark.
Video TikTok Downloader using 🧰 NodeJS with Watermark and Non-Watermark!

## Technology/Dependencies
## 〽️ Technology/Dependencies
- [Got](https://npmjs.com/got)
- [Ow](https://npmjs.com/ow)
- [VM2](https://npmjs.com/vm2)

## Develop
## Develop 👷
- Clone/fork into a directory you want.
- Install all dependencies correctly (`yarn install` or `npm install`)
- Install vercel cli too with `npm install vercel -g` or `yarn global add vercel`
- Ran `vercel dev` for development (default port is: `3000`)
> Use `vercel --prod` for production use.
> Use `vercel --prod` for production use 😎
# Configuration
# Configuration 🔑

**Environment Setup:**
1. Rename `.env.example` to `.env`
2. Fill `REDIS_URL` value with your redis database url.

**Environment Setup on Hosting:**
**Environment Setup on Hosting:** (vercel)
1. Go to your project settings.
2. Find `Environment Variables` button and click it.
3. Add environment variable with `REDIS_URL` as the name, and fill the value using your redis url.

## Endpoints
## ☁️ Endpoints
Available on [Wiki](https://github.com/hansputera/tiktok-dl/wiki/Endpoints)

## Credits + Source
## 🔥 Credits + Source

- [TikTok](https://tiktok.com)
- [SnapTik](https://snaptik.app)
Expand All @@ -42,6 +42,7 @@ Available on [Wiki](https://github.com/hansputera/tiktok-dl/wiki/Endpoints)
- [TikDown](https://tikdown.org)
- [DownTik](https://downtik.net)
- [LoveTik](https://lovetik.com)
- [Tokup](https://tokup.app) (TTSave alternative)
- [Tokup](https://tokup.app)
- [TikTokDownloaderOne](https://tiktokdownloader.one) (TTSave alternative)

Contribution(s) are welcome!
🧗‍♀️ Contribution(s) are welcome!
89 changes: 89 additions & 0 deletions lib/providers/downloaderOneProvider.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
import {BaseProvider, ExtractedInfo} from './baseProvider';
import {getFetch} from '../fetch';
import {handleException} from '../decorators';

/**
* @class DownloadOne
*/
export class DownloadOne extends BaseProvider {
/**
* Get provider name
* @return {string}
*/
public resourceName(): string {
return 'ttdownloaderone';
}

public client = getFetch('http://tiktokdownloader.one');

/**
* Fetch ttdownloader.one
* @param {string} url Video TikTok URL
* @return {Promise<ExtractedInfo>}
*/
@handleException
public async fetch(
url: string,
): Promise<ExtractedInfo> {
// getting the token
const response = await this.client('./');

const token = (/name="_token_" content="(.*)"/gi
.exec(response.body) as string[])[1];

const dlResponse = await this.client(
'./api/v1/fetch?url=' + url, {
'headers': {
'TOKEN': token,
'Referer': 'http://tiktokdownloader.one/',
'Origin': 'http://tiktokdownloader.one',
'Accept': 'application/json, text/plain, */*',
},
},
);

if (dlResponse.statusCode !== 200) {
return {
'error': 'Probably the video doesn\'t exist',
};
}

return this.extract(dlResponse.body);
}

/**
* Extract page from ttdownloader.one site
* @param {string} html
* @return {ExtractedInfo}
*/
extract(html: string): ExtractedInfo {
const json = JSON.parse(html);

return {
'result': {
'urls': [
json.url,
json.url_nwm,
],
'thumb': json.cover,
'advanced': {
'videoId': json.video_id,
'musicUrl': json.music.url,
'musicTitle': json.music.title,
'musicAuthor': json.music.author,
'musicCover': json.music.cover,
'author': json.user.username,
'authorId': json.user.name,
'authorThumb': json.user.cover,
'uploadedAt': json.uploaded_at,
'updatedAt': json.updated_at ?? '-',
'caption': json.caption,
'commentsCount': json.stats.comment,
'sharesCount': json.stats.shares,
'likesCount': json.stats.like,
'playsCount': json.stats.play,
},
},
};
}
}
2 changes: 2 additions & 0 deletions lib/providers/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {DownTikProvider} from './downTikProvider';
import {LoveTikProvider} from './loveTikProvider';
import {DDDTikProvider} from './dddTikProvider';
import {TokupProvider} from './tokupProvider';
import {DownloadOne} from './downloaderOneProvider';

export const Providers: BaseProvider[] = [
new SnaptikProvider(),
Expand All @@ -28,6 +29,7 @@ export const Providers: BaseProvider[] = [
new LoveTikProvider(),
new DDDTikProvider(),
new TokupProvider(), // ttsave alternative
new DownloadOne(),
];

export const getRandomProvider = () => Providers[
Expand Down
2 changes: 2 additions & 0 deletions lib/providers/tokupProvider.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import {BaseProvider, ExtractedInfo} from './baseProvider';
import {getFetch} from '../fetch';
import {handleException} from '../decorators';

/**
* @class TokupProvider
Expand All @@ -20,6 +21,7 @@ export class TokupProvider extends BaseProvider {
* @param {string} url - TikTok Video URL
* @return {Promise<ExtractedInfo>}
*/
@handleException
public async fetch(
url: string,
): Promise<ExtractedInfo> {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "tktk",
"version": "1.0.0",
"version": "1.0.3",
"main": "index.js",
"license": "MIT",
"dependencies": {
Expand Down

1 comment on commit fec4c1e

@vercel
Copy link

@vercel vercel bot commented on fec4c1e Dec 21, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.