Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 11 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,9 @@ api = TikTokApi()

results = 10

trending = api.trending(count=results)
# Since TikTok changed their API you need to use the custom_verifyFp option.
# In your web browser you will need to go to TikTok, Log in and get the s_v_web_id value.
trending = api.trending(count=results, custom_verifyFp="")

for tiktok in trending:
# Prints the id of the tiktok
Expand Down Expand Up @@ -132,7 +134,7 @@ executablePath - The path to your chromedriver if you don't want global install
##### The trending Method

```
api.trending(self, count=30, referrer="https://www.tiktok.com/@ondymikula/video/6756762109670477061", language='en', proxy=None)
api.trending(self, count=30, referrer="https://www.tiktok.com/@ondymikula/video/6756762109670477061", language='en', proxy=None, , custom_verifyFp="")
```

count - this is how many trending Tiktoks you want to be returned.
Expand All @@ -142,7 +144,7 @@ Trending returns an array of dictionaries. Example structure [here](https://www.
##### The get_Video_By_TikTok Method

```
api.get_Video_By_TikTok(data, language='en', proxy=None)
api.get_Video_By_TikTok(data, language='en', proxy=None, , custom_verifyFp="")
```

data - The tiktok dictionary returned from the API. Will return bytes.
Expand Down Expand Up @@ -301,7 +303,7 @@ getSuggestedMusicIDCrawler(self, count=30, startingId='6745191554350760966', lan
##### The get_Video_By_DownloadURL Method

```
api.get_Video_By_DownloadURL(url, language='en', proxy=None)
api.get_Video_By_DownloadURL(url, language='en', proxy=None, custom_verifyFp="")
```

url - The download url that's found in the TikTok dictionary. TikTok['video']['downloadAddr']
Expand All @@ -310,7 +312,7 @@ url - The download url that's found in the TikTok dictionary. TikTok['video']['d
##### The get_Video_By_Url Method

```
api.get_Video_By_Url(video_url, return_bytes=0)
api.get_Video_By_Url(video_url, return_bytes=0, custom_verifyFp="")
```

video_url - The video you want to get url.
Expand All @@ -320,7 +322,7 @@ return_bytes - The default value is 0, when it is set to 1 the function instead
##### The get_Video_No_Watermark_Faster Method

```
api.get_Video_No_Watermark(video_url, return_bytes=0, language='en', proxy=None)
api.get_Video_No_Watermark(video_url, return_bytes=0, language='en', proxy=None, custom_verifyFp="")
```

video_url - The video you want to get url.
Expand All @@ -329,7 +331,7 @@ return_bytes - The default value is 0, when it is set to 1 the function instead

If you request without bytes you will need to make a call to the URL it responds yourself to get bytes.
```
url = api.get_Video_No_Watermark_ID('6829267836783971589', return_bytes=0)
url = api.get_Video_No_Watermark_ID('6829267836783971589', return_bytes=0, custom_verifyFp="")

import requests
video_bytes = requests.get(url, headers={"User-Agent": "okhttp"}).content
Expand Down Expand Up @@ -370,7 +372,7 @@ You can use this method if you really want, but just use the 3 above it.
##### The get_Video_No_Watermark_ID Method

```
api.get_Video_No_Watermark_ID(self, video_id, return_bytes=1, proxy=None)
api.get_Video_No_Watermark_ID(self, video_id, return_bytes=1, proxy=None, custom_verifyFp="")
```

video_id - The video id you want to get.
Expand All @@ -388,7 +390,7 @@ video_bytes = requests.get(url, headers={"User-Agent": "okhttp"}).content

##### The get_Video_No_Watermark Method
```
api.get_Video_No_Watermark(self, video_url, return_bytes=0, proxy=None)
api.get_Video_No_Watermark(self, video_url, return_bytes=0, proxy=None, custom_verifyFp="")
```

This endpoint returns a url that is able to be opened in any browser, but sacrifices speed for this convenience. Any old request library can return the bytes if you decide to return a url.
Expand Down
11 changes: 6 additions & 5 deletions TikTokApi/browser.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def __init__(
self.args = args
self.args.append("--user-agent=" + self.userAgent)

if self.proxy != None:
if self.proxy is not None:
if "@" in self.proxy:
self.args.append(
"--proxy-server="
Expand All @@ -96,7 +96,7 @@ def __init__(

self.options.update(options)

if self.executablePath != None:
if self.executablePath is not None:
self.options["executablePath"] = self.executablePath

if async_support:
Expand Down Expand Up @@ -133,7 +133,8 @@ async def newParams(self) -> None:

# self.browser_language = await self.page.evaluate("""() => { return navigator.language || navigator.userLanguage; }""")
self.browser_language = ""
# self.timezone_name = await self.page.evaluate("""() => { return Intl.DateTimeFormat().resolvedOptions().timeZone; }""")
# self.timezone_name = await self.page.evaluate("""() => { return
# Intl.DateTimeFormat().resolvedOptions().timeZone; }""")
self.timezone_name = ""
# self.browser_platform = await self.page.evaluate("""() => { return window.navigator.platform; }""")
self.browser_platform = ""
Expand Down Expand Up @@ -263,7 +264,7 @@ async def find_redirect(self):
self.browser.process.communicate()

def __format_proxy(self, proxy):
if proxy != None:
if proxy is not None:
return {"http": proxy, "https": proxy}
else:
return None
Expand All @@ -272,4 +273,4 @@ def __get_js(self):
return requests.get(
"https://sf16-muse-va.ibytedtos.com/obj/rc-web-sdk-gcs/acrawler.js",
proxies=self.__format_proxy(self.proxy),
).text
).text
Loading