Skip to content

Commit

Permalink
Merge pull request #409 from davidteather/nightly
Browse files Browse the repository at this point in the history
V3.8.4 - Fix Some Changes & Add Option For Test Endpoints
  • Loading branch information
davidteather authored Dec 7, 2020
2 parents 9e839fa + 6fddd93 commit 5aec299
Show file tree
Hide file tree
Showing 14 changed files with 21 additions and 17 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,6 @@ test.mp4
test.txt
.pytest_cache/*
tests/__pycache__/*
*.pyc
*.pyc
acrawl.js
test2.py
8 changes: 5 additions & 3 deletions TikTokApi/tiktok.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ def __init__(self, **kwargs):
self.proxy = kwargs.get("proxy", None)
self.custom_verifyFp = kwargs.get("custom_verifyFp")

if kwargs.get("use_test_endpoints", False):
global BASE_URL
BASE_URL = "https://t.tiktok.com/"
if kwargs.get("use_selenium", False):
from .browser_selenium import browser
else:
Expand Down Expand Up @@ -210,7 +213,7 @@ def getData(self, **kwargs) -> dict:
raise JSONDecodeFailure() from e

def get_cookies(self, **kwargs):
did = kwargs.get("did", str(random.randint(10000, 999999999)))
did = kwargs.get("custom_did", ''.join(random.choice(string.digits) for num in range(19)))
if kwargs.get("custom_verifyFp") == None:
if self.custom_verifyFp != None:
verifyFp = self.custom_verifyFp
Expand Down Expand Up @@ -1564,7 +1567,6 @@ def __process_kwargs__(self, kwargs):
language = kwargs.get("language", "en")
proxy = kwargs.get("proxy", None)
maxCount = kwargs.get("maxCount", 35)
did = kwargs.get("did", str(random.randint(10000, 999999999)))
kwargs["did"] = did
did = kwargs.get("custom_did", ''.join(random.choice(string.digits) for num in range(19)))

return region, language, proxy, maxCount, did
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
setuptools.setup(
name="TikTokApi",
packages=["TikTokApi"],
version="3.8.3",
version="3.8.4",
license="MIT",
description="The Unofficial TikTok API Wrapper in Python 3.",
author="David Teather",
Expand Down
4 changes: 2 additions & 2 deletions tests/test_byHashtag.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from TikTokApi import TikTokApi
import os

api = TikTokApi.get_instance(custom_verifyFp=os.environ.get("verifyFp", None))
api = TikTokApi.get_instance(custom_verifyFp=os.environ.get("verifyFp", None), use_test_endpoints=True)


def unique_count(tiktoks):
Expand All @@ -16,7 +16,7 @@ def test_hashtag():
assert len(api.byHashtag("funny", 5)) == 5
assert len(api.byHashtag("funny", 10)) == 10
assert len(api.byHashtag("funny", 20)) == 20
assert len(unique_count(api.byHashtag("funny", 500))) == 500
assert abs(len(unique_count(api.byHashtag("funny", 500)))-500) <= 5


def test_non_latin1():
Expand Down
2 changes: 1 addition & 1 deletion tests/test_bySound.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from TikTokApi import TikTokApi
import os

api = TikTokApi.get_instance(custom_verifyFp=os.environ.get("verifyFp", None))
api = TikTokApi.get_instance(custom_verifyFp=os.environ.get("verifyFp", None), use_test_endpoints=True)


def test_trending():
Expand Down
2 changes: 1 addition & 1 deletion tests/test_byUsername.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from TikTokApi import TikTokApi
import os

api = TikTokApi.get_instance(custom_verifyFp=os.environ.get("verifyFp", None))
api = TikTokApi.get_instance(custom_verifyFp=os.environ.get("verifyFp", None), use_test_endpoints=True)


def test_trending():
Expand Down
2 changes: 1 addition & 1 deletion tests/test_discover.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from TikTokApi import TikTokApi
import os

api = TikTokApi.get_instance(custom_verifyFp=os.environ.get("verifyFp", None))
api = TikTokApi.get_instance(custom_verifyFp=os.environ.get("verifyFp", None), use_test_endpoints=True)


def test_trending():
Expand Down
2 changes: 1 addition & 1 deletion tests/test_getHashtagDetails.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from TikTokApi import TikTokApi
import os

api = TikTokApi.get_instance(custom_verifyFp=os.environ.get("verifyFp", None))
api = TikTokApi.get_instance(custom_verifyFp=os.environ.get("verifyFp", None), use_test_endpoints=True)


def test_getHashtagDetails():
Expand Down
2 changes: 1 addition & 1 deletion tests/test_getObjectRoutes.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from TikTokApi import TikTokApi
import os

api = TikTokApi.get_instance(custom_verifyFp=os.environ.get("verifyFp", None))
api = TikTokApi.get_instance(custom_verifyFp=os.environ.get("verifyFp", None), use_test_endpoints=True)


def test_tiktok_object():
Expand Down
2 changes: 1 addition & 1 deletion tests/test_search_for.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from TikTokApi import TikTokApi
import os

api = TikTokApi.get_instance(custom_verifyFp=os.environ.get("verifyFp", None))
api = TikTokApi.get_instance(custom_verifyFp=os.environ.get("verifyFp", None), use_test_endpoints=True)


def test_search_for():
Expand Down
2 changes: 1 addition & 1 deletion tests/test_suggested.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from TikTokApi import TikTokApi
import os

api = TikTokApi.get_instance(custom_verifyFp=os.environ.get("verifyFp", None))
api = TikTokApi.get_instance(custom_verifyFp=os.environ.get("verifyFp", None), use_test_endpoints=True)


def test_suggested():
Expand Down
2 changes: 1 addition & 1 deletion tests/test_trending.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from TikTokApi import TikTokApi
import os

api = TikTokApi.get_instance(custom_verifyFp=os.environ.get("verifyFp", None))
api = TikTokApi.get_instance(custom_verifyFp=os.environ.get("verifyFp", None), use_test_endpoints=True)


def test_trending():
Expand Down
2 changes: 1 addition & 1 deletion tests/test_user.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from TikTokApi import TikTokApi
import os

api = TikTokApi.get_instance(custom_verifyFp=os.environ.get("verifyFp", None))
api = TikTokApi.get_instance(custom_verifyFp=os.environ.get("verifyFp", None), use_test_endpoints=True)


def test_user():
Expand Down
2 changes: 1 addition & 1 deletion tests/test_userPager.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from TikTokApi import TikTokApi
import os

api = TikTokApi.get_instance(custom_verifyFp=os.environ.get("verifyFp", None))
api = TikTokApi.get_instance(custom_verifyFp=os.environ.get("verifyFp", None), use_test_endpoints=True)


class TestUserPager:
Expand Down

0 comments on commit 5aec299

Please sign in to comment.