Skip to content

Commit

Permalink
Merge branch 'master' of github.com:drawrowfly/tiktok-scraper
Browse files Browse the repository at this point in the history
  • Loading branch information
drawrowfly committed Dec 10, 2020
2 parents db44eeb + 709b03b commit 0336f5f
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 37 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ This is not an official API support and etc. This is just a scraper that is usin
- Save post metadata to the JSON/CSV files
- Download media **with and without the watermark** and save to the ZIP file
- Download single video without the watermark from the CLI
- Sign URL to make custom request to the TIkTok API
- Sign URL to make custom request to the TikTok API
- Extract metadata from the User, Hashtag and Single Video pages
- **Save previous progress and download only new videos that weren't downloaded before**. This feature only works from the CLI and only if **download** flag is on.
- **View and manage previously downloaded posts history in the CLI**
Expand All @@ -66,8 +66,8 @@ This is not an official API support and etc. This is just a scraper that is usin
- [x] Download video without the watermark
- [x] Indicate in the output file(csv/json) if the video was downloaded or not
- [x] Build and run from Docker
- [x] CLI: Scrape and download in batchu
- [x] CLi: Load proxies from a file
- [x] CLI: Scrape and download in batch
- [x] CLI: Load proxies from a file
- [x] CLI: Optional ZIP
- [x] Renew API
- [x] Set WebHook URL (CLI)
Expand Down
2 changes: 1 addition & 1 deletion examples/CLI/BatchDownload.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[Go back to the Main Documenation](https://github.com/drawrowfly/tiktok-scraper/blob/master/README.md)
[Go back to the Main Documentation](https://github.com/drawrowfly/tiktok-scraper/blob/master/README.md)

## Batch Scrape And Download Example

Expand Down
2 changes: 1 addition & 1 deletion examples/CLI/DownloadHistory.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[Go back to the Main Documenation](https://github.com/drawrowfly/tiktok-scraper/blob/master/README.md)
[Go back to the Main Documentation](https://github.com/drawrowfly/tiktok-scraper/blob/master/README.md)

## Manage Download History

Expand Down
2 changes: 1 addition & 1 deletion examples/CLI/Examples.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[Go back to the Main Documenation](https://github.com/drawrowfly/tiktok-scraper/blob/master/README.md)
[Go back to the Main Documentation](https://github.com/drawrowfly/tiktok-scraper/blob/master/README.md)

## Terminal Examples

Expand Down
64 changes: 33 additions & 31 deletions src/entry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,29 +22,31 @@ import {
import CONST from './constant';
import { makeid } from './helpers';

const INIT_OPTIONS = {
number: 30,
download: false,
zip: false,
asyncDownload: 5,
asyncScraping: 3,
proxy: [],
filepath: process.cwd(),
filetype: 'na',
progress: false,
event: false,
by_user_id: false,
noWaterMark: false,
hdVideo: false,
timeout: 0,
tac: '',
signature: '',
verifyFp: CONST.verifyFp(),
headers: {
'User-Agent': CONST.userAgent(),
Referer: 'https://www.tiktok.com/',
Cookie: `tt_webid_v2=68${makeid(16)}`,
},
const getInitOptions = () => {
return {
number: 30,
download: false,
zip: false,
asyncDownload: 5,
asyncScraping: 3,
proxy: [],
filepath: process.cwd(),
filetype: 'na',
progress: false,
event: false,
by_user_id: false,
noWaterMark: false,
hdVideo: false,
timeout: 0,
tac: '',
signature: '',
verifyFp: CONST.verifyFp(),
headers: {
'User-Agent': CONST.userAgent(),
Referer: 'https://www.tiktok.com/',
Cookie: `tt_webid_v2=68${makeid(16)}`,
}
}
};

/**
Expand Down Expand Up @@ -73,7 +75,7 @@ const promiseScraper = async (input: string, type: ScrapeType, options = {} as O
options.proxy = await proxyFromFile(options?.proxyFile);
}

const constructor: TikTokConstructor = { ...INIT_OPTIONS, ...options, ...{ type, input } };
const constructor: TikTokConstructor = { ...getInitOptions(), ...options, ...{ type, input } };

const scraper = new TikTokScraper(constructor);

Expand All @@ -86,7 +88,7 @@ const eventScraper = (input: string, type: ScrapeType, options = {} as Options):
throw new TypeError('Object is expected');
}

const contructor: TikTokConstructor = { ...INIT_OPTIONS, ...options, ...{ type, input, event: true } };
const contructor: TikTokConstructor = { ...getInitOptions(), ...options, ...{ type, input, event: true } };
return new TikTokScraper(contructor);
};

Expand All @@ -108,7 +110,7 @@ export const getHashtagInfo = async (input: string, options = {} as Options): Pr
options.proxy = await proxyFromFile(options?.proxyFile);
}

const contructor: TikTokConstructor = { ...INIT_OPTIONS, ...options, ...{ type: 'signle_hashtag' as ScrapeType, input } };
const contructor: TikTokConstructor = { ...getInitOptions(), ...options, ...{ type: 'signle_hashtag' as ScrapeType, input } };
const scraper = new TikTokScraper(contructor);

const result = await scraper.getHashtagInfo();
Expand All @@ -123,7 +125,7 @@ export const getMusicInfo = async (input: string, options = {} as Options): Prom
options.proxy = await proxyFromFile(options?.proxyFile);
}

const contructor: TikTokConstructor = { ...INIT_OPTIONS, ...options, ...{ type: 'single_music' as ScrapeType, input } };
const contructor: TikTokConstructor = { ...getInitOptions(), ...options, ...{ type: 'single_music' as ScrapeType, input } };
const scraper = new TikTokScraper(contructor);

const result = await scraper.getMusicInfo();
Expand All @@ -138,7 +140,7 @@ export const getUserProfileInfo = async (input: string, options = {} as Options)
if (options?.proxyFile) {
options.proxy = await proxyFromFile(options?.proxyFile);
}
const contructor: TikTokConstructor = { ...INIT_OPTIONS, ...options, ...{ type: 'sinsgle_user' as ScrapeType, input } };
const contructor: TikTokConstructor = { ...getInitOptions(), ...options, ...{ type: 'sinsgle_user' as ScrapeType, input } };
const scraper = new TikTokScraper(contructor);

const result = await scraper.getUserProfileInfo();
Expand All @@ -153,7 +155,7 @@ export const signUrl = async (input: string, options = {} as Options): Promise<s
options.proxy = await proxyFromFile(options?.proxyFile);
}

const contructor: TikTokConstructor = { ...INIT_OPTIONS, ...options, ...{ type: 'signature' as ScrapeType, input } };
const contructor: TikTokConstructor = { ...getInitOptions(), ...options, ...{ type: 'signature' as ScrapeType, input } };
const scraper = new TikTokScraper(contructor);

const result = await scraper.signUrl();
Expand All @@ -168,7 +170,7 @@ export const getVideoMeta = async (input: string, options = {} as Options): Prom
if (options?.proxyFile) {
options.proxy = await proxyFromFile(options?.proxyFile);
}
const contructor: TikTokConstructor = { ...INIT_OPTIONS, ...options, ...{ type: 'video_meta' as ScrapeType, input } };
const contructor: TikTokConstructor = { ...getInitOptions(), ...options, ...{ type: 'video_meta' as ScrapeType, input } };
const scraper = new TikTokScraper(contructor);

const result = await scraper.getVideoMeta();
Expand All @@ -186,7 +188,7 @@ export const video = async (input: string, options = {} as Options): Promise<any
if (options?.proxyFile) {
options.proxy = await proxyFromFile(options?.proxyFile);
}
const contructor: TikTokConstructor = { ...INIT_OPTIONS, ...options, ...{ type: 'video' as ScrapeType, input } };
const contructor: TikTokConstructor = { ...getInitOptions(), ...options, ...{ type: 'video' as ScrapeType, input } };
const scraper = new TikTokScraper(contructor);
const result: PostCollector = await scraper.getVideoMeta();

Expand Down

0 comments on commit 0336f5f

Please sign in to comment.